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

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

Issue 1927963003: [tracing] Don't pop context from an empty stack. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix oops Created 4 years, 7 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698