OLD | NEW |
1 /* Copyright (c) 2005, Google Inc. | 1 /* Copyright (c) 2005, Google Inc. |
2 * All rights reserved. | 2 * All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 # endif | 61 # endif |
62 #endif | 62 #endif |
63 | 63 |
64 /* All this code should be usable from within C apps. */ | 64 /* All this code should be usable from within C apps. */ |
65 #ifdef __cplusplus | 65 #ifdef __cplusplus |
66 extern "C" { | 66 extern "C" { |
67 #endif | 67 #endif |
68 | 68 |
69 /* Start profiling and arrange to write profile data to file names | 69 /* Start profiling and arrange to write profile data to file names |
70 * of the form: "prefix.0000", "prefix.0001", ... | 70 * of the form: "prefix.0000", "prefix.0001", ... |
| 71 * |
| 72 * If |prefix| is NULL then dumps will not be written to disk. Applications |
| 73 * can use GetHeapProfile() to get profile data, but HeapProfilerDump() will do |
| 74 * nothing. |
71 */ | 75 */ |
72 PERFTOOLS_DLL_DECL void HeapProfilerStart(const char* prefix); | 76 PERFTOOLS_DLL_DECL void HeapProfilerStart(const char* prefix); |
73 | 77 |
| 78 /* Start profiling with a callback function that returns application-generated |
| 79 * pseudo-stacks. Profiles are not written to disk, but may be obtained via |
| 80 * GetHeapProfile(). In the callback the caller must provide a |stack| buffer |
| 81 * of at least size 32 * sizeof(void*). The callback must return the number of |
| 82 * items copied or zero. |
| 83 */ |
| 84 typedef int (*PseudoStackGenerator)(void** stack); |
| 85 PERFTOOLS_DLL_DECL void HeapProfilerWithPseudoStackStart( |
| 86 PseudoStackGenerator callback); |
| 87 |
74 /* Returns non-zero if we are currently profiling the heap. (Returns | 88 /* Returns non-zero if we are currently profiling the heap. (Returns |
75 * an int rather than a bool so it's usable from C.) This is true | 89 * an int rather than a bool so it's usable from C.) This is true |
76 * between calls to HeapProfilerStart() and HeapProfilerStop(), and | 90 * between calls to HeapProfilerStart() and HeapProfilerStop(), and |
77 * also if the program has been run with HEAPPROFILER, or some other | 91 * also if the program has been run with HEAPPROFILER, or some other |
78 * way to turn on whole-program profiling. | 92 * way to turn on whole-program profiling. |
79 */ | 93 */ |
80 int IsHeapProfilerRunning(); | 94 int IsHeapProfilerRunning(); |
81 | 95 |
82 /* Stop heap profiling. Can be restarted again with HeapProfilerStart(), | 96 /* Stop heap profiling. Can be restarted again with HeapProfilerStart(), |
83 * but the currently accumulated profiling information will be cleared. | 97 * but the currently accumulated profiling information will be cleared. |
(...skipping 23 matching lines...) Expand all Loading... |
107 * callback will be invoked with the data argument and allocation pointer. | 121 * callback will be invoked with the data argument and allocation pointer. |
108 */ | 122 */ |
109 PERFTOOLS_DLL_DECL void IterateAllocatedObjects(AddressVisitor callback, | 123 PERFTOOLS_DLL_DECL void IterateAllocatedObjects(AddressVisitor callback, |
110 void* data); | 124 void* data); |
111 | 125 |
112 #ifdef __cplusplus | 126 #ifdef __cplusplus |
113 } // extern "C" | 127 } // extern "C" |
114 #endif | 128 #endif |
115 | 129 |
116 #endif /* BASE_HEAP_PROFILER_H_ */ | 130 #endif /* BASE_HEAP_PROFILER_H_ */ |
OLD | NEW |