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

Side by Side Diff: base/debug/trace_event.h

Issue 7778033: Add trace code to track all posted tasks in message_loop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: trace_event.h formatting fix Created 9 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | base/debug/trace_event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Trace events are for tracking application performance. 5 // Trace events are for tracking application performance.
6 // 6 //
7 // Events are issued against categories. Whereas LOG's 7 // Events are issued against categories. Whereas LOG's
8 // categories are statically defined, TRACE categories are created 8 // categories are statically defined, TRACE categories are created
9 // implicitly with a string. For example: 9 // implicitly with a string. For example:
10 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") 10 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent")
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 107 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
108 #include "base/timer.h" 108 #include "base/timer.h"
109 109
110 // By default, const char* argument values are assumed to have long-lived scope 110 // By default, const char* argument values are assumed to have long-lived scope
111 // and will not be copied. Use this macro to force a const char* to be copied. 111 // and will not be copied. Use this macro to force a const char* to be copied.
112 #define TRACE_STR_COPY(str) base::debug::TraceValue::StringWithCopy(str) 112 #define TRACE_STR_COPY(str) base::debug::TraceValue::StringWithCopy(str)
113 113
114 // Older style trace macros with explicit id and extra data 114 // Older style trace macros with explicit id and extra data
115 // Only these macros result in publishing data to ETW as currently implemented. 115 // Only these macros result in publishing data to ETW as currently implemented.
116 #define TRACE_EVENT_BEGIN_ETW(name, id, extra) \ 116 #define TRACE_EVENT_BEGIN_ETW(name, id, extra) \
117 base::debug::TraceLog::AddTraceEventEtw( \ 117 base::debug::TraceLog::AddTraceEventEtw( \
118 base::debug::TRACE_EVENT_PHASE_BEGIN, \ 118 base::debug::TRACE_EVENT_PHASE_BEGIN, \
119 name, reinterpret_cast<const void*>(id), extra) 119 name, reinterpret_cast<const void*>(id), extra)
120 120
121 #define TRACE_EVENT_END_ETW(name, id, extra) \ 121 #define TRACE_EVENT_END_ETW(name, id, extra) \
122 base::debug::TraceLog::AddTraceEventEtw( \ 122 base::debug::TraceLog::AddTraceEventEtw( \
123 base::debug::TRACE_EVENT_PHASE_END, \ 123 base::debug::TRACE_EVENT_PHASE_END, \
124 name, reinterpret_cast<const void*>(id), extra) 124 name, reinterpret_cast<const void*>(id), extra)
125 125
126 #define TRACE_EVENT_INSTANT_ETW(name, id, extra) \ 126 #define TRACE_EVENT_INSTANT_ETW(name, id, extra) \
127 base::debug::TraceLog::AddTraceEventEtw( \ 127 base::debug::TraceLog::AddTraceEventEtw( \
128 base::debug::TRACE_EVENT_PHASE_INSTANT, \ 128 base::debug::TRACE_EVENT_PHASE_INSTANT, \
129 name, reinterpret_cast<const void*>(id), extra) 129 name, reinterpret_cast<const void*>(id), extra)
130 130
131 // Records a pair of begin and end events called "name" for the current 131 // Records a pair of begin and end events called "name" for the current
132 // scope, with 0, 1 or 2 associated arguments. If the category is not 132 // scope, with 0, 1 or 2 associated arguments. If the category is not
133 // enabled, then this does nothing. 133 // enabled, then this does nothing.
134 // - category and name strings must have application lifetime (statics or 134 // - category and name strings must have application lifetime (statics or
135 // literals). They may not include " chars. 135 // literals). They may not include " chars.
136 #define TRACE_EVENT0(category, name) \ 136 #define TRACE_EVENT0(category, name) \
137 TRACE_EVENT1(category, name, NULL, 0) 137 TRACE_EVENT1(category, name, NULL, 0)
138 #define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ 138 #define TRACE_EVENT1(category, name, arg1_name, arg1_val) \
139 TRACE_EVENT2(category, name, arg1_name, arg1_val, NULL, 0) 139 TRACE_EVENT2(category, name, arg1_name, arg1_val, NULL, 0)
140 #define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ 140 #define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
141 INTERNAL_TRACE_EVENT_ADD_SCOPED( \ 141 INTERNAL_TRACE_EVENT_ADD_SCOPED( \
142 category, name, arg1_name, arg1_val, arg2_name, arg2_val) 142 category, name, arg1_name, arg1_val, arg2_name, arg2_val)
143
144 // Same as TRACE_EVENT except that they are not included in official builds.
145 #ifdef OFFICIAL_BUILD
146 #define UNSHIPPED_TRACE_EVENT0(category, name) (void)0
147 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) (void)0
148 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \
149 arg2_name, arg2_val) (void)0
150 #else
151 #define UNSHIPPED_TRACE_EVENT0(category, name) \
152 TRACE_EVENT0(category, name)
153 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) \
154 TRACE_EVENT1(category, name, arg1_name, arg1_val)
155 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \
156 arg2_name, arg2_val) \
157 TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val)
158 #endif
143 159
144 // Records a single event called "name" immediately, with 0, 1 or 2 160 // Records a single event called "name" immediately, with 0, 1 or 2
145 // associated arguments. If the category is not enabled, then this 161 // associated arguments. If the category is not enabled, then this
146 // does nothing. 162 // does nothing.
147 // - category and name strings must have application lifetime (statics or 163 // - category and name strings must have application lifetime (statics or
148 // literals). They may not include " chars. 164 // literals). They may not include " chars.
149 #define TRACE_EVENT_INSTANT0(category, name) \ 165 #define TRACE_EVENT_INSTANT0(category, name) \
150 TRACE_EVENT_INSTANT1(category, name, NULL, 0) 166 TRACE_EVENT_INSTANT1(category, name, NULL, 0)
151 #define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ 167 #define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \
152 TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, NULL, 0) 168 TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, NULL, 0)
153 #define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ 169 #define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \
154 arg2_name, arg2_val) \ 170 arg2_name, arg2_val) \
155 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_INSTANT, \ 171 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_INSTANT, \
156 category, name, arg1_name, arg1_val, arg2_name, arg2_val, \ 172 category, name, arg1_name, arg1_val, arg2_name, arg2_val, \
157 base::debug::TraceLog::EVENT_FLAG_NONE) 173 base::debug::TraceLog::EVENT_FLAG_NONE)
158 #define TRACE_EVENT_COPY_INSTANT0(category, name) \ 174 #define TRACE_EVENT_COPY_INSTANT0(category, name) \
159 TRACE_EVENT_COPY_INSTANT1(category, name, NULL, 0) 175 TRACE_EVENT_COPY_INSTANT1(category, name, NULL, 0)
160 #define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ 176 #define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \
161 TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, NULL, 0) 177 TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, NULL, 0)
162 #define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ 178 #define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \
163 arg2_name, arg2_val) \ 179 arg2_name, arg2_val) \
164 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_INSTANT, \ 180 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_INSTANT, \
165 category, name, \ 181 category, name, \
166 arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ 182 arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \
167 arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ 183 arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \
168 base::debug::TraceLog::EVENT_FLAG_COPY) 184 base::debug::TraceLog::EVENT_FLAG_COPY)
169 185
170 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 186 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2
171 // associated arguments. If the category is not enabled, then this 187 // associated arguments. If the category is not enabled, then this
172 // does nothing. 188 // does nothing.
173 // - category and name strings must have application lifetime (statics or 189 // - category and name strings must have application lifetime (statics or
174 // literals). They may not include " chars. 190 // literals). They may not include " chars.
175 #define TRACE_EVENT_BEGIN0(category, name) \ 191 #define TRACE_EVENT_BEGIN0(category, name) \
176 TRACE_EVENT_BEGIN1(category, name, NULL, 0) 192 TRACE_EVENT_BEGIN1(category, name, NULL, 0)
177 #define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ 193 #define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \
178 TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, NULL, 0) 194 TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, NULL, 0)
179 #define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \ 195 #define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \
180 arg2_name, arg2_val) \ 196 arg2_name, arg2_val) \
181 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_BEGIN, \ 197 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_BEGIN, \
182 category, name, arg1_name, arg1_val, arg2_name, arg2_val, \ 198 category, name, arg1_name, arg1_val, arg2_name, arg2_val, \
183 base::debug::TraceLog::EVENT_FLAG_NONE) 199 base::debug::TraceLog::EVENT_FLAG_NONE)
184 #define TRACE_EVENT_COPY_BEGIN0(category, name) \ 200 #define TRACE_EVENT_COPY_BEGIN0(category, name) \
185 TRACE_EVENT_COPY_BEGIN1(category, name, NULL, 0) 201 TRACE_EVENT_COPY_BEGIN1(category, name, NULL, 0)
186 #define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ 202 #define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \
187 TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, NULL, 0) 203 TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, NULL, 0)
188 #define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ 204 #define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \
189 arg2_name, arg2_val) \ 205 arg2_name, arg2_val) \
190 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_BEGIN, \ 206 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_BEGIN, \
191 category, name, \ 207 category, name, \
192 arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ 208 arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \
193 arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ 209 arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \
194 base::debug::TraceLog::EVENT_FLAG_COPY) 210 base::debug::TraceLog::EVENT_FLAG_COPY)
195 211
196 // Records a single END event for "name" immediately. If the category 212 // Records a single END event for "name" immediately. If the category
197 // is not enabled, then this does nothing. 213 // is not enabled, then this does nothing.
198 // - category and name strings must have application lifetime (statics or 214 // - category and name strings must have application lifetime (statics or
199 // literals). They may not include " chars. 215 // literals). They may not include " chars.
200 #define TRACE_EVENT_END0(category, name) \ 216 #define TRACE_EVENT_END0(category, name) \
201 TRACE_EVENT_END1(category, name, NULL, 0) 217 TRACE_EVENT_END1(category, name, NULL, 0)
202 #define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ 218 #define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \
203 TRACE_EVENT_END2(category, name, arg1_name, arg1_val, NULL, 0) 219 TRACE_EVENT_END2(category, name, arg1_name, arg1_val, NULL, 0)
204 #define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ 220 #define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \
205 arg2_name, arg2_val) \ 221 arg2_name, arg2_val) \
206 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_END, \ 222 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_END, \
207 category, name, arg1_name, arg1_val, arg2_name, arg2_val, \ 223 category, name, arg1_name, arg1_val, arg2_name, arg2_val, \
208 base::debug::TraceLog::EVENT_FLAG_NONE) 224 base::debug::TraceLog::EVENT_FLAG_NONE)
209 #define TRACE_EVENT_COPY_END0(category, name) \ 225 #define TRACE_EVENT_COPY_END0(category, name) \
210 TRACE_EVENT_COPY_END1(category, name, NULL, 0) 226 TRACE_EVENT_COPY_END1(category, name, NULL, 0)
211 #define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ 227 #define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \
212 TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, NULL, 0) 228 TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, NULL, 0)
213 #define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ 229 #define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \
214 arg2_name, arg2_val) \ 230 arg2_name, arg2_val) \
215 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_END, \ 231 INTERNAL_TRACE_EVENT_ADD(base::debug::TRACE_EVENT_PHASE_END, \
216 category, name, \ 232 category, name, \
217 arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ 233 arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \
218 arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ 234 arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \
219 base::debug::TraceLog::EVENT_FLAG_COPY) 235 base::debug::TraceLog::EVENT_FLAG_COPY)
220 236
221 // Time threshold event: 237 // Time threshold event:
222 // Only record the event if the duration is greater than the specified 238 // Only record the event if the duration is greater than the specified
223 // threshold_us (time in microseconds). 239 // threshold_us (time in microseconds).
224 // Records a pair of begin and end events called "name" for the current 240 // Records a pair of begin and end events called "name" for the current
225 // scope, with 0, 1 or 2 associated arguments. If the category is not 241 // scope, with 0, 1 or 2 associated arguments. If the category is not
226 // enabled, then this does nothing. 242 // enabled, then this does nothing.
227 // - category and name strings must have application lifetime (statics or 243 // - category and name strings must have application lifetime (statics or
228 // literals). They may not include " chars. 244 // literals). They may not include " chars.
229 #define TRACE_EVENT_IF_LONGER_THAN0(threshold_us, category, name) \ 245 #define TRACE_EVENT_IF_LONGER_THAN0(threshold_us, category, name) \
230 TRACE_EVENT_IF_LONGER_THAN1(threshold_us, category, name, NULL, 0) 246 TRACE_EVENT_IF_LONGER_THAN1(threshold_us, category, name, NULL, 0)
231 #define TRACE_EVENT_IF_LONGER_THAN1( \ 247 #define TRACE_EVENT_IF_LONGER_THAN1( \
232 threshold_us, category, name, arg1_name, arg1_val) \ 248 threshold_us, category, name, arg1_name, arg1_val) \
233 TRACE_EVENT_IF_LONGER_THAN2(threshold_us, category, name, \ 249 TRACE_EVENT_IF_LONGER_THAN2(threshold_us, category, name, \
234 arg1_name, arg1_val, NULL, 0) 250 arg1_name, arg1_val, NULL, 0)
235 #define TRACE_EVENT_IF_LONGER_THAN2( \ 251 #define TRACE_EVENT_IF_LONGER_THAN2( \
236 threshold_us, category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ 252 threshold_us, category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
237 INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold_us, \ 253 INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold_us, \
238 category, name, arg1_name, arg1_val, arg2_name, arg2_val) 254 category, name, arg1_name, arg1_val, arg2_name, arg2_val)
239 255
240 256
241 // Implementation detail: trace event macros create temporary variables 257 // Implementation detail: trace event macros create temporary variables
242 // to keep instrumentation overhead low. These macros give each temporary 258 // to keep instrumentation overhead low. These macros give each temporary
243 // variable a unique name based on the line number to prevent name collissions. 259 // variable a unique name based on the line number to prevent name collissions.
244 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ 260 #define INTERNAL_TRACE_EVENT_UID3(a,b) \
245 trace_event_unique_##a##b 261 trace_event_unique_##a##b
246 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ 262 #define INTERNAL_TRACE_EVENT_UID2(a,b) \
247 INTERNAL_TRACE_EVENT_UID3(a,b) 263 INTERNAL_TRACE_EVENT_UID3(a,b)
248 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ 264 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \
249 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) 265 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__)
250 266
251 // Implementation detail: internal macro to create static category. 267 // Implementation detail: internal macro to create static category.
252 // - ANNOTATE_BENIGN_RACE, see Thread Safety above. 268 // - ANNOTATE_BENIGN_RACE, see Thread Safety above.
253 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ 269 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \
254 static const base::debug::TraceCategory* \ 270 static const base::debug::TraceCategory* \
255 INTERNAL_TRACE_EVENT_UID(catstatic) = NULL; \ 271 INTERNAL_TRACE_EVENT_UID(catstatic) = NULL; \
256 ANNOTATE_BENIGN_RACE(&INTERNAL_TRACE_EVENT_UID(catstatic), \ 272 ANNOTATE_BENIGN_RACE(&INTERNAL_TRACE_EVENT_UID(catstatic), \
257 "trace_event category"); \ 273 "trace_event category"); \
258 if (!INTERNAL_TRACE_EVENT_UID(catstatic)) \ 274 if (!INTERNAL_TRACE_EVENT_UID(catstatic)) \
259 INTERNAL_TRACE_EVENT_UID(catstatic) = \ 275 INTERNAL_TRACE_EVENT_UID(catstatic) = \
260 base::debug::TraceLog::GetCategory(category); 276 base::debug::TraceLog::GetCategory(category);
261 277
262 // Implementation detail: internal macro to create static category and add begin 278 // Implementation detail: internal macro to create static category and add begin
263 // event if the category is enabled. 279 // event if the category is enabled.
264 #define INTERNAL_TRACE_EVENT_ADD( \ 280 #define INTERNAL_TRACE_EVENT_ADD( \
265 phase, category, name, arg1_name, arg1_val, arg2_name, arg2_val, flags) \ 281 phase, category, name, arg1_name, arg1_val, arg2_name, arg2_val, flags) \
266 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ 282 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
267 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ 283 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \
268 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ 284 base::debug::TraceLog::GetInstance()->AddTraceEvent( \
269 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ 285 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \
270 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, flags); \ 286 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, flags); \
271 } 287 }
272 288
273 // Implementation detail: internal macro to create static category and add begin 289 // Implementation detail: internal macro to create static category and add begin
274 // event if the category is enabled. Also adds the end event when the scope 290 // event if the category is enabled. Also adds the end event when the scope
275 // ends. 291 // ends.
276 #define INTERNAL_TRACE_EVENT_ADD_SCOPED( \ 292 #define INTERNAL_TRACE_EVENT_ADD_SCOPED( \
277 category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ 293 category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
278 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ 294 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
279 base::debug::internal::TraceEndOnScopeClose \ 295 base::debug::internal::TraceEndOnScopeClose \
280 INTERNAL_TRACE_EVENT_UID(profileScope); \ 296 INTERNAL_TRACE_EVENT_UID(profileScope); \
281 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ 297 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \
282 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ 298 base::debug::TraceLog::GetInstance()->AddTraceEvent( \
283 base::debug::TRACE_EVENT_PHASE_BEGIN, \ 299 base::debug::TRACE_EVENT_PHASE_BEGIN, \
284 INTERNAL_TRACE_EVENT_UID(catstatic), \ 300 INTERNAL_TRACE_EVENT_UID(catstatic), \
285 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \ 301 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \
286 base::debug::TraceLog::EVENT_FLAG_NONE); \ 302 base::debug::TraceLog::EVENT_FLAG_NONE); \
287 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ 303 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \
288 INTERNAL_TRACE_EVENT_UID(catstatic), name); \ 304 INTERNAL_TRACE_EVENT_UID(catstatic), name); \
289 } 305 }
290 306
291 // Implementation detail: internal macro to create static category and add begin 307 // Implementation detail: internal macro to create static category and add begin
292 // event if the category is enabled. Also adds the end event when the scope 308 // event if the category is enabled. Also adds the end event when the scope
293 // ends. If the elapsed time is < threshold time, the begin/end pair is erased. 309 // ends. If the elapsed time is < threshold time, the begin/end pair is erased.
294 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold, \ 310 #define INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold, \
295 category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ 311 category, name, arg1_name, arg1_val, arg2_name, arg2_val) \
296 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ 312 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
297 base::debug::internal::TraceEndOnScopeCloseThreshold \ 313 base::debug::internal::TraceEndOnScopeCloseThreshold \
298 INTERNAL_TRACE_EVENT_UID(profileScope); \ 314 INTERNAL_TRACE_EVENT_UID(profileScope); \
299 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ 315 if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \
300 int INTERNAL_TRACE_EVENT_UID(begin_event_id) = \ 316 int INTERNAL_TRACE_EVENT_UID(begin_event_id) = \
301 base::debug::TraceLog::GetInstance()->AddTraceEvent( \ 317 base::debug::TraceLog::GetInstance()->AddTraceEvent( \
302 base::debug::TRACE_EVENT_PHASE_BEGIN, \ 318 base::debug::TRACE_EVENT_PHASE_BEGIN, \
303 INTERNAL_TRACE_EVENT_UID(catstatic), \ 319 INTERNAL_TRACE_EVENT_UID(catstatic), \
304 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \ 320 name, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \
305 base::debug::TraceLog::EVENT_FLAG_NONE); \ 321 base::debug::TraceLog::EVENT_FLAG_NONE); \
306 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ 322 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \
307 INTERNAL_TRACE_EVENT_UID(catstatic), name, \ 323 INTERNAL_TRACE_EVENT_UID(catstatic), name, \
308 INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \ 324 INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \
309 } 325 }
310 326
311 namespace base { 327 namespace base {
312 328
313 class RefCountedString; 329 class RefCountedString;
314 330
315 namespace debug { 331 namespace debug {
316 332
317 // Categories allow enabling/disabling of streams of trace events 333 // Categories allow enabling/disabling of streams of trace events
318 struct TraceCategory { 334 struct TraceCategory {
319 const char* name; 335 const char* name;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 const char* name, 586 const char* name,
571 const void* id, 587 const void* id,
572 const char* extra); 588 const char* extra);
573 static void AddTraceEventEtw(TraceEventPhase phase, 589 static void AddTraceEventEtw(TraceEventPhase phase,
574 const char* name, 590 const char* name,
575 const void* id, 591 const void* id,
576 const std::string& extra); 592 const std::string& extra);
577 593
578 // Exposed for unittesting: 594 // Exposed for unittesting:
579 595
596 // Allows deleting our singleton instance.
597 static void DeleteForTesting();
598
580 // Allows resurrecting our singleton instance post-AtExit processing. 599 // Allows resurrecting our singleton instance post-AtExit processing.
581 static void Resurrect(); 600 static void Resurrect();
582 601
583 // Allow tests to inspect TraceEvents. 602 // Allow tests to inspect TraceEvents.
584 size_t GetEventsSize() const { return logged_events_.size(); } 603 size_t GetEventsSize() const { return logged_events_.size(); }
585 const TraceEvent& GetEventAt(size_t index) const { 604 const TraceEvent& GetEventAt(size_t index) const {
586 DCHECK(index < logged_events_.size()); 605 DCHECK(index < logged_events_.size());
587 return logged_events_[index]; 606 return logged_events_[index];
588 } 607 }
589 608
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 Data* p_data_; 698 Data* p_data_;
680 Data data_; 699 Data data_;
681 }; 700 };
682 701
683 } // namespace internal 702 } // namespace internal
684 703
685 } // namespace debug 704 } // namespace debug
686 } // namespace base 705 } // namespace base
687 706
688 #endif // BASE_DEBUG_TRACE_EVENT_H_ 707 #endif // BASE_DEBUG_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | base/debug/trace_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698