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 2115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2126 int flags, | 2126 int flags, |
2127 int fd, | 2127 int fd, |
2128 off_t offset) { | 2128 off_t offset) { |
2129 InitHeapLeakCheckerFromMallocHook(); | 2129 InitHeapLeakCheckerFromMallocHook(); |
2130 // record this first mmap as well (if we need to): | 2130 // record this first mmap as well (if we need to): |
2131 MallocHook::InvokeMmapHook( | 2131 MallocHook::InvokeMmapHook( |
2132 result, start, size, protection, flags, fd, offset); | 2132 result, start, size, protection, flags, fd, offset); |
2133 } | 2133 } |
2134 | 2134 |
2135 // Important to have this to catch the first sbrk call (say from tcmalloc): | 2135 // Important to have this to catch the first sbrk call (say from tcmalloc): |
2136 extern void InitialMallocHook_Sbrk(const void* result, ptrdiff_t increment) { | 2136 extern void InitialMallocHook_Sbrk(const void* result, std::ptrdiff_t increment)
{ |
2137 InitHeapLeakCheckerFromMallocHook(); | 2137 InitHeapLeakCheckerFromMallocHook(); |
2138 // record this first sbrk as well (if we need to): | 2138 // record this first sbrk as well (if we need to): |
2139 MallocHook::InvokeSbrkHook(result, increment); | 2139 MallocHook::InvokeSbrkHook(result, increment); |
2140 } | 2140 } |
2141 | 2141 |
2142 // static | 2142 // static |
2143 void CancelInitialMallocHooks() { | 2143 void CancelInitialMallocHooks() { |
2144 if (MallocHook::GetNewHook() == InitialMallocHook_New) { | 2144 if (MallocHook::GetNewHook() == InitialMallocHook_New) { |
2145 MallocHook::SetNewHook(NULL); | 2145 MallocHook::SetNewHook(NULL); |
2146 } | 2146 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 // static | 2381 // static |
2382 const void* HeapLeakChecker::GetAllocCaller(void* ptr) { | 2382 const void* HeapLeakChecker::GetAllocCaller(void* ptr) { |
2383 // this is used only in the unittest, so the heavy checks are fine | 2383 // this is used only in the unittest, so the heavy checks are fine |
2384 HeapProfileTable::AllocInfo info; | 2384 HeapProfileTable::AllocInfo info; |
2385 { SpinLockHolder l(&heap_checker_lock); | 2385 { SpinLockHolder l(&heap_checker_lock); |
2386 RAW_CHECK(heap_profile->FindAllocDetails(ptr, &info), ""); | 2386 RAW_CHECK(heap_profile->FindAllocDetails(ptr, &info), ""); |
2387 } | 2387 } |
2388 RAW_CHECK(info.stack_depth >= 1, ""); | 2388 RAW_CHECK(info.stack_depth >= 1, ""); |
2389 return info.call_stack[0]; | 2389 return info.call_stack[0]; |
2390 } | 2390 } |
OLD | NEW |