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/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 Loading... |
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 1721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1904 } | 1906 } |
1905 | 1907 |
1906 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { | 1908 ScopedTraceBinaryEfficient::~ScopedTraceBinaryEfficient() { |
1907 if (*category_group_enabled_) { | 1909 if (*category_group_enabled_) { |
1908 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, | 1910 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(category_group_enabled_, name_, |
1909 event_handle_); | 1911 event_handle_); |
1910 } | 1912 } |
1911 } | 1913 } |
1912 | 1914 |
1913 } // namespace trace_event_internal | 1915 } // namespace trace_event_internal |
OLD | NEW |