diff options
Diffstat (limited to 'libc/private/bionic_malloc.h')
-rw-r--r-- | libc/private/bionic_malloc.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libc/private/bionic_malloc.h b/libc/private/bionic_malloc.h index e8a6f6ef5..9c602eadf 100644 --- a/libc/private/bionic_malloc.h +++ b/libc/private/bionic_malloc.h @@ -30,6 +30,22 @@ #include <stdbool.h> +// Structures for android_mallopt. + +typedef struct { + // Pointer to the buffer allocated by a call to M_GET_MALLOC_LEAK_INFO. + uint8_t* buffer; + // The size of the "info" buffer. + size_t overall_size; + // The size of a single entry. + size_t info_size; + // The sum of all allocations that have been tracked. Does not include + // any heap overhead. + size_t total_memory; + // The maximum number of backtrace entries. + size_t backtrace_size; +} android_mallopt_leak_info_t; + // Opcodes for android_mallopt. enum { @@ -48,6 +64,26 @@ enum { // Called after the zygote forks to indicate this is a child. M_SET_ZYGOTE_CHILD = 4, #define M_SET_ZYGOTE_CHILD M_SET_ZYGOTE_CHILD + + // Options to dump backtraces of allocations. These options only + // work when malloc debug has been enabled. + + // Writes the backtrace information of all current allocations to a file. + // NOTE: arg_size has to be sizeof(FILE*) because FILE is an opaque type. + // arg = FILE* + // arg_size = sizeof(FILE*) + M_WRITE_MALLOC_LEAK_INFO_TO_FILE = 5, +#define M_WRITE_MALLOC_LEAK_INFO_TO_FILE M_WRITE_MALLOC_LEAK_INFO_TO_FILE + // Get information about the backtraces of all + // arg = android_mallopt_leak_info_t* + // arg_size = sizeof(android_mallopt_leak_info_t) + M_GET_MALLOC_LEAK_INFO = 6, +#define M_GET_MALLOC_LEAK_INFO M_GET_MALLOC_LEAK_INFO + // Free the memory allocated and returned by M_GET_MALLOC_LEAK_INFO. + // arg = android_mallopt_leak_info_t* + // arg_size = sizeof(android_mallopt_leak_info_t) + M_FREE_MALLOC_LEAK_INFO = 7, +#define M_FREE_MALLOC_LEAK_INFO M_FREE_MALLOC_LEAK_INFO }; // Manipulates bionic-specific handling of memory allocation APIs such as |