|
1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
|
2 * |
|
3 * This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 /* declarations needed by both nsTraceMalloc.c and nsWinTraceMalloc.cpp */ |
|
8 |
|
9 #ifndef NSTRACEMALLOCCALLBACKS_H |
|
10 #define NSTRACEMALLOCCALLBACKS_H |
|
11 |
|
12 #include <stdint.h> |
|
13 #include <stdlib.h> |
|
14 |
|
15 #ifdef __cplusplus |
|
16 extern "C" { |
|
17 #endif |
|
18 |
|
19 /* Used by backtrace. */ |
|
20 typedef struct stack_buffer_info { |
|
21 void **buffer; |
|
22 size_t size; |
|
23 size_t entries; |
|
24 } stack_buffer_info; |
|
25 |
|
26 typedef struct tm_thread tm_thread; |
|
27 struct tm_thread { |
|
28 /* |
|
29 * This counter suppresses tracing, in case any tracing code needs |
|
30 * to malloc. |
|
31 */ |
|
32 uint32_t suppress_tracing; |
|
33 |
|
34 /* buffer for backtrace, below */ |
|
35 stack_buffer_info backtrace_buf; |
|
36 }; |
|
37 |
|
38 /* implemented in nsTraceMalloc.c */ |
|
39 tm_thread * tm_get_thread(void); |
|
40 |
|
41 /* implemented in nsTraceMalloc.c */ |
|
42 PR_EXTERN(void) MallocCallback(void *aPtr, size_t aSize, uint32_t start, uint32_t end, tm_thread *t); |
|
43 PR_EXTERN(void) CallocCallback(void *aPtr, size_t aCount, size_t aSize, uint32_t start, uint32_t end, tm_thread *t); |
|
44 PR_EXTERN(void) ReallocCallback(void *aPin, void* aPout, size_t aSize, uint32_t start, uint32_t end, tm_thread *t); |
|
45 PR_EXTERN(void) FreeCallback(void *aPtr, uint32_t start, uint32_t end, tm_thread *t); |
|
46 |
|
47 #ifdef XP_WIN32 |
|
48 /* implemented in nsTraceMalloc.c */ |
|
49 PR_EXTERN(void) StartupHooker(); |
|
50 PR_EXTERN(void) ShutdownHooker(); |
|
51 |
|
52 /* implemented in nsWinTraceMalloc.cpp */ |
|
53 void* dhw_orig_malloc(size_t); |
|
54 void* dhw_orig_calloc(size_t, size_t); |
|
55 void* dhw_orig_realloc(void*, size_t); |
|
56 void dhw_orig_free(void*); |
|
57 |
|
58 #endif /* defined(XP_WIN32) */ |
|
59 |
|
60 #ifdef __cplusplus |
|
61 } |
|
62 #endif |
|
63 |
|
64 #endif /* !defined(NSTRACEMALLOCCALLBACKS_H) */ |