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

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

Issue 1839503002: [tracing] Add native allocation tracing mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Increase Backtrace frames, request even more frames 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <iterator> 7 #include <iterator>
8 8
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/pending_task.h" 10 #include "base/pending_task.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 ->GetContextSnapshot(); 55 ->GetContextSnapshot();
56 56
57 ASSERT_EQ(0u, ctx.backtrace.frame_count); 57 ASSERT_EQ(0u, ctx.backtrace.frame_count);
58 } 58 }
59 59
60 class AllocationContextTrackerTest : public testing::Test { 60 class AllocationContextTrackerTest : public testing::Test {
61 public: 61 public:
62 void SetUp() override { 62 void SetUp() override {
63 TraceConfig config(""); 63 TraceConfig config("");
64 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); 64 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE);
65 AllocationContextTracker::SetCaptureEnabled(true); 65 AllocationContextTracker::SetCaptureMode(
66 AllocationContextTracker::CaptureMode::PSEUDO_STACK);
66 } 67 }
67 68
68 void TearDown() override { 69 void TearDown() override {
69 AllocationContextTracker::SetCaptureEnabled(false); 70 AllocationContextTracker::SetCaptureMode(
71 AllocationContextTracker::CaptureMode::DISABLED);
70 TraceLog::GetInstance()->SetDisabled(); 72 TraceLog::GetInstance()->SetDisabled();
71 } 73 }
72 }; 74 };
73 75
74 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly. 76 // Check that |TRACE_EVENT| macros push and pop to the pseudo stack correctly.
75 TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) { 77 TEST_F(AllocationContextTrackerTest, PseudoStackScopedTrace) {
76 StackFrame c = StackFrame::FromTraceEventName(kCupcake); 78 StackFrame c = StackFrame::FromTraceEventName(kCupcake);
77 StackFrame d = StackFrame::FromTraceEventName(kDonut); 79 StackFrame d = StackFrame::FromTraceEventName(kDonut);
78 StackFrame e = StackFrame::FromTraceEventName(kEclair); 80 StackFrame e = StackFrame::FromTraceEventName(kEclair);
79 StackFrame f = StackFrame::FromTraceEventName(kFroyo); 81 StackFrame f = StackFrame::FromTraceEventName(kFroyo);
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
287 AllocationContextTracker::GetInstanceForCurrentThread() 289 AllocationContextTracker::GetInstanceForCurrentThread()
288 ->GetContextSnapshot(); 290 ->GetContextSnapshot();
289 const StringPiece kTracingOverhead("tracing_overhead"); 291 const StringPiece kTracingOverhead("tracing_overhead");
290 ASSERT_EQ(kTracingOverhead, 292 ASSERT_EQ(kTracingOverhead,
291 static_cast<const char*>(ctx.backtrace.frames[0].value)); 293 static_cast<const char*>(ctx.backtrace.frames[0].value));
292 ASSERT_EQ(1u, ctx.backtrace.frame_count); 294 ASSERT_EQ(1u, ctx.backtrace.frame_count);
293 } 295 }
294 296
295 } // namespace trace_event 297 } // namespace trace_event
296 } // namespace base 298 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698