Add record_allocs_on_exit option.
Add a config parameter "record_allocs_on_exit" that will cause the
currently recorded set of allocs to be dumped to a file when
the process exits.
Update the documentation, and add new unit tests.
Test: Unit tests pass.
Change-Id: I81d31bc63b8a6709697533c5099dcc6444c11d47
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index b66b8e2..6d88092 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -451,6 +451,10 @@
PointerData::LogLeaks();
}
+ if ((g_debug->config().options() & RECORD_ALLOCS) && g_debug->config().record_allocs_on_exit()) {
+ RecordData::WriteEntriesOnExit();
+ }
+
if ((g_debug->config().options() & BACKTRACE) && g_debug->config().backtrace_dump_on_exit()) {
debug_dump_heap(android::base::StringPrintf("%s.%d.exit.txt",
g_debug->config().backtrace_dump_prefix().c_str(),