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

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

Issue 2272843002: Heap Profiler: Add trace category group names as type names for allocations (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@add_filter
Patch Set: use substr and build fix. Created 4 years, 3 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 | « base/trace_event/heap_profiler_type_name_deduplicator.cc ('k') | 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/trace_log.h" 5 #include "base/trace_event/trace_log.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 bool FilterTraceEvent(const TraceEvent& trace_event) const override { 144 bool FilterTraceEvent(const TraceEvent& trace_event) const override {
145 if (AllocationContextTracker::capture_mode() != 145 if (AllocationContextTracker::capture_mode() !=
146 AllocationContextTracker::CaptureMode::PSEUDO_STACK) { 146 AllocationContextTracker::CaptureMode::PSEUDO_STACK) {
147 return true; 147 return true;
148 } 148 }
149 149
150 // TODO(primiano): Add support for events with copied name crbug.com/581079. 150 // TODO(primiano): Add support for events with copied name crbug.com/581079.
151 if (trace_event.flags() & TRACE_EVENT_FLAG_COPY) 151 if (trace_event.flags() & TRACE_EVENT_FLAG_COPY)
152 return true; 152 return true;
153 153
154 const char* category_name =
155 TraceLog::GetCategoryGroupName(trace_event.category_group_enabled());
154 if (trace_event.phase() == TRACE_EVENT_PHASE_BEGIN || 156 if (trace_event.phase() == TRACE_EVENT_PHASE_BEGIN ||
155 trace_event.phase() == TRACE_EVENT_PHASE_COMPLETE) { 157 trace_event.phase() == TRACE_EVENT_PHASE_COMPLETE) {
156 AllocationContextTracker::GetInstanceForCurrentThread() 158 AllocationContextTracker::GetInstanceForCurrentThread()
157 ->PushPseudoStackFrame(trace_event.name()); 159 ->PushPseudoStackFrame({category_name, trace_event.name()});
158 } else if (trace_event.phase() == TRACE_EVENT_PHASE_END) { 160 } else if (trace_event.phase() == TRACE_EVENT_PHASE_END) {
159 // The pop for |TRACE_EVENT_PHASE_COMPLETE| events is in |EndEvent|. 161 // The pop for |TRACE_EVENT_PHASE_COMPLETE| events is in |EndEvent|.
160 AllocationContextTracker::GetInstanceForCurrentThread() 162 AllocationContextTracker::GetInstanceForCurrentThread()
161 ->PopPseudoStackFrame(trace_event.name()); 163 ->PopPseudoStackFrame({category_name, trace_event.name()});
162 } 164 }
163 // Do not filter-out any events and always return true. TraceLog adds the 165 // Do not filter-out any events and always return true. TraceLog adds the
164 // event only if it is enabled for recording. 166 // event only if it is enabled for recording.
165 return true; 167 return true;
166 } 168 }
167 169
168 void EndEvent(const char* name, const char* category_group) override { 170 void EndEvent(const char* name, const char* category_group) override {
169 if (AllocationContextTracker::capture_mode() == 171 if (AllocationContextTracker::capture_mode() ==
170 AllocationContextTracker::CaptureMode::PSEUDO_STACK) { 172 AllocationContextTracker::CaptureMode::PSEUDO_STACK) {
171 AllocationContextTracker::GetInstanceForCurrentThread() 173 AllocationContextTracker::GetInstanceForCurrentThread()
172 ->PopPseudoStackFrame(name); 174 ->PopPseudoStackFrame({category_group, name});
173 } 175 }
174 } 176 }
175 }; 177 };
176 178
177 TraceLog::TraceEventFilterConstructorForTesting 179 TraceLog::TraceEventFilterConstructorForTesting
178 g_trace_event_filter_constructor_for_testing = nullptr; 180 g_trace_event_filter_constructor_for_testing = nullptr;
179 181
180 // Indexes here have to match the g_category_groups array indexes above. 182 // Indexes here have to match the g_category_groups array indexes above.
181 const int kCategoryAlreadyShutdown = 1; 183 const int kCategoryAlreadyShutdown = 1;
182 const int kCategoryCategoriesExhausted = 2; 184 const int kCategoryCategoriesExhausted = 2;
(...skipping 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 } 1923 }
1922 1924
1923 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { 1925 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() {
1924 if (*category_group_enabled_) { 1926 if (*category_group_enabled_) {
1925 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, 1927 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_,
1926 event_handle_); 1928 event_handle_);
1927 } 1929 }
1928 } 1930 }
1929 1931
1930 } // namespace trace_event_internal 1932 } // namespace trace_event_internal
OLDNEW
« no previous file with comments | « base/trace_event/heap_profiler_type_name_deduplicator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698