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

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

Issue 1839503002: [tracing] Add native allocation tracing mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add type to StackFrame; format thread name Created 4 years, 8 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 tid_dumping_heap_ == PlatformThread::CurrentId()) 229 tid_dumping_heap_ == PlatformThread::CurrentId())
230 return; 230 return;
231 231
232 // AllocationContextTracker will return nullptr when called re-reentrantly. 232 // AllocationContextTracker will return nullptr when called re-reentrantly.
233 // This is the case of GetInstanceForCurrentThread() being called for the 233 // This is the case of GetInstanceForCurrentThread() being called for the
234 // first time, which causes a new() inside the tracker which re-enters the 234 // first time, which causes a new() inside the tracker which re-enters the
235 // heap profiler, in which case we just want to early out. 235 // heap profiler, in which case we just want to early out.
236 auto tracker = AllocationContextTracker::GetInstanceForCurrentThread(); 236 auto tracker = AllocationContextTracker::GetInstanceForCurrentThread();
237 if (!tracker) 237 if (!tracker)
238 return; 238 return;
239 AllocationContext context = tracker->GetContextSnapshot();
240 239
241 AutoLock lock(allocation_register_lock_); 240 AutoLock lock(allocation_register_lock_);
242 if (!allocation_register_) 241 if (!allocation_register_)
243 return; 242 return;
244 243
244 AllocationContext context = tracker->GetContextSnapshot();
Primiano Tucci (use gerrit) 2016/04/07 15:51:57 why moving this? The point of this being before th
245 allocation_register_->Insert(address, size, context); 245 allocation_register_->Insert(address, size, context);
246 } 246 }
247 247
248 void MallocDumpProvider::RemoveAllocation(void* address) { 248 void MallocDumpProvider::RemoveAllocation(void* address) {
249 // No re-entrancy is expected here as none of the calls below should 249 // No re-entrancy is expected here as none of the calls below should
250 // cause a free()-s (|allocation_register_| does its own heap management). 250 // cause a free()-s (|allocation_register_| does its own heap management).
251 if (tid_dumping_heap_ != kInvalidThreadId && 251 if (tid_dumping_heap_ != kInvalidThreadId &&
252 tid_dumping_heap_ == PlatformThread::CurrentId()) 252 tid_dumping_heap_ == PlatformThread::CurrentId())
253 return; 253 return;
254 AutoLock lock(allocation_register_lock_); 254 AutoLock lock(allocation_register_lock_);
255 if (!allocation_register_) 255 if (!allocation_register_)
256 return; 256 return;
257 allocation_register_->Remove(address); 257 allocation_register_->Remove(address);
258 } 258 }
259 259
260 } // namespace trace_event 260 } // namespace trace_event
261 } // namespace base 261 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698