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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc

Issue 1814083002: [tracing] Add thread name to the pseudo stack of heap profiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@profiler
Patch Set: rebase. Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
diff --git a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
index 2498fcd30c913463c3899e8b075481bd60148dbc..6349ec0c007e7b5317bcbe6417d8e62a3b5f0426 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
+++ b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
@@ -229,5 +229,27 @@ TEST_F(AllocationContextTrackerTest, BacktraceTakesTop) {
}
}
+TEST_F(AllocationContextTrackerTest, SetCurrentThreadName) {
+ TRACE_EVENT0("Testing", kCupcake);
+
+ // Test if the thread name is inserted into backtrace.
+ const char kThread1[] = "thread1";
+ AllocationContextTracker::SetCurrentThreadName(kThread1);
+ AllocationContext ctx1 =
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->GetContextSnapshot();
+ ASSERT_EQ(kThread1, ctx1.backtrace.frames[0]);
+ ASSERT_EQ(kCupcake, ctx1.backtrace.frames[1]);
+
+ // Test if the thread name is reset.
+ const char kThread2[] = "thread2";
+ AllocationContextTracker::SetCurrentThreadName(kThread2);
+ AllocationContext ctx2 =
+ AllocationContextTracker::GetInstanceForCurrentThread()
+ ->GetContextSnapshot();
+ ASSERT_EQ(kThread2, ctx2.backtrace.frames[0]);
+ ASSERT_EQ(kCupcake, ctx2.backtrace.frames[1]);
+}
+
} // namespace trace_event
} // namespace base

Powered by Google App Engine
This is Rietveld 408576698