| Index: base/trace_event/heap_profiler_allocation_context_tracker.cc
|
| diff --git a/base/trace_event/heap_profiler_allocation_context_tracker.cc b/base/trace_event/heap_profiler_allocation_context_tracker.cc
|
| index 2877d2af91b27ace28839ebaac7468322cf4823f..2dfe79fb34af0985b835709661a315a56a355b52 100644
|
| --- a/base/trace_event/heap_profiler_allocation_context_tracker.cc
|
| +++ b/base/trace_event/heap_profiler_allocation_context_tracker.cc
|
| @@ -49,12 +49,19 @@ AllocationContextTracker::GetInstanceForCurrentThread() {
|
| return tracker;
|
| }
|
|
|
| -AllocationContextTracker::AllocationContextTracker() {
|
| +AllocationContextTracker::AllocationContextTracker() : thread_name_(nullptr) {
|
| pseudo_stack_.reserve(kMaxStackDepth);
|
| }
|
| AllocationContextTracker::~AllocationContextTracker() {}
|
|
|
| // static
|
| +void AllocationContextTracker::SetCurrentThreadName(const char* name) {
|
| + if (name && capture_enabled()) {
|
| + GetInstanceForCurrentThread()->thread_name_ = name;
|
| + }
|
| +}
|
| +
|
| +// static
|
| void AllocationContextTracker::SetCaptureEnabled(bool enabled) {
|
| // When enabling capturing, also initialize the TLS slot. This does not create
|
| // a TLS instance yet.
|
| @@ -103,6 +110,13 @@ AllocationContext AllocationContextTracker::GetContextSnapshot() {
|
| auto src_end = pseudo_stack_.end();
|
| auto dst_end = std::end(ctx.backtrace.frames);
|
|
|
| + // Add the thread name as the first enrty in the backtrace.
|
| + if (thread_name_) {
|
| + DCHECK(dst < dst_end);
|
| + *dst = thread_name_;
|
| + ++dst;
|
| + }
|
| +
|
| // Copy as much of the bottom of the pseudo stack into the backtrace as
|
| // possible.
|
| for (; src != src_end && dst != dst_end; src++, dst++)
|
|
|