diff options
author | Andreas Kling <kling@serenityos.org> | 2020-07-21 18:46:39 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-07-21 19:08:01 +0200 |
commit | d1dd5013ead09bf123e95d40404c970829190ad2 (patch) | |
tree | bb2941fab31248e32a51ec9702f865ba7fe89048 /DevTools/UserspaceEmulator/MallocTracer.cpp | |
parent | b820e4626c1a1bde87684807273a7464f160311d (diff) | |
download | serenity-d1dd5013ead09bf123e95d40404c970829190ad2.zip |
UserspaceEmulator: Remove unnecessary local getpid() caches
Now that LibC caches this for us, we can stop worrying.
Diffstat (limited to 'DevTools/UserspaceEmulator/MallocTracer.cpp')
-rw-r--r-- | DevTools/UserspaceEmulator/MallocTracer.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/DevTools/UserspaceEmulator/MallocTracer.cpp b/DevTools/UserspaceEmulator/MallocTracer.cpp index 47c0e53ae1..31e3da0636 100644 --- a/DevTools/UserspaceEmulator/MallocTracer.cpp +++ b/DevTools/UserspaceEmulator/MallocTracer.cpp @@ -34,8 +34,6 @@ namespace UserspaceEmulator { -static pid_t s_pid = getpid(); - MallocTracer::MallocTracer() { } @@ -69,8 +67,8 @@ void MallocTracer::target_did_free(Badge<SoftCPU>, FlatPtr address) if (mallocation.address == address) { if (mallocation.freed) { dbgprintf("\n"); - dbgprintf("==%d== \033[31;1mDouble free()\033[0m, %p\n", s_pid, address); - dbgprintf("==%d== Address %p has already been passed to free()\n", s_pid, address); + dbgprintf("==%d== \033[31;1mDouble free()\033[0m, %p\n", getpid(), address); + dbgprintf("==%d== Address %p has already been passed to free()\n", getpid(), address); Emulator::the().dump_backtrace(); } else { mallocation.freed = true; @@ -80,8 +78,8 @@ void MallocTracer::target_did_free(Badge<SoftCPU>, FlatPtr address) } } dbgprintf("\n"); - dbgprintf("==%d== \033[31;1mInvalid free()\033[0m, %p\n", s_pid, address); - dbgprintf("==%d== Address %p has never been returned by malloc()\n", s_pid, address); + dbgprintf("==%d== \033[31;1mInvalid free()\033[0m, %p\n", getpid(), address); + dbgprintf("==%d== Address %p has never been returned by malloc()\n", getpid(), address); Emulator::the().dump_backtrace(); } @@ -110,11 +108,11 @@ void MallocTracer::audit_read(FlatPtr address, size_t size) if (mallocation->freed) { dbgprintf("\n"); - dbgprintf("==%d== \033[31;1mUse-after-free\033[0m, invalid %zu-byte read at address %p\n", s_pid, size, address); + dbgprintf("==%d== \033[31;1mUse-after-free\033[0m, invalid %zu-byte read at address %p\n", getpid(), size, address); Emulator::the().dump_backtrace(); - dbgprintf("==%d== Address is %zu bytes into block of size %zu, allocated at:\n", s_pid, offset_into_mallocation, mallocation->size); + dbgprintf("==%d== Address is %zu bytes into block of size %zu, allocated at:\n", getpid(), offset_into_mallocation, mallocation->size); Emulator::the().dump_backtrace(mallocation->malloc_backtrace); - dbgprintf("==%d== Later freed at:\n", s_pid, offset_into_mallocation, mallocation->size); + dbgprintf("==%d== Later freed at:\n", getpid(), offset_into_mallocation, mallocation->size); Emulator::the().dump_backtrace(mallocation->free_backtrace); return; } @@ -136,11 +134,11 @@ void MallocTracer::audit_write(FlatPtr address, size_t size) if (mallocation->freed) { dbgprintf("\n"); - dbgprintf("==%d== \033[31;1mUse-after-free\033[0m, invalid %zu-byte write at address %p\n", s_pid, size, address); + dbgprintf("==%d== \033[31;1mUse-after-free\033[0m, invalid %zu-byte write at address %p\n", getpid(), size, address); Emulator::the().dump_backtrace(); - dbgprintf("==%d== Address is %zu bytes into block of size %zu, allocated at:\n", s_pid, offset_into_mallocation, mallocation->size); + dbgprintf("==%d== Address is %zu bytes into block of size %zu, allocated at:\n", getpid(), offset_into_mallocation, mallocation->size); Emulator::the().dump_backtrace(mallocation->malloc_backtrace); - dbgprintf("==%d== Later freed at:\n", s_pid, offset_into_mallocation, mallocation->size); + dbgprintf("==%d== Later freed at:\n", getpid(), offset_into_mallocation, mallocation->size); Emulator::the().dump_backtrace(mallocation->free_backtrace); return; } @@ -211,15 +209,15 @@ void MallocTracer::dump_leak_report() ++leaks_found; bytes_leaked += mallocation.size; dbgprintf("\n"); - dbgprintf("==%d== \033[31;1mLeak\033[0m, %zu-byte allocation at address %p\n", s_pid, mallocation.size, mallocation.address); + dbgprintf("==%d== \033[31;1mLeak\033[0m, %zu-byte allocation at address %p\n", getpid(), mallocation.size, mallocation.address); Emulator::the().dump_backtrace(mallocation.malloc_backtrace); } dbgprintf("\n"); if (!leaks_found) - dbgprintf("==%d== \033[32;1mNo leaks found!\033[0m\n", s_pid); + dbgprintf("==%d== \033[32;1mNo leaks found!\033[0m\n", getpid()); else - dbgprintf("==%d== \033[31;1m%zu leak(s) found: %zu byte(s) leaked\033[0m\n", s_pid, leaks_found, bytes_leaked); + dbgprintf("==%d== \033[31;1m%zu leak(s) found: %zu byte(s) leaked\033[0m\n", getpid(), leaks_found, bytes_leaked); } } |