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