diff options
Diffstat (limited to 'libc/malloc_debug/malloc_debug.cpp')
-rw-r--r-- | libc/malloc_debug/malloc_debug.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp index 609f030bf..b27853a9a 100644 --- a/libc/malloc_debug/malloc_debug.cpp +++ b/libc/malloc_debug/malloc_debug.cpp @@ -39,6 +39,8 @@ #include <sys/syscall.h> #include <unistd.h> +#include <sys/system_properties.h> + #include <mutex> #include <vector> @@ -66,6 +68,10 @@ DebugData* g_debug; bool* g_zygote_child; const MallocDispatch* g_dispatch; + +size_t g_min_alloc_to_record = 0; +size_t g_max_alloc_to_record = SIZE_MAX; + // ------------------------------------------------------------------------ // ------------------------------------------------------------------------ @@ -325,6 +331,23 @@ bool debug_initialize(const MallocDispatch* malloc_dispatch, bool* zygote_child, // of different error cases. backtrace_startup(); + char min_alloc_to_record[10]; + if (__system_property_get("libc.debug.malloc.minalloctorecord", min_alloc_to_record)) { + g_min_alloc_to_record = atoi(min_alloc_to_record); + } + + char max_alloc_to_record[10]; + if (__system_property_get("libc.debug.malloc.maxalloctorecord", max_alloc_to_record)) { + g_max_alloc_to_record = atoi(max_alloc_to_record); + } + + if (g_min_alloc_to_record > g_max_alloc_to_record) { + error_log("%s: min_alloc_to_record > max_alloc_to_record!," + "reverting back to default limits", getprogname()); + g_min_alloc_to_record = 0; + g_max_alloc_to_record = SIZE_MAX; + } + if (g_debug->config().options() & VERBOSE) { info_log("%s: malloc debug enabled", getprogname()); } |