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

Unified Diff: base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc

Issue 1907593002: Revert of [tracing] Turn StackFrame into struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 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 a39700e4fff4171d6701883d83d6a8ef98a85cdd..05c60c722c317cca7bf6e52453a5faba1d7b1903 100644
--- a/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
+++ b/base/trace_event/heap_profiler_allocation_context_tracker_unittest.cc
@@ -33,7 +33,7 @@
->GetContextSnapshot();
auto actual = std::begin(ctx.backtrace.frames);
- auto actual_bottom = actual + ctx.backtrace.frame_count;
+ auto actual_bottom = std::end(ctx.backtrace.frames);
auto expected = std::begin(expected_backtrace);
auto expected_bottom = std::end(expected_backtrace);
@@ -53,7 +53,8 @@
AllocationContextTracker::GetInstanceForCurrentThread()
->GetContextSnapshot();
- ASSERT_EQ(0u, ctx.backtrace.frame_count);
+ for (StackFrame frame : ctx.backtrace.frames)
+ ASSERT_EQ(nullptr, frame);
}
class AllocationContextTrackerTest : public testing::Test {
@@ -71,22 +72,24 @@
};
// Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly.
+// Also check that |GetContextSnapshot| fills the backtrace with null pointers
+// when the pseudo stack height is less than the capacity.
TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) {
- StackFrame c = StackFrame::FromTraceEventName(kCupcake);
- StackFrame d = StackFrame::FromTraceEventName(kDonut);
- StackFrame e = StackFrame::FromTraceEventName(kEclair);
- StackFrame f = StackFrame::FromTraceEventName(kFroyo);
+ StackFrame c = kCupcake;
+ StackFrame d = kDonut;
+ StackFrame e = kEclair;
+ StackFrame f = kFroyo;
AssertBacktraceEmpty();
{
TRACE_EVENT0("Testing", kCupcake);
- StackFrame frame_c[] = {c};
+ StackFrame frame_c[] = {c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
AssertBacktraceEquals(frame_c);
{
TRACE_EVENT0("Testing", kDonut);
- StackFrame frame_cd[] = {c, d};
+ StackFrame frame_cd[] = {c, d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
AssertBacktraceEquals(frame_cd);
}
@@ -94,7 +97,7 @@
{
TRACE_EVENT0("Testing", kEclair);
- StackFrame frame_ce[] = {c, e};
+ StackFrame frame_ce[] = {c, e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
AssertBacktraceEquals(frame_ce);
}
@@ -105,7 +108,7 @@
{
TRACE_EVENT0("Testing", kFroyo);
- StackFrame frame_f[] = {f};
+ StackFrame frame_f[] = {f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
AssertBacktraceEquals(frame_f);
}
@@ -115,15 +118,15 @@
// Same as |PseudoStackScopedTrace|, but now test the |TRACE_EVENT_BEGIN| and
// |TRACE_EVENT_END| macros.
TEST_F(AllocationContextTrackerTest, PseudoStackBeginEndTrace) {
- StackFrame c = StackFrame::FromTraceEventName(kCupcake);
- StackFrame d = StackFrame::FromTraceEventName(kDonut);
- StackFrame e = StackFrame::FromTraceEventName(kEclair);
- StackFrame f = StackFrame::FromTraceEventName(kFroyo);
-
- StackFrame frame_c[] = {c};
- StackFrame frame_cd[] = {c, d};
- StackFrame frame_ce[] = {c, e};
- StackFrame frame_f[] = {f};
+ StackFrame c = kCupcake;
+ StackFrame d = kDonut;
+ StackFrame e = kEclair;
+ StackFrame f = kFroyo;
+
+ StackFrame frame_c[] = {c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ StackFrame frame_cd[] = {c, d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ StackFrame frame_ce[] = {c, e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ StackFrame frame_f[] = {f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
AssertBacktraceEmpty();
@@ -153,15 +156,15 @@
}
TEST_F(AllocationContextTrackerTest, PseudoStackMixedTrace) {
- StackFrame c = StackFrame::FromTraceEventName(kCupcake);
- StackFrame d = StackFrame::FromTraceEventName(kDonut);
- StackFrame e = StackFrame::FromTraceEventName(kEclair);
- StackFrame f = StackFrame::FromTraceEventName(kFroyo);
-
- StackFrame frame_c[] = {c};
- StackFrame frame_cd[] = {c, d};
- StackFrame frame_e[] = {e};
- StackFrame frame_ef[] = {e, f};
+ StackFrame c = kCupcake;
+ StackFrame d = kDonut;
+ StackFrame e = kEclair;
+ StackFrame f = kFroyo;
+
+ StackFrame frame_c[] = {c, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ StackFrame frame_cd[] = {c, d, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ StackFrame frame_e[] = {e, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ StackFrame frame_ef[] = {e, f, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
AssertBacktraceEmpty();
@@ -191,9 +194,6 @@
}
TEST_F(AllocationContextTrackerTest, BacktraceTakesTop) {
- StackFrame c = StackFrame::FromTraceEventName(kCupcake);
- StackFrame f = StackFrame::FromTraceEventName(kFroyo);
-
// Push 12 events onto the pseudo stack.
TRACE_EVENT0("Testing", kCupcake);
TRACE_EVENT0("Testing", kCupcake);
@@ -217,16 +217,16 @@
->GetContextSnapshot();
// The pseudo stack relies on pointer equality, not deep string comparisons.
- ASSERT_EQ(c, ctx.backtrace.frames[0]);
- ASSERT_EQ(f, ctx.backtrace.frames[11]);
+ ASSERT_EQ(kCupcake, ctx.backtrace.frames[0]);
+ ASSERT_EQ(kFroyo, ctx.backtrace.frames[11]);
}
{
AllocationContext ctx =
AllocationContextTracker::GetInstanceForCurrentThread()
->GetContextSnapshot();
- ASSERT_EQ(c, ctx.backtrace.frames[0]);
- ASSERT_EQ(f, ctx.backtrace.frames[11]);
+ ASSERT_EQ(kCupcake, ctx.backtrace.frames[0]);
+ ASSERT_EQ(kFroyo, ctx.backtrace.frames[11]);
}
}
@@ -239,8 +239,8 @@
AllocationContext ctx1 =
AllocationContextTracker::GetInstanceForCurrentThread()
->GetContextSnapshot();
- ASSERT_EQ(StackFrame::FromThreadName(kThread1), ctx1.backtrace.frames[0]);
- ASSERT_EQ(StackFrame::FromTraceEventName(kCupcake), ctx1.backtrace.frames[1]);
+ 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";
@@ -248,8 +248,8 @@
AllocationContext ctx2 =
AllocationContextTracker::GetInstanceForCurrentThread()
->GetContextSnapshot();
- ASSERT_EQ(StackFrame::FromThreadName(kThread2), ctx2.backtrace.frames[0]);
- ASSERT_EQ(StackFrame::FromTraceEventName(kCupcake), ctx2.backtrace.frames[1]);
+ ASSERT_EQ(kThread2, ctx2.backtrace.frames[0]);
+ ASSERT_EQ(kCupcake, ctx2.backtrace.frames[1]);
}
TEST_F(AllocationContextTrackerTest, TrackTaskContext) {

Powered by Google App Engine
This is Rietveld 408576698