summaryrefslogtreecommitdiff
path: root/DevTools/UserspaceEmulator/MallocTracer.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-07-16 19:15:38 +0200
committerAndreas Kling <kling@serenityos.org>2020-07-16 19:21:45 +0200
commit3dc1c809581cba246fe29afda5e2739e2c887b17 (patch)
tree072ad5e2cc2dcb8596eb19bf219838062ae67476 /DevTools/UserspaceEmulator/MallocTracer.cpp
parentc13da77e8509cdd3e71af049d105fa15de32fd72 (diff)
downloadserenity-3dc1c809581cba246fe29afda5e2739e2c887b17.zip
UserspaceEmulator: Print the number of bytes leaked on exit :^)
Diffstat (limited to 'DevTools/UserspaceEmulator/MallocTracer.cpp')
-rw-r--r--DevTools/UserspaceEmulator/MallocTracer.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/DevTools/UserspaceEmulator/MallocTracer.cpp b/DevTools/UserspaceEmulator/MallocTracer.cpp
index 3230e6a093..36bad55a19 100644
--- a/DevTools/UserspaceEmulator/MallocTracer.cpp
+++ b/DevTools/UserspaceEmulator/MallocTracer.cpp
@@ -187,6 +187,7 @@ void MallocTracer::dump_leak_report()
{
TemporaryChange change(m_auditing_enabled, false);
+ size_t bytes_leaked = 0;
size_t leaks_found = 0;
for (auto& mallocation : m_mallocations) {
if (mallocation.freed)
@@ -194,12 +195,17 @@ void MallocTracer::dump_leak_report()
if (is_reachable(mallocation))
continue;
++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);
Emulator::the().dump_backtrace(mallocation.malloc_backtrace);
}
- dbgprintf("==%d== \033[%d;1m%zu leak(s) found\033[0m\n", s_pid, leaks_found ? 31 : 32, leaks_found);
+ dbgprintf("\n");
+ if (!leaks_found)
+ dbgprintf("==%d== \033[32;1mNo leaks found!\033[0m\n", s_pid);
+ else
+ dbgprintf("==%d== \033[31;1m%zu leak(s) found: %zu byte(s) leaked\033[0m\n", s_pid, leaks_found, bytes_leaked);
}
}