Index: third_party/tcmalloc/chromium/src/gperftools/heap-checker.h |
diff --git a/third_party/tcmalloc/chromium/src/google/heap-checker.h b/third_party/tcmalloc/chromium/src/gperftools/heap-checker.h |
similarity index 95% |
copy from third_party/tcmalloc/chromium/src/google/heap-checker.h |
copy to third_party/tcmalloc/chromium/src/gperftools/heap-checker.h |
index f46f353a822e55326c789dff5b0f04d92541314b..32ed10a823238f5ac3665c7189b0b42e0d82dc29 100644 |
--- a/third_party/tcmalloc/chromium/src/google/heap-checker.h |
+++ b/third_party/tcmalloc/chromium/src/gperftools/heap-checker.h |
@@ -181,17 +181,22 @@ class PERFTOOLS_DLL_DECL HeapLeakChecker { |
}; |
// Ignore an object located at 'ptr' (can go at the start or into the object) |
- // as well as all heap objects (transitively) referenced from it |
- // for the purposes of heap leak checking. |
- // If 'ptr' does not point to an active allocated object |
- // at the time of this call, it is ignored; |
- // but if it does, the object must not get deleted from the heap later on; |
- // it must also be not already ignored at the time of this call. |
+ // as well as all heap objects (transitively) referenced from it for the |
+ // purposes of heap leak checking. Returns 'ptr' so that one can write |
+ // static T* obj = IgnoreObject(new T(...)); |
+ // |
+ // If 'ptr' does not point to an active allocated object at the time of this |
+ // call, it is ignored; but if it does, the object must not get deleted from |
+ // the heap later on. |
// |
// See also HiddenPointer, below, if you need to prevent a pointer from |
// being traversed by the heap checker but do not wish to transitively |
// whitelist objects referenced through it. |
- static void IgnoreObject(const void* ptr); |
+ template <typename T> |
+ static T* IgnoreObject(T* ptr) { |
+ DoIgnoreObject(static_cast<const void*>(const_cast<const T*>(ptr))); |
+ return ptr; |
+ } |
// Undo what an earlier IgnoreObject() call promised and asked to do. |
// At the time of this call 'ptr' must point at or inside of an active |
@@ -199,12 +204,6 @@ class PERFTOOLS_DLL_DECL HeapLeakChecker { |
static void UnIgnoreObject(const void* ptr); |
// ----------------------------------------------------------------------- // |
- // Initialization; to be called from main() only. |
- |
- // Full starting of recommended whole-program checking. |
- static void InternalInitStart(); |
- |
- // ----------------------------------------------------------------------- // |
// Internal types defined in .cc |
class Allocator; |
@@ -227,6 +226,9 @@ class PERFTOOLS_DLL_DECL HeapLeakChecker { |
// Helper for *NoLeaks and *SameHeap |
bool DoNoLeaks(ShouldSymbolize should_symbolize); |
+ // Helper for NoGlobalLeaks, also called by the global destructor. |
+ static bool NoGlobalLeaksMaybeSymbolize(ShouldSymbolize should_symbolize); |
+ |
// These used to be public, but they are now deprecated. |
// Will remove entirely when all internal uses are fixed. |
// In the meantime, use friendship so the unittest can still test them. |
@@ -237,11 +239,12 @@ class PERFTOOLS_DLL_DECL HeapLeakChecker { |
friend void NamedTwoDisabledLeaks(); |
friend void* RunNamedDisabledLeaks(void*); |
friend void TestHeapLeakCheckerNamedDisabling(); |
+ // TODO(csilvers): remove this one, at least |
friend int main(int, char**); |
- // Helper for DisableChecksIn |
- static void DisableChecksInLocked(const char* pattern); |
+ // Actually implements IgnoreObject(). |
+ static void DoIgnoreObject(const void* ptr); |
// Disable checks based on stack trace entry at a depth <= |
// max_depth. Used to hide allocations done inside some special |
@@ -286,10 +289,6 @@ class PERFTOOLS_DLL_DECL HeapLeakChecker { |
// are being used. |
static void IgnoreLiveObjectsLocked(const char* name, const char* name2); |
- // Runs REGISTER_HEAPCHECK_CLEANUP cleanups and potentially |
- // calls DoMainHeapCheck |
- static void RunHeapCleanups(); |
- |
// Do the overall whole-program heap leak check if needed; |
// returns true when did the leak check. |
static bool DoMainHeapCheck(); |
@@ -348,6 +347,13 @@ class PERFTOOLS_DLL_DECL HeapLeakChecker { |
// This gets to execute after destructors for all global objects |
friend void HeapLeakChecker_AfterDestructors(); |
+ // Full starting of recommended whole-program checking. |
+ friend void HeapLeakChecker_InternalInitStart(); |
+ |
+ // Runs REGISTER_HEAPCHECK_CLEANUP cleanups and potentially |
+ // calls DoMainHeapCheck |
+ friend void HeapLeakChecker_RunHeapCleanups(); |
+ |
// ----------------------------------------------------------------------- // |
// Member data. |