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 2185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 "BeforeConstructorsLocked called multiple times"); | 2196 "BeforeConstructorsLocked called multiple times"); |
2197 #ifdef ADDRESS_SANITIZER | 2197 #ifdef ADDRESS_SANITIZER |
2198 // AddressSanitizer's custom malloc conflicts with HeapChecker. | 2198 // AddressSanitizer's custom malloc conflicts with HeapChecker. |
2199 return; | 2199 return; |
2200 #endif | 2200 #endif |
2201 // Set hooks early to crash if 'new' gets called before we make heap_profile, | 2201 // Set hooks early to crash if 'new' gets called before we make heap_profile, |
2202 // and make sure no other hooks existed: | 2202 // and make sure no other hooks existed: |
2203 RAW_CHECK(MallocHook::AddNewHook(&NewHook), ""); | 2203 RAW_CHECK(MallocHook::AddNewHook(&NewHook), ""); |
2204 RAW_CHECK(MallocHook::AddDeleteHook(&DeleteHook), ""); | 2204 RAW_CHECK(MallocHook::AddDeleteHook(&DeleteHook), ""); |
2205 constructor_heap_profiling = true; | 2205 constructor_heap_profiling = true; |
2206 MemoryRegionMap::Init(1); | 2206 MemoryRegionMap::Init(1, /* use_buckets */ false); |
2207 // Set up MemoryRegionMap with (at least) one caller stack frame to record | 2207 // Set up MemoryRegionMap with (at least) one caller stack frame to record |
2208 // (important that it's done before HeapProfileTable creation below). | 2208 // (important that it's done before HeapProfileTable creation below). |
2209 Allocator::Init(); | 2209 Allocator::Init(); |
2210 RAW_CHECK(heap_profile == NULL, ""); | 2210 RAW_CHECK(heap_profile == NULL, ""); |
2211 heap_profile = new(Allocator::Allocate(sizeof(HeapProfileTable))) | 2211 heap_profile = new(Allocator::Allocate(sizeof(HeapProfileTable))) |
2212 HeapProfileTable(&Allocator::Allocate, &Allocator::Free); | 2212 HeapProfileTable(&Allocator::Allocate, &Allocator::Free); |
2213 RAW_VLOG(10, "Starting tracking the heap"); | 2213 RAW_VLOG(10, "Starting tracking the heap"); |
2214 heap_checker_on = true; | 2214 heap_checker_on = true; |
2215 } | 2215 } |
2216 | 2216 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2368 // static | 2368 // static |
2369 const void* HeapLeakChecker::GetAllocCaller(void* ptr) { | 2369 const void* HeapLeakChecker::GetAllocCaller(void* ptr) { |
2370 // this is used only in the unittest, so the heavy checks are fine | 2370 // this is used only in the unittest, so the heavy checks are fine |
2371 HeapProfileTable::AllocInfo info; | 2371 HeapProfileTable::AllocInfo info; |
2372 { SpinLockHolder l(&heap_checker_lock); | 2372 { SpinLockHolder l(&heap_checker_lock); |
2373 RAW_CHECK(heap_profile->FindAllocDetails(ptr, &info), ""); | 2373 RAW_CHECK(heap_profile->FindAllocDetails(ptr, &info), ""); |
2374 } | 2374 } |
2375 RAW_CHECK(info.stack_depth >= 1, ""); | 2375 RAW_CHECK(info.stack_depth >= 1, ""); |
2376 return info.call_stack[0]; | 2376 return info.call_stack[0]; |
2377 } | 2377 } |
OLD | NEW |