| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // Guard for stack underflow. If tracing was started with a TRACE_EVENT in | 122 // Guard for stack underflow. If tracing was started with a TRACE_EVENT in |
| 123 // scope, the frame was never pushed, so it is possible that pop is called | 123 // scope, the frame was never pushed, so it is possible that pop is called |
| 124 // on an empty stack. | 124 // on an empty stack. |
| 125 if (pseudo_stack_.empty()) | 125 if (pseudo_stack_.empty()) |
| 126 return; | 126 return; |
| 127 | 127 |
| 128 // Assert that pushes and pops are nested correctly. This DCHECK can be | 128 // Assert that pushes and pops are nested correctly. This DCHECK can be |
| 129 // hit if some TRACE_EVENT macro is unbalanced (a TRACE_EVENT_END* call | 129 // hit if some TRACE_EVENT macro is unbalanced (a TRACE_EVENT_END* call |
| 130 // without a corresponding TRACE_EVENT_BEGIN). | 130 // without a corresponding TRACE_EVENT_BEGIN). |
| 131 DCHECK(stack_frame == pseudo_stack_.back()) | 131 DCHECK(stack_frame == pseudo_stack_.back()) |
| 132 << "Encountered an unmatched TRACE_EVENT_END: " | 132 << "Encountered an unmatched TRACE_EVENT_END"; |
| 133 << stack_frame.trace_event_name | |
| 134 << " vs event in stack: " << pseudo_stack_.back().trace_event_name; | |
| 135 | 133 |
| 136 pseudo_stack_.pop_back(); | 134 pseudo_stack_.pop_back(); |
| 137 } | 135 } |
| 138 | 136 |
| 139 void AllocationContextTracker::PushCurrentTaskContext(const char* context) { | 137 void AllocationContextTracker::PushCurrentTaskContext(const char* context) { |
| 140 DCHECK(context); | 138 DCHECK(context); |
| 141 if (task_contexts_.size() < kMaxTaskDepth) | 139 if (task_contexts_.size() < kMaxTaskDepth) |
| 142 task_contexts_.push_back(context); | 140 task_contexts_.push_back(context); |
| 143 else | 141 else |
| 144 NOTREACHED(); | 142 NOTREACHED(); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 // If task context was unavailable, then the category names are taken from | 244 // If task context was unavailable, then the category names are taken from |
| 247 // trace events. | 245 // trace events. |
| 248 ctx.type_name = pseudo_stack_.back().trace_event_category; | 246 ctx.type_name = pseudo_stack_.back().trace_event_category; |
| 249 } | 247 } |
| 250 | 248 |
| 251 return ctx; | 249 return ctx; |
| 252 } | 250 } |
| 253 | 251 |
| 254 } // namespace trace_event | 252 } // namespace trace_event |
| 255 } // namespace base | 253 } // namespace base |
| OLD | NEW |