Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #ifndef libmalloc_h___ |
michael@0 | 6 | #define libmalloc_h___ |
michael@0 | 7 | |
michael@0 | 8 | #include <sys/types.h> |
michael@0 | 9 | #include <malloc.h> |
michael@0 | 10 | |
michael@0 | 11 | #ifdef __cplusplus |
michael@0 | 12 | extern "C" { |
michael@0 | 13 | #endif |
michael@0 | 14 | |
michael@0 | 15 | #include "config.h" |
michael@0 | 16 | |
michael@0 | 17 | typedef unsigned long u_long; |
michael@0 | 18 | |
michael@0 | 19 | // For me->flags |
michael@0 | 20 | #define JP_FIRST_AFTER_PAUSE 1 |
michael@0 | 21 | |
michael@0 | 22 | // Format of a jprof log entry. This is what's written out to the |
michael@0 | 23 | // "jprof-log" file. |
michael@0 | 24 | // It's called malloc_log_entry because the history of jprof is that |
michael@0 | 25 | // it's a modified version of tracemalloc. |
michael@0 | 26 | struct malloc_log_entry { |
michael@0 | 27 | u_long delTime; |
michael@0 | 28 | u_long numpcs; |
michael@0 | 29 | unsigned int flags; |
michael@0 | 30 | int thread; |
michael@0 | 31 | char* pcs[MAX_STACK_CRAWL]; |
michael@0 | 32 | }; |
michael@0 | 33 | |
michael@0 | 34 | // type's |
michael@0 | 35 | #define malloc_log_stack 7 |
michael@0 | 36 | |
michael@0 | 37 | // Format of a malloc map entry; after this struct is nameLen+1 bytes of |
michael@0 | 38 | // name data. |
michael@0 | 39 | struct malloc_map_entry { |
michael@0 | 40 | u_long nameLen; |
michael@0 | 41 | u_long address; // base address |
michael@0 | 42 | }; |
michael@0 | 43 | |
michael@0 | 44 | // A method that can be called if you want to programmatically control |
michael@0 | 45 | // the malloc logging. Note that you must link with the library to do |
michael@0 | 46 | // this (or use dlsym after dynamically loading the library...) |
michael@0 | 47 | extern u_long SetMallocFlags(u_long flags); |
michael@0 | 48 | |
michael@0 | 49 | // The environment variable LIBMALLOC_LOG should be set to an integer |
michael@0 | 50 | // value whose meaning is as follows: |
michael@0 | 51 | |
michael@0 | 52 | // Enable logging |
michael@0 | 53 | #define LIBMALLOC_LOG 0x1 |
michael@0 | 54 | |
michael@0 | 55 | // Don't free memory when set |
michael@0 | 56 | #define LIBMALLOC_NOFREE 0x2 |
michael@0 | 57 | |
michael@0 | 58 | // Check heap for corruption after every malloc/free/realloc |
michael@0 | 59 | #define LIBMALLOC_CHECK 0x4 |
michael@0 | 60 | |
michael@0 | 61 | // Log reference count calls (addref/release) |
michael@0 | 62 | #define LIBMALLOC_LOG_RC 0x8 |
michael@0 | 63 | |
michael@0 | 64 | // Log a stack trace |
michael@0 | 65 | #define LIBMALLOC_LOG_TRACE 0x10 |
michael@0 | 66 | |
michael@0 | 67 | void __log_addref(void* p, int oldrc, int newrc); |
michael@0 | 68 | void __log_release(void* p, int oldrc, int newrc); |
michael@0 | 69 | |
michael@0 | 70 | #ifdef __cplusplus |
michael@0 | 71 | } /* end of extern "C" */ |
michael@0 | 72 | #endif |
michael@0 | 73 | |
michael@0 | 74 | #endif /* libmalloc_h___ */ |