OLD | NEW |
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 AllocationContextTracker::GetInstanceForCurrentThread() | 56 AllocationContextTracker::GetInstanceForCurrentThread() |
57 ->GetContextSnapshot(); | 57 ->GetContextSnapshot(); |
58 | 58 |
59 ASSERT_EQ(1u, ctx.backtrace.frame_count); | 59 ASSERT_EQ(1u, ctx.backtrace.frame_count); |
60 ASSERT_EQ(t, ctx.backtrace.frames[0]); | 60 ASSERT_EQ(t, ctx.backtrace.frames[0]); |
61 } | 61 } |
62 | 62 |
63 class AllocationContextTrackerTest : public testing::Test { | 63 class AllocationContextTrackerTest : public testing::Test { |
64 public: | 64 public: |
65 void SetUp() override { | 65 void SetUp() override { |
66 TraceConfig config(""); | 66 TraceConfig config( |
| 67 "{ \"event_filters\":[{" |
| 68 "\"included_categories\":[" |
| 69 "\"Testing\"," |
| 70 "\"disabled-by-default-Testing\"" |
| 71 "]," |
| 72 "\"filter_predicate\":\"heap_profiler_predicate\"" |
| 73 "}] }"); |
67 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); | 74 TraceLog::GetInstance()->SetEnabled(config, TraceLog::RECORDING_MODE); |
68 AllocationContextTracker::SetCaptureMode( | 75 AllocationContextTracker::SetCaptureMode( |
69 AllocationContextTracker::CaptureMode::PSEUDO_STACK); | 76 AllocationContextTracker::CaptureMode::PSEUDO_STACK); |
70 AllocationContextTracker::SetCurrentThreadName(kThreadName); | 77 AllocationContextTracker::SetCurrentThreadName(kThreadName); |
71 } | 78 } |
72 | 79 |
73 void TearDown() override { | 80 void TearDown() override { |
74 AllocationContextTracker::SetCaptureMode( | 81 AllocationContextTracker::SetCaptureMode( |
75 AllocationContextTracker::CaptureMode::DISABLED); | 82 AllocationContextTracker::CaptureMode::DISABLED); |
76 TraceLog::GetInstance()->SetDisabled(); | 83 TraceLog::GetInstance()->SetDisabled(); |
(...skipping 22 matching lines...) Expand all Loading... |
99 } | 106 } |
100 | 107 |
101 AssertBacktraceEquals(frame_c); | 108 AssertBacktraceEquals(frame_c); |
102 | 109 |
103 { | 110 { |
104 TRACE_EVENT0("Testing", kEclair); | 111 TRACE_EVENT0("Testing", kEclair); |
105 StackFrame frame_ce[] = {t, c, e}; | 112 StackFrame frame_ce[] = {t, c, e}; |
106 AssertBacktraceEquals(frame_ce); | 113 AssertBacktraceEquals(frame_ce); |
107 } | 114 } |
108 | 115 |
| 116 { |
| 117 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("Testing"), kCupcake); |
| 118 StackFrame frame_ce[] = {t, c, c}; |
| 119 AssertBacktraceEquals(frame_ce); |
| 120 } |
| 121 |
109 AssertBacktraceEquals(frame_c); | 122 AssertBacktraceEquals(frame_c); |
110 } | 123 } |
111 | 124 |
112 AssertBacktraceContainsOnlyThreadName(); | 125 AssertBacktraceContainsOnlyThreadName(); |
113 | 126 |
114 { | 127 { |
115 TRACE_EVENT0("Testing", kFroyo); | 128 TRACE_EVENT0("Testing", kFroyo); |
116 StackFrame frame_f[] = {t, f}; | 129 StackFrame frame_f[] = {t, f}; |
117 AssertBacktraceEquals(frame_f); | 130 AssertBacktraceEquals(frame_f); |
118 } | 131 } |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 AllocationContextTracker::GetInstanceForCurrentThread() | 289 AllocationContextTracker::GetInstanceForCurrentThread() |
277 ->GetContextSnapshot(); | 290 ->GetContextSnapshot(); |
278 const StringPiece kTracingOverhead("tracing_overhead"); | 291 const StringPiece kTracingOverhead("tracing_overhead"); |
279 ASSERT_EQ(kTracingOverhead, | 292 ASSERT_EQ(kTracingOverhead, |
280 static_cast<const char*>(ctx.backtrace.frames[0].value)); | 293 static_cast<const char*>(ctx.backtrace.frames[0].value)); |
281 ASSERT_EQ(1u, ctx.backtrace.frame_count); | 294 ASSERT_EQ(1u, ctx.backtrace.frame_count); |
282 } | 295 } |
283 | 296 |
284 } // namespace trace_event | 297 } // namespace trace_event |
285 } // namespace base | 298 } // namespace base |
OLD | NEW |