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 "base/trace_event/heap_profiler_allocation_context_tracker.h" | 5 #include "base/trace_event/heap_profiler_allocation_context_tracker.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <iterator> | 8 #include <iterator> |
9 | 9 |
10 #include "base/atomicops.h" | 10 #include "base/atomicops.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
106 | 106 |
107 void AllocationContextTracker::PushCurrentTaskContext(const char* context) { | 107 void AllocationContextTracker::PushCurrentTaskContext(const char* context) { |
108 DCHECK(context); | 108 DCHECK(context); |
109 if (task_contexts_.size() < kMaxTaskDepth) | 109 if (task_contexts_.size() < kMaxTaskDepth) |
110 task_contexts_.push_back(context); | 110 task_contexts_.push_back(context); |
111 else | 111 else |
112 NOTREACHED(); | 112 NOTREACHED(); |
113 } | 113 } |
114 | 114 |
115 void AllocationContextTracker::PopCurrentTaskContext(const char* context) { | 115 void AllocationContextTracker::PopCurrentTaskContext(const char* context) { |
116 // Guard for stack underflow. If tracing was started with a TRACE_EVENT in | |
117 // scope, the context was never pushed, so it is possible that pop is called | |
118 // on an empty stack. | |
119 if (task_contexts_.empty()) | |
120 return; | |
121 | |
116 DCHECK_EQ(context, task_contexts_.back()) | 122 DCHECK_EQ(context, task_contexts_.back()) |
Primiano Tucci (use gerrit)
2016/04/29 12:02:36
ok following this logic (that is correcT) we shoul
ssid
2016/04/29 12:10:44
This check is still valid because the contexts can
| |
117 << "Encountered an unmatched context end"; | 123 << "Encountered an unmatched context end"; |
118 task_contexts_.pop_back(); | 124 task_contexts_.pop_back(); |
119 } | 125 } |
120 | 126 |
121 // static | 127 // static |
122 AllocationContext AllocationContextTracker::GetContextSnapshot() { | 128 AllocationContext AllocationContextTracker::GetContextSnapshot() { |
123 AllocationContext ctx; | 129 AllocationContext ctx; |
124 | 130 |
125 if (ignore_scope_depth_) { | 131 if (ignore_scope_depth_) { |
126 ctx.backtrace.frames[0] = StackFrame::FromTraceEventName(kTracingOverhead); | 132 ctx.backtrace.frames[0] = StackFrame::FromTraceEventName(kTracingOverhead); |
(...skipping 24 matching lines...) Expand all Loading... | |
151 | 157 |
152 // TODO(ssid): Fix crbug.com/594803 to add file name as 3rd dimension | 158 // TODO(ssid): Fix crbug.com/594803 to add file name as 3rd dimension |
153 // (component name) in the heap profiler and not piggy back on the type name. | 159 // (component name) in the heap profiler and not piggy back on the type name. |
154 ctx.type_name = task_contexts_.empty() ? nullptr : task_contexts_.back(); | 160 ctx.type_name = task_contexts_.empty() ? nullptr : task_contexts_.back(); |
155 | 161 |
156 return ctx; | 162 return ctx; |
157 } | 163 } |
158 | 164 |
159 } // namespace trace_event | 165 } // namespace trace_event |
160 } // namespace base | 166 } // namespace base |
OLD | NEW |