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 * stacks. Profiles are not written to disk, but may be obtained via |
| 80 * GetHeapProfile(). The callback: |
| 81 * 1. May optionally skip the first |skip_count| items on the stack. |
| 82 * 2. Must provide a |stack| buffer of at least size 32 * sizeof(void*). |
| 83 * 3. Must return the number of items copied or zero. |
| 84 */ |
| 85 typedef int (*StackGeneratorFunction)(int skip_count, void** stack); |
| 86 PERFTOOLS_DLL_DECL void HeapProfilerWithPseudoStackStart( |
| 87 StackGeneratorFunction callback); |
| 88 |
74 /* Returns non-zero if we are currently profiling the heap. (Returns | 89 /* 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 | 90 * an int rather than a bool so it's usable from C.) This is true |
76 * between calls to HeapProfilerStart() and HeapProfilerStop(), and | 91 * between calls to HeapProfilerStart() and HeapProfilerStop(), and |
77 * also if the program has been run with HEAPPROFILER, or some other | 92 * also if the program has been run with HEAPPROFILER, or some other |
78 * way to turn on whole-program profiling. | 93 * way to turn on whole-program profiling. |
79 */ | 94 */ |
80 int IsHeapProfilerRunning(); | 95 int IsHeapProfilerRunning(); |
81 | 96 |
82 /* Stop heap profiling. Can be restarted again with HeapProfilerStart(), | 97 /* Stop heap profiling. Can be restarted again with HeapProfilerStart(), |
83 * but the currently accumulated profiling information will be cleared. | 98 * 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. | 122 * callback will be invoked with the data argument and allocation pointer. |
108 */ | 123 */ |
109 PERFTOOLS_DLL_DECL void IterateAllocatedObjects(AddressVisitor callback, | 124 PERFTOOLS_DLL_DECL void IterateAllocatedObjects(AddressVisitor callback, |
110 void* data); | 125 void* data); |
111 | 126 |
112 #ifdef __cplusplus | 127 #ifdef __cplusplus |
113 } // extern "C" | 128 } // extern "C" |
114 #endif | 129 #endif |
115 | 130 |
116 #endif /* BASE_HEAP_PROFILER_H_ */ | 131 #endif /* BASE_HEAP_PROFILER_H_ */ |
OLD | NEW |