michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef libmalloc_h___ michael@0: #define libmalloc_h___ michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #ifdef __cplusplus michael@0: extern "C" { michael@0: #endif michael@0: michael@0: #include "config.h" michael@0: michael@0: typedef unsigned long u_long; michael@0: michael@0: // For me->flags michael@0: #define JP_FIRST_AFTER_PAUSE 1 michael@0: michael@0: // Format of a jprof log entry. This is what's written out to the michael@0: // "jprof-log" file. michael@0: // It's called malloc_log_entry because the history of jprof is that michael@0: // it's a modified version of tracemalloc. michael@0: struct malloc_log_entry { michael@0: u_long delTime; michael@0: u_long numpcs; michael@0: unsigned int flags; michael@0: int thread; michael@0: char* pcs[MAX_STACK_CRAWL]; michael@0: }; michael@0: michael@0: // type's michael@0: #define malloc_log_stack 7 michael@0: michael@0: // Format of a malloc map entry; after this struct is nameLen+1 bytes of michael@0: // name data. michael@0: struct malloc_map_entry { michael@0: u_long nameLen; michael@0: u_long address; // base address michael@0: }; michael@0: michael@0: // A method that can be called if you want to programmatically control michael@0: // the malloc logging. Note that you must link with the library to do michael@0: // this (or use dlsym after dynamically loading the library...) michael@0: extern u_long SetMallocFlags(u_long flags); michael@0: michael@0: // The environment variable LIBMALLOC_LOG should be set to an integer michael@0: // value whose meaning is as follows: michael@0: michael@0: // Enable logging michael@0: #define LIBMALLOC_LOG 0x1 michael@0: michael@0: // Don't free memory when set michael@0: #define LIBMALLOC_NOFREE 0x2 michael@0: michael@0: // Check heap for corruption after every malloc/free/realloc michael@0: #define LIBMALLOC_CHECK 0x4 michael@0: michael@0: // Log reference count calls (addref/release) michael@0: #define LIBMALLOC_LOG_RC 0x8 michael@0: michael@0: // Log a stack trace michael@0: #define LIBMALLOC_LOG_TRACE 0x10 michael@0: michael@0: void __log_addref(void* p, int oldrc, int newrc); michael@0: void __log_release(void* p, int oldrc, int newrc); michael@0: michael@0: #ifdef __cplusplus michael@0: } /* end of extern "C" */ michael@0: #endif michael@0: michael@0: #endif /* libmalloc_h___ */