Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: base/trace_event/malloc_dump_provider.cc

Issue 2637783002: [tracing] Don't register tracing-related allocations. (Closed)
Patch Set: Fix unittest Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/trace_event/malloc_dump_provider.h" 5 #include "base/trace_event/malloc_dump_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/allocator/allocator_extension.h" 9 #include "base/allocator/allocator_extension.h"
10 #include "base/allocator/allocator_shim.h" 10 #include "base/allocator/allocator_shim.h"
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 tid_dumping_heap_ == PlatformThread::CurrentId()) 290 tid_dumping_heap_ == PlatformThread::CurrentId())
291 return; 291 return;
292 292
293 // AllocationContextTracker will return nullptr when called re-reentrantly. 293 // AllocationContextTracker will return nullptr when called re-reentrantly.
294 // This is the case of GetInstanceForCurrentThread() being called for the 294 // This is the case of GetInstanceForCurrentThread() being called for the
295 // first time, which causes a new() inside the tracker which re-enters the 295 // first time, which causes a new() inside the tracker which re-enters the
296 // heap profiler, in which case we just want to early out. 296 // heap profiler, in which case we just want to early out.
297 auto* tracker = AllocationContextTracker::GetInstanceForCurrentThread(); 297 auto* tracker = AllocationContextTracker::GetInstanceForCurrentThread();
298 if (!tracker) 298 if (!tracker)
299 return; 299 return;
300 AllocationContext context = tracker->GetContextSnapshot(); 300
301 AllocationContext context;
302 if (!tracker->GetContextSnapshot(&context))
303 return;
301 304
302 AutoLock lock(allocation_register_lock_); 305 AutoLock lock(allocation_register_lock_);
303 if (!allocation_register_) 306 if (!allocation_register_)
304 return; 307 return;
305 308
306 allocation_register_->Insert(address, size, context); 309 allocation_register_->Insert(address, size, context);
307 } 310 }
308 311
309 void MallocDumpProvider::RemoveAllocation(void* address) { 312 void MallocDumpProvider::RemoveAllocation(void* address) {
310 // No re-entrancy is expected here as none of the calls below should 313 // No re-entrancy is expected here as none of the calls below should
311 // cause a free()-s (|allocation_register_| does its own heap management). 314 // cause a free()-s (|allocation_register_| does its own heap management).
312 if (tid_dumping_heap_ != kInvalidThreadId && 315 if (tid_dumping_heap_ != kInvalidThreadId &&
313 tid_dumping_heap_ == PlatformThread::CurrentId()) 316 tid_dumping_heap_ == PlatformThread::CurrentId())
314 return; 317 return;
315 AutoLock lock(allocation_register_lock_); 318 AutoLock lock(allocation_register_lock_);
316 if (!allocation_register_) 319 if (!allocation_register_)
317 return; 320 return;
318 allocation_register_->Remove(address); 321 allocation_register_->Remove(address);
319 } 322 }
320 323
321 } // namespace trace_event 324 } // namespace trace_event
322 } // namespace base 325 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698