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..19fa8ac313de4788794c4d914ce0a5f6cbeef023 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) { |
Primiano Tucci (use gerrit)
2016/03/25 02:14:30
after me cl lands this should be just sa call to t
ssid
2016/03/25 05:57:09
Yes i did not want this to be a member because i w
Primiano Tucci (use gerrit)
2016/03/25 15:27:55
Ahh ok makes sense. Although our code style [1] se
|
+ 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,10 @@ 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_) |
+ *src++ = thread_name_; |
Primiano Tucci (use gerrit)
2016/03/25 02:14:31
are you not clobbering the first valid stack entry
ssid
2016/03/25 05:57:09
Sorry I meant dst++ here!
Primiano Tucci (use gerrit)
2016/03/25 15:27:55
Ah right, that makes more sense :)
|
+ |
// Copy as much of the bottom of the pseudo stack into the backtrace as |
// possible. |
for (; src != src_end && dst != dst_end; src++, dst++) |