malloc_debug: Implement allocation dump on exit in guarded heap.
When enabled (using heap_debug_dump_allocations_on_exit(true) or MALLOC_DEBUG=e) this causes a dump of all remaining allocations when libroot_debug is unloaded. It uses terminate_after to be called as late as possible. When combined with alloc stack traces this makes for a nice if a bit crude leak checker. Note that a lot of allocations usually remain even at that stage due to statically, lazyly and globally allocated stuff from the various system libraries where it isn't necessarily worth the overhead to free them when the program terminates anyway.
This commit is contained in:
@@ -30,6 +30,7 @@ void *heap_debug_malloc_with_guard_page(size_t size);
|
||||
status_t heap_debug_get_allocation_info(void *address, size_t *size,
|
||||
thread_id *thread);
|
||||
|
||||
status_t heap_debug_dump_allocations_on_exit(bool enabled);
|
||||
status_t heap_debug_set_stack_trace_depth(size_t stackTraceDepth);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -35,6 +35,7 @@ void _call_atexit_hooks_for_range(addr_t start, addr_t size);
|
||||
void __init_env(const struct user_space_program_args *args);
|
||||
status_t __init_heap(void);
|
||||
void __init_heap_post_env(void);
|
||||
void __heap_terminate_after(void);
|
||||
|
||||
void __init_time(addr_t commPageTable);
|
||||
void __arch_init_time(struct real_time_data *data, bool setDefaults);
|
||||
|
||||
Reference in New Issue
Block a user