OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This header file defines the set of trace_event macros without specifying | 5 // This header file defines the set of trace_event macros without specifying |
6 // how the events actually get collected and stored. If you need to expose trace | 6 // how the events actually get collected and stored. If you need to expose trace |
7 // events to some other universe, you can copy-and-paste this file as well as | 7 // events to some other universe, you can copy-and-paste this file as well as |
8 // trace_event.h, modifying the macros contained there as necessary for the | 8 // trace_event.h, modifying the macros contained there as necessary for the |
9 // target platform. The end result is that multiple libraries can funnel events | 9 // target platform. The end result is that multiple libraries can funnel events |
10 // through to a shared trace event collector. | 10 // through to a shared trace event collector. |
11 | 11 |
12 // Trace events are for tracking application performance and resource usage. | 12 // Trace events are for tracking application performance and resource usage. |
13 // Macros are provided to track: | 13 // Macros are provided to track: |
14 // Begin and end of function calls | 14 // Begin and end of function calls |
15 // Counters | 15 // Counters |
16 // | 16 // |
17 // Events are issued against categories. Whereas LOG's | 17 // Events are issued against categories. Whereas LOG's |
18 // categories are statically defined, TRACE categories are created | 18 // categories are statically defined, TRACE categories are created |
19 // implicitly with a string. For example: | 19 // implicitly with a string. For example: |
20 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") | 20 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") |
21 // | 21 // |
| 22 // It is often the case that one trace may belong in multiple categories at the |
| 23 // same time. The first argument to the trace can be a comma-separated list of |
| 24 // categories, forming a category group, like: |
| 25 // |
| 26 // TRACE_EVENT_INSTANT0("input,views", "OnMouseOver") |
| 27 // |
| 28 // We can enable/disable tracing of OnMouseOver by enabling/disabling either |
| 29 // category. |
| 30 // |
22 // Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: | 31 // Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: |
23 // TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") | 32 // TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") |
24 // doSomethingCostly() | 33 // doSomethingCostly() |
25 // TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") | 34 // TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") |
26 // Note: our tools can't always determine the correct BEGIN/END pairs unless | 35 // Note: our tools can't always determine the correct BEGIN/END pairs unless |
27 // these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you | 36 // these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you |
28 // need them to be in separate scopes. | 37 // need them to be in separate scopes. |
29 // | 38 // |
30 // A common use case is to trace entire function scopes. This | 39 // A common use case is to trace entire function scopes. This |
31 // issues a trace BEGIN and END automatically: | 40 // issues a trace BEGIN and END automatically: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // unique ID, by using the TRACE_COUNTER_ID* variations. | 101 // unique ID, by using the TRACE_COUNTER_ID* variations. |
93 // | 102 // |
94 // By default, trace collection is compiled in, but turned off at runtime. | 103 // By default, trace collection is compiled in, but turned off at runtime. |
95 // Collecting trace data is the responsibility of the embedding | 104 // Collecting trace data is the responsibility of the embedding |
96 // application. In Chrome's case, navigating to about:tracing will turn on | 105 // application. In Chrome's case, navigating to about:tracing will turn on |
97 // tracing and display data collected across all active processes. | 106 // tracing and display data collected across all active processes. |
98 // | 107 // |
99 // | 108 // |
100 // Memory scoping note: | 109 // Memory scoping note: |
101 // Tracing copies the pointers, not the string content, of the strings passed | 110 // Tracing copies the pointers, not the string content, of the strings passed |
102 // in for category, name, and arg_names. Thus, the following code will | 111 // in for category_group, name, and arg_names. Thus, the following code will |
103 // cause problems: | 112 // cause problems: |
104 // char* str = strdup("impprtantName"); | 113 // char* str = strdup("importantName"); |
105 // TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! | 114 // TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! |
106 // free(str); // Trace system now has dangling pointer | 115 // free(str); // Trace system now has dangling pointer |
107 // | 116 // |
108 // To avoid this issue with the |name| and |arg_name| parameters, use the | 117 // To avoid this issue with the |name| and |arg_name| parameters, use the |
109 // TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime overhead. | 118 // TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime overhead. |
110 // Notes: The category must always be in a long-lived char* (i.e. static const). | 119 // Notes: The category must always be in a long-lived char* (i.e. static const). |
111 // The |arg_values|, when used, are always deep copied with the _COPY | 120 // The |arg_values|, when used, are always deep copied with the _COPY |
112 // macros. | 121 // macros. |
113 // | 122 // |
114 // When are string argument values copied: | 123 // When are string argument values copied: |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 // A thread safe singleton and mutex are used for thread safety. Category | 166 // A thread safe singleton and mutex are used for thread safety. Category |
158 // enabled flags are used to limit the performance impact when the system | 167 // enabled flags are used to limit the performance impact when the system |
159 // is not enabled. | 168 // is not enabled. |
160 // | 169 // |
161 // TRACE_EVENT macros first cache a pointer to a category. The categories are | 170 // TRACE_EVENT macros first cache a pointer to a category. The categories are |
162 // statically allocated and safe at all times, even after exit. Fetching a | 171 // statically allocated and safe at all times, even after exit. Fetching a |
163 // category is protected by the TraceLog::lock_. Multiple threads initializing | 172 // category is protected by the TraceLog::lock_. Multiple threads initializing |
164 // the static variable is safe, as they will be serialized by the lock and | 173 // the static variable is safe, as they will be serialized by the lock and |
165 // multiple calls will return the same pointer to the category. | 174 // multiple calls will return the same pointer to the category. |
166 // | 175 // |
167 // Then the category_enabled flag is checked. This is a unsigned char, and | 176 // Then the category_group_enabled flag is checked. This is a unsigned char, and |
168 // not intended to be multithread safe. It optimizes access to AddTraceEvent | 177 // not intended to be multithread safe. It optimizes access to AddTraceEvent |
169 // which is threadsafe internally via TraceLog::lock_. The enabled flag may | 178 // which is threadsafe internally via TraceLog::lock_. The enabled flag may |
170 // cause some threads to incorrectly call or skip calling AddTraceEvent near | 179 // cause some threads to incorrectly call or skip calling AddTraceEvent near |
171 // the time of the system being enabled or disabled. This is acceptable as | 180 // the time of the system being enabled or disabled. This is acceptable as |
172 // we tolerate some data loss while the system is being enabled/disabled and | 181 // we tolerate some data loss while the system is being enabled/disabled and |
173 // because AddTraceEvent is threadsafe internally and checks the enabled state | 182 // because AddTraceEvent is threadsafe internally and checks the enabled state |
174 // again under lock. | 183 // again under lock. |
175 // | 184 // |
176 // Without the use of these static category pointers and enabled flags all | 185 // Without the use of these static category pointers and enabled flags all |
177 // trace points would carry a significant performance cost of aquiring a lock | 186 // trace points would carry a significant performance cost of aquiring a lock |
(...skipping 16 matching lines...) Expand all Loading... |
194 // By default, uint64 ID argument values are not mangled with the Process ID in | 203 // By default, uint64 ID argument values are not mangled with the Process ID in |
195 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. | 204 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. |
196 #define TRACE_ID_MANGLE(id) \ | 205 #define TRACE_ID_MANGLE(id) \ |
197 trace_event_internal::TraceID::ForceMangle(id) | 206 trace_event_internal::TraceID::ForceMangle(id) |
198 | 207 |
199 // Records a pair of begin and end events called "name" for the current | 208 // Records a pair of begin and end events called "name" for the current |
200 // scope, with 0, 1 or 2 associated arguments. If the category is not | 209 // scope, with 0, 1 or 2 associated arguments. If the category is not |
201 // enabled, then this does nothing. | 210 // enabled, then this does nothing. |
202 // - category and name strings must have application lifetime (statics or | 211 // - category and name strings must have application lifetime (statics or |
203 // literals). They may not include " chars. | 212 // literals). They may not include " chars. |
204 #define TRACE_EVENT0(category, name) \ | 213 #define TRACE_EVENT0(category_group, name) \ |
205 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name) | 214 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name) |
206 #define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ | 215 #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ |
207 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val) | 216 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val) |
208 #define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ | 217 #define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \ |
209 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \ | 218 arg2_val) \ |
| 219 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val, \ |
210 arg2_name, arg2_val) | 220 arg2_name, arg2_val) |
211 | 221 |
212 // Same as TRACE_EVENT except that they are not included in official builds. | 222 // Same as TRACE_EVENT except that they are not included in official builds. |
213 #ifdef OFFICIAL_BUILD | 223 #ifdef OFFICIAL_BUILD |
214 #define UNSHIPPED_TRACE_EVENT0(category, name) (void)0 | 224 #define UNSHIPPED_TRACE_EVENT0(category_group, name) (void)0 |
215 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) (void)0 | 225 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ |
216 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \ | 226 (void)0 |
| 227 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \ |
217 arg2_name, arg2_val) (void)0 | 228 arg2_name, arg2_val) (void)0 |
218 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name, scope) (void)0 | 229 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name, scope) (void)0 |
219 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, scope, \ | 230 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, scope, \ |
220 arg1_name, arg1_val) (void)0 | 231 arg1_name, arg1_val) (void)0 |
221 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, scope, \ | 232 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category_group, name, scope, \ |
222 arg1_name, arg1_val, \ | 233 arg1_name, arg1_val, \ |
223 arg2_name, arg2_val) (void)0 | 234 arg2_name, arg2_val) (void)0 |
224 #else | 235 #else |
225 #define UNSHIPPED_TRACE_EVENT0(category, name) \ | 236 #define UNSHIPPED_TRACE_EVENT0(category_group, name) \ |
226 TRACE_EVENT0(category, name) | 237 TRACE_EVENT0(category_group, name) |
227 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) \ | 238 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ |
228 TRACE_EVENT1(category, name, arg1_name, arg1_val) | 239 TRACE_EVENT1(category_group, name, arg1_name, arg1_val) |
229 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \ | 240 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \ |
230 arg2_name, arg2_val) \ | 241 arg2_name, arg2_val) \ |
231 TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) | 242 TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) |
232 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name, scope) \ | 243 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name, scope) \ |
233 TRACE_EVENT_INSTANT0(category, name, scope) | 244 TRACE_EVENT_INSTANT0(category_group, name, scope) |
234 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, scope, \ | 245 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, scope, \ |
235 arg1_name, arg1_val) \ | 246 arg1_name, arg1_val) \ |
236 TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) | 247 TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) |
237 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, scope, \ | 248 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category_group, name, scope, \ |
238 arg1_name, arg1_val, \ | 249 arg1_name, arg1_val, \ |
239 arg2_name, arg2_val) \ | 250 arg2_name, arg2_val) \ |
240 TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \ | 251 TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \ |
241 arg2_name, arg2_val) | 252 arg2_name, arg2_val) |
242 #endif | 253 #endif |
243 | 254 |
244 // Records a single event called "name" immediately, with 0, 1 or 2 | 255 // Records a single event called "name" immediately, with 0, 1 or 2 |
245 // associated arguments. If the category is not enabled, then this | 256 // associated arguments. If the category is not enabled, then this |
246 // does nothing. | 257 // does nothing. |
247 // - category and name strings must have application lifetime (statics or | 258 // - category and name strings must have application lifetime (statics or |
248 // literals). They may not include " chars. | 259 // literals). They may not include " chars. |
249 #define TRACE_EVENT_INSTANT0(category, name, scope) \ | 260 #define TRACE_EVENT_INSTANT0(category_group, name, scope) \ |
250 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 261 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
251 category, name, TRACE_EVENT_FLAG_NONE | scope) | 262 category_group, name, TRACE_EVENT_FLAG_NONE | scope) |
252 #define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \ | 263 #define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) \ |
253 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 264 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
254 category, name, TRACE_EVENT_FLAG_NONE | scope, \ | 265 category_group, name, TRACE_EVENT_FLAG_NONE | scope, \ |
255 arg1_name, arg1_val) | 266 arg1_name, arg1_val) |
256 #define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \ | 267 #define TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \ |
257 arg2_name, arg2_val) \ | 268 arg2_name, arg2_val) \ |
258 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 269 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
259 category, name, TRACE_EVENT_FLAG_NONE | scope, \ | 270 category_group, name, TRACE_EVENT_FLAG_NONE | scope, \ |
260 arg1_name, arg1_val, arg2_name, arg2_val) | 271 arg1_name, arg1_val, arg2_name, arg2_val) |
261 #define TRACE_EVENT_COPY_INSTANT0(category, name, scope) \ | 272 #define TRACE_EVENT_COPY_INSTANT0(category_group, name, scope) \ |
262 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 273 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
263 category, name, TRACE_EVENT_FLAG_COPY | scope) | 274 category_group, name, TRACE_EVENT_FLAG_COPY | scope) |
264 #define TRACE_EVENT_COPY_INSTANT1(category, name, scope, \ | 275 #define TRACE_EVENT_COPY_INSTANT1(category_group, name, scope, \ |
265 arg1_name, arg1_val) \ | 276 arg1_name, arg1_val) \ |
266 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 277 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
267 category, name, TRACE_EVENT_FLAG_COPY | scope, arg1_name, arg1_val) | 278 category_group, name, TRACE_EVENT_FLAG_COPY | scope, arg1_name, \ |
268 #define TRACE_EVENT_COPY_INSTANT2(category, name, scope, \ | 279 arg1_val) |
| 280 #define TRACE_EVENT_COPY_INSTANT2(category_group, name, scope, \ |
269 arg1_name, arg1_val, \ | 281 arg1_name, arg1_val, \ |
270 arg2_name, arg2_val) \ | 282 arg2_name, arg2_val) \ |
271 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 283 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
272 category, name, TRACE_EVENT_FLAG_COPY | scope, \ | 284 category_group, name, TRACE_EVENT_FLAG_COPY | scope, \ |
273 arg1_name, arg1_val, arg2_name, arg2_val) | 285 arg1_name, arg1_val, arg2_name, arg2_val) |
274 | 286 |
275 // Sets the current sample state to the given category and name (both must be | 287 // Sets the current sample state to the given category and name (both must be |
276 // constant strings). These states are intended for a sampling profiler. | 288 // constant strings). These states are intended for a sampling profiler. |
277 // Implementation note: we store category and name together because we don't | 289 // Implementation note: we store category and name together because we don't |
278 // want the inconsistency/expense of storing two pointers. | 290 // want the inconsistency/expense of storing two pointers. |
279 // |thread_bucket| is [0..2] and is used to statically isolate samples in one | 291 // |thread_bucket| is [0..2] and is used to statically isolate samples in one |
280 // thread from others. | 292 // thread from others. |
281 #define TRACE_EVENT_SAMPLE_STATE(thread_bucket, category, name) \ | 293 #define TRACE_EVENT_SAMPLE_STATE(thread_bucket, category, name) \ |
282 TRACE_EVENT_API_ATOMIC_STORE( \ | 294 TRACE_EVENT_API_ATOMIC_STORE( \ |
283 TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \ | 295 TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \ |
284 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(category "\0" name)); | 296 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(category "\0" name)); |
285 | 297 |
286 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 | 298 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 |
287 // associated arguments. If the category is not enabled, then this | 299 // associated arguments. If the category is not enabled, then this |
288 // does nothing. | 300 // does nothing. |
289 // - category and name strings must have application lifetime (statics or | 301 // - category and name strings must have application lifetime (statics or |
290 // literals). They may not include " chars. | 302 // literals). They may not include " chars. |
291 #define TRACE_EVENT_BEGIN0(category, name) \ | 303 #define TRACE_EVENT_BEGIN0(category_group, name) \ |
292 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 304 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
293 category, name, TRACE_EVENT_FLAG_NONE) | 305 category_group, name, TRACE_EVENT_FLAG_NONE) |
294 #define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ | 306 #define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val) \ |
295 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 307 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
296 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 308 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
297 #define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \ | 309 #define TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_val, \ |
298 arg2_name, arg2_val) \ | 310 arg2_name, arg2_val) \ |
299 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 311 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
300 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 312 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
301 arg2_name, arg2_val) | 313 arg2_name, arg2_val) |
302 #define TRACE_EVENT_COPY_BEGIN0(category, name) \ | 314 #define TRACE_EVENT_COPY_BEGIN0(category_group, name) \ |
303 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 315 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
304 category, name, TRACE_EVENT_FLAG_COPY) | 316 category_group, name, TRACE_EVENT_FLAG_COPY) |
305 #define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ | 317 #define TRACE_EVENT_COPY_BEGIN1(category_group, name, arg1_name, arg1_val) \ |
306 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 318 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
307 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 319 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
308 #define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ | 320 #define TRACE_EVENT_COPY_BEGIN2(category_group, name, arg1_name, arg1_val, \ |
309 arg2_name, arg2_val) \ | 321 arg2_name, arg2_val) \ |
310 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 322 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
311 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 323 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
312 arg2_name, arg2_val) | 324 arg2_name, arg2_val) |
313 | 325 |
314 // Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided. | 326 // Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided. |
315 // - |id| is used to match the _BEGIN event with the _END event. | 327 // - |id| is used to match the _BEGIN event with the _END event. |
316 // Events are considered to match if their category, name and id values all | 328 // Events are considered to match if their category_group, name and id values |
317 // match. |id| must either be a pointer or an integer value up to 64 bits. If | 329 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
318 // it's a pointer, the bits will be xored with a hash of the process ID so | 330 // If it's a pointer, the bits will be xored with a hash of the process ID so |
319 // that the same pointer on two different processes will not collide. | 331 // that the same pointer on two different processes will not collide. |
320 #define TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(category, \ | 332 #define TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(category_group, \ |
321 name, id, thread_id, timestamp) \ | 333 name, id, thread_id, timestamp) \ |
322 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 334 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
323 TRACE_EVENT_PHASE_ASYNC_BEGIN, category, name, id, thread_id, \ | 335 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ |
324 timestamp, TRACE_EVENT_FLAG_NONE) | 336 timestamp, TRACE_EVENT_FLAG_NONE) |
325 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \ | 337 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \ |
326 category, name, id, thread_id, timestamp) \ | 338 category_group, name, id, thread_id, timestamp) \ |
327 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 339 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
328 TRACE_EVENT_PHASE_ASYNC_BEGIN, category, name, id, thread_id, \ | 340 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ |
329 timestamp, TRACE_EVENT_FLAG_COPY) | 341 timestamp, TRACE_EVENT_FLAG_COPY) |
330 | 342 |
331 // Records a single END event for "name" immediately. If the category | 343 // Records a single END event for "name" immediately. If the category |
332 // is not enabled, then this does nothing. | 344 // is not enabled, then this does nothing. |
333 // - category and name strings must have application lifetime (statics or | 345 // - category and name strings must have application lifetime (statics or |
334 // literals). They may not include " chars. | 346 // literals). They may not include " chars. |
335 #define TRACE_EVENT_END0(category, name) \ | 347 #define TRACE_EVENT_END0(category_group, name) \ |
336 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 348 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
337 category, name, TRACE_EVENT_FLAG_NONE) | 349 category_group, name, TRACE_EVENT_FLAG_NONE) |
338 #define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ | 350 #define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val) \ |
339 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 351 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
340 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 352 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
341 #define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ | 353 #define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, \ |
342 arg2_name, arg2_val) \ | 354 arg2_name, arg2_val) \ |
343 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 355 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
344 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 356 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
345 arg2_name, arg2_val) | 357 arg2_name, arg2_val) |
346 #define TRACE_EVENT_COPY_END0(category, name) \ | 358 #define TRACE_EVENT_COPY_END0(category_group, name) \ |
347 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 359 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
348 category, name, TRACE_EVENT_FLAG_COPY) | 360 category_group, name, TRACE_EVENT_FLAG_COPY) |
349 #define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ | 361 #define TRACE_EVENT_COPY_END1(category_group, name, arg1_name, arg1_val) \ |
350 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 362 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
351 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 363 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
352 #define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ | 364 #define TRACE_EVENT_COPY_END2(category_group, name, arg1_name, arg1_val, \ |
353 arg2_name, arg2_val) \ | 365 arg2_name, arg2_val) \ |
354 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 366 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
355 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 367 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
356 arg2_name, arg2_val) | 368 arg2_name, arg2_val) |
357 | 369 |
358 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided. | 370 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided. |
359 // - |id| is used to match the _BEGIN event with the _END event. | 371 // - |id| is used to match the _BEGIN event with the _END event. |
360 // Events are considered to match if their category, name and id values all | 372 // Events are considered to match if their category_group, name and id values |
361 // match. |id| must either be a pointer or an integer value up to 64 bits. If | 373 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
362 // it's a pointer, the bits will be xored with a hash of the process ID so | 374 // If it's a pointer, the bits will be xored with a hash of the process ID so |
363 // that the same pointer on two different processes will not collide. | 375 // that the same pointer on two different processes will not collide. |
364 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category, \ | 376 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category_group, \ |
365 name, id, thread_id, timestamp) \ | 377 name, id, thread_id, timestamp) \ |
366 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 378 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
367 TRACE_EVENT_PHASE_ASYNC_END, category, name, id, thread_id, timestamp, \ | 379 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ |
368 TRACE_EVENT_FLAG_NONE) | 380 timestamp, TRACE_EVENT_FLAG_NONE) |
369 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \ | 381 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \ |
370 category, name, id, thread_id, timestamp) \ | 382 category_group, name, id, thread_id, timestamp) \ |
371 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 383 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
372 TRACE_EVENT_PHASE_ASYNC_END, category, name, id, thread_id, timestamp, \ | 384 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ |
373 TRACE_EVENT_FLAG_COPY) | 385 timestamp, TRACE_EVENT_FLAG_COPY) |
374 | 386 |
375 // Records the value of a counter called "name" immediately. Value | 387 // Records the value of a counter called "name" immediately. Value |
376 // must be representable as a 32 bit integer. | 388 // must be representable as a 32 bit integer. |
377 // - category and name strings must have application lifetime (statics or | 389 // - category and name strings must have application lifetime (statics or |
378 // literals). They may not include " chars. | 390 // literals). They may not include " chars. |
379 #define TRACE_COUNTER1(category, name, value) \ | 391 #define TRACE_COUNTER1(category_group, name, value) \ |
380 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 392 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
381 category, name, TRACE_EVENT_FLAG_NONE, \ | 393 category_group, name, TRACE_EVENT_FLAG_NONE, \ |
382 "value", static_cast<int>(value)) | 394 "value", static_cast<int>(value)) |
383 #define TRACE_COPY_COUNTER1(category, name, value) \ | 395 #define TRACE_COPY_COUNTER1(category_group, name, value) \ |
384 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 396 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
385 category, name, TRACE_EVENT_FLAG_COPY, \ | 397 category_group, name, TRACE_EVENT_FLAG_COPY, \ |
386 "value", static_cast<int>(value)) | 398 "value", static_cast<int>(value)) |
387 | 399 |
388 // Records the values of a multi-parted counter called "name" immediately. | 400 // Records the values of a multi-parted counter called "name" immediately. |
389 // The UI will treat value1 and value2 as parts of a whole, displaying their | 401 // The UI will treat value1 and value2 as parts of a whole, displaying their |
390 // values as a stacked-bar chart. | 402 // values as a stacked-bar chart. |
391 // - category and name strings must have application lifetime (statics or | 403 // - category and name strings must have application lifetime (statics or |
392 // literals). They may not include " chars. | 404 // literals). They may not include " chars. |
393 #define TRACE_COUNTER2(category, name, value1_name, value1_val, \ | 405 #define TRACE_COUNTER2(category_group, name, value1_name, value1_val, \ |
394 value2_name, value2_val) \ | 406 value2_name, value2_val) \ |
395 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 407 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
396 category, name, TRACE_EVENT_FLAG_NONE, \ | 408 category_group, name, TRACE_EVENT_FLAG_NONE, \ |
397 value1_name, static_cast<int>(value1_val), \ | 409 value1_name, static_cast<int>(value1_val), \ |
398 value2_name, static_cast<int>(value2_val)) | 410 value2_name, static_cast<int>(value2_val)) |
399 #define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ | 411 #define TRACE_COPY_COUNTER2(category_group, name, value1_name, value1_val, \ |
400 value2_name, value2_val) \ | 412 value2_name, value2_val) \ |
401 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 413 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
402 category, name, TRACE_EVENT_FLAG_COPY, \ | 414 category_group, name, TRACE_EVENT_FLAG_COPY, \ |
403 value1_name, static_cast<int>(value1_val), \ | 415 value1_name, static_cast<int>(value1_val), \ |
404 value2_name, static_cast<int>(value2_val)) | 416 value2_name, static_cast<int>(value2_val)) |
405 | 417 |
406 // Records the value of a counter called "name" immediately. Value | 418 // Records the value of a counter called "name" immediately. Value |
407 // must be representable as a 32 bit integer. | 419 // must be representable as a 32 bit integer. |
408 // - category and name strings must have application lifetime (statics or | 420 // - category and name strings must have application lifetime (statics or |
409 // literals). They may not include " chars. | 421 // literals). They may not include " chars. |
410 // - |id| is used to disambiguate counters with the same name. It must either | 422 // - |id| is used to disambiguate counters with the same name. It must either |
411 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits | 423 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits |
412 // will be xored with a hash of the process ID so that the same pointer on | 424 // will be xored with a hash of the process ID so that the same pointer on |
413 // two different processes will not collide. | 425 // two different processes will not collide. |
414 #define TRACE_COUNTER_ID1(category, name, id, value) \ | 426 #define TRACE_COUNTER_ID1(category_group, name, id, value) \ |
415 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 427 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
416 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 428 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
417 "value", static_cast<int>(value)) | 429 "value", static_cast<int>(value)) |
418 #define TRACE_COPY_COUNTER_ID1(category, name, id, value) \ | 430 #define TRACE_COPY_COUNTER_ID1(category_group, name, id, value) \ |
419 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 431 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
420 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 432 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
421 "value", static_cast<int>(value)) | 433 "value", static_cast<int>(value)) |
422 | 434 |
423 // Records the values of a multi-parted counter called "name" immediately. | 435 // Records the values of a multi-parted counter called "name" immediately. |
424 // The UI will treat value1 and value2 as parts of a whole, displaying their | 436 // The UI will treat value1 and value2 as parts of a whole, displaying their |
425 // values as a stacked-bar chart. | 437 // values as a stacked-bar chart. |
426 // - category and name strings must have application lifetime (statics or | 438 // - category and name strings must have application lifetime (statics or |
427 // literals). They may not include " chars. | 439 // literals). They may not include " chars. |
428 // - |id| is used to disambiguate counters with the same name. It must either | 440 // - |id| is used to disambiguate counters with the same name. It must either |
429 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits | 441 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits |
430 // will be xored with a hash of the process ID so that the same pointer on | 442 // will be xored with a hash of the process ID so that the same pointer on |
431 // two different processes will not collide. | 443 // two different processes will not collide. |
432 #define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ | 444 #define TRACE_COUNTER_ID2(category_group, name, id, value1_name, value1_val, \ |
433 value2_name, value2_val) \ | 445 value2_name, value2_val) \ |
434 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 446 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
435 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 447 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
436 value1_name, static_cast<int>(value1_val), \ | 448 value1_name, static_cast<int>(value1_val), \ |
437 value2_name, static_cast<int>(value2_val)) | 449 value2_name, static_cast<int>(value2_val)) |
438 #define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \ | 450 #define TRACE_COPY_COUNTER_ID2(category_group, name, id, value1_name, \ |
439 value2_name, value2_val) \ | 451 value1_val, value2_name, value2_val) \ |
440 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 452 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
441 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 453 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
442 value1_name, static_cast<int>(value1_val), \ | 454 value1_name, static_cast<int>(value1_val), \ |
443 value2_name, static_cast<int>(value2_val)) | 455 value2_name, static_cast<int>(value2_val)) |
444 | 456 |
445 | 457 |
446 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 | 458 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 |
447 // associated arguments. If the category is not enabled, then this | 459 // associated arguments. If the category is not enabled, then this |
448 // does nothing. | 460 // does nothing. |
449 // - category and name strings must have application lifetime (statics or | 461 // - category and name strings must have application lifetime (statics or |
450 // literals). They may not include " chars. | 462 // literals). They may not include " chars. |
451 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC | 463 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC |
452 // events are considered to match if their category, name and id values all | 464 // events are considered to match if their category_group, name and id values |
453 // match. |id| must either be a pointer or an integer value up to 64 bits. If | 465 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
454 // it's a pointer, the bits will be xored with a hash of the process ID so | 466 // If it's a pointer, the bits will be xored with a hash of the process ID so |
455 // that the same pointer on two different processes will not collide. | 467 // that the same pointer on two different processes will not collide. |
456 // An asynchronous operation can consist of multiple phases. The first phase is | 468 // An asynchronous operation can consist of multiple phases. The first phase is |
457 // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the | 469 // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the |
458 // ASYNC_STEP macros. When the operation completes, call ASYNC_END. | 470 // ASYNC_STEP macros. When the operation completes, call ASYNC_END. |
459 // An ASYNC trace typically occur on a single thread (if not, they will only be | 471 // An ASYNC trace typically occur on a single thread (if not, they will only be |
460 // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that | 472 // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that |
461 // operation must use the same |name| and |id|. Each event can have its own | 473 // operation must use the same |name| and |id|. Each event can have its own |
462 // args. | 474 // args. |
463 #define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \ | 475 #define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \ |
464 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 476 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
465 category, name, id, TRACE_EVENT_FLAG_NONE) | 477 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
466 #define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ | 478 #define TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ |
| 479 arg1_val) \ |
467 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 480 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
468 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 481 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
469 #define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ | 482 #define TRACE_EVENT_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ |
470 arg2_name, arg2_val) \ | 483 arg1_val, arg2_name, arg2_val) \ |
471 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 484 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
472 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 485 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
473 arg1_name, arg1_val, arg2_name, arg2_val) | 486 arg1_name, arg1_val, arg2_name, arg2_val) |
474 #define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \ | 487 #define TRACE_EVENT_COPY_ASYNC_BEGIN0(category_group, name, id) \ |
475 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 488 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
476 category, name, id, TRACE_EVENT_FLAG_COPY) | 489 category_group, name, id, TRACE_EVENT_FLAG_COPY) |
477 #define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ | 490 #define TRACE_EVENT_COPY_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ |
| 491 arg1_val) \ |
478 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 492 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
479 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 493 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
480 arg1_name, arg1_val) | 494 arg1_name, arg1_val) |
481 #define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ | 495 #define TRACE_EVENT_COPY_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ |
482 arg2_name, arg2_val) \ | 496 arg1_val, arg2_name, arg2_val) \ |
483 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 497 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
484 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 498 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
485 arg1_name, arg1_val, arg2_name, arg2_val) | 499 arg1_name, arg1_val, arg2_name, arg2_val) |
486 | 500 |
487 // Records a single ASYNC_STEP event for |step| immediately. If the category | 501 // Records a single ASYNC_STEP event for |step| immediately. If the category |
488 // is not enabled, then this does nothing. The |name| and |id| must match the | 502 // is not enabled, then this does nothing. The |name| and |id| must match the |
489 // ASYNC_BEGIN event above. The |step| param identifies this step within the | 503 // ASYNC_BEGIN event above. The |step| param identifies this step within the |
490 // async event. This should be called at the beginning of the next phase of an | 504 // async event. This should be called at the beginning of the next phase of an |
491 // asynchronous operation. | 505 // asynchronous operation. |
492 #define TRACE_EVENT_ASYNC_STEP0(category, name, id, step) \ | 506 #define TRACE_EVENT_ASYNC_STEP0(category_group, name, id, step) \ |
493 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ | 507 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ |
494 category, name, id, TRACE_EVENT_FLAG_NONE, "step", step) | 508 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) |
495 #define TRACE_EVENT_ASYNC_STEP1(category, name, id, step, \ | 509 #define TRACE_EVENT_ASYNC_STEP1(category_group, name, id, step, \ |
496 arg1_name, arg1_val) \ | 510 arg1_name, arg1_val) \ |
497 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ | 511 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ |
498 category, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ | 512 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ |
499 arg1_name, arg1_val) | 513 arg1_name, arg1_val) |
500 #define TRACE_EVENT_COPY_ASYNC_STEP0(category, name, id, step) \ | 514 #define TRACE_EVENT_COPY_ASYNC_STEP0(category_group, name, id, step) \ |
501 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ | 515 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ |
502 category, name, id, TRACE_EVENT_FLAG_COPY, "step", step) | 516 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step) |
503 #define TRACE_EVENT_COPY_ASYNC_STEP1(category, name, id, step, \ | 517 #define TRACE_EVENT_COPY_ASYNC_STEP1(category_group, name, id, step, \ |
504 arg1_name, arg1_val) \ | 518 arg1_name, arg1_val) \ |
505 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ | 519 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ |
506 category, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \ | 520 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \ |
507 arg1_name, arg1_val) | 521 arg1_name, arg1_val) |
508 | 522 |
509 // Records a single ASYNC_END event for "name" immediately. If the category | 523 // Records a single ASYNC_END event for "name" immediately. If the category |
510 // is not enabled, then this does nothing. | 524 // is not enabled, then this does nothing. |
511 #define TRACE_EVENT_ASYNC_END0(category, name, id) \ | 525 #define TRACE_EVENT_ASYNC_END0(category_group, name, id) \ |
512 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 526 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
513 category, name, id, TRACE_EVENT_FLAG_NONE) | 527 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
514 #define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ | 528 #define TRACE_EVENT_ASYNC_END1(category_group, name, id, arg1_name, arg1_val) \ |
515 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 529 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
516 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 530 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
517 #define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ | 531 #define TRACE_EVENT_ASYNC_END2(category_group, name, id, arg1_name, arg1_val, \ |
518 arg2_name, arg2_val) \ | 532 arg2_name, arg2_val) \ |
519 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 533 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
520 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 534 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
521 arg1_name, arg1_val, arg2_name, arg2_val) | 535 arg1_name, arg1_val, arg2_name, arg2_val) |
522 #define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \ | 536 #define TRACE_EVENT_COPY_ASYNC_END0(category_group, name, id) \ |
523 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 537 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
524 category, name, id, TRACE_EVENT_FLAG_COPY) | 538 category_group, name, id, TRACE_EVENT_FLAG_COPY) |
525 #define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ | 539 #define TRACE_EVENT_COPY_ASYNC_END1(category_group, name, id, arg1_name, \ |
| 540 arg1_val) \ |
526 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 541 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
527 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 542 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
528 arg1_name, arg1_val) | 543 arg1_name, arg1_val) |
529 #define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ | 544 #define TRACE_EVENT_COPY_ASYNC_END2(category_group, name, id, arg1_name, \ |
530 arg2_name, arg2_val) \ | 545 arg1_val, arg2_name, arg2_val) \ |
531 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 546 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
532 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 547 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
533 arg1_name, arg1_val, arg2_name, arg2_val) | 548 arg1_name, arg1_val, arg2_name, arg2_val) |
534 | 549 |
535 | 550 |
536 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 | 551 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 |
537 // associated arguments. If the category is not enabled, then this | 552 // associated arguments. If the category is not enabled, then this |
538 // does nothing. | 553 // does nothing. |
539 // - category and name strings must have application lifetime (statics or | 554 // - category and name strings must have application lifetime (statics or |
540 // literals). They may not include " chars. | 555 // literals). They may not include " chars. |
541 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW | 556 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW |
542 // events are considered to match if their category, name and id values all | 557 // events are considered to match if their category_group, name and id values |
543 // match. |id| must either be a pointer or an integer value up to 64 bits. If | 558 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
544 // it's a pointer, the bits will be xored with a hash of the process ID so | 559 // If it's a pointer, the bits will be xored with a hash of the process ID so |
545 // that the same pointer on two different processes will not collide. | 560 // that the same pointer on two different processes will not collide. |
546 // FLOW events are different from ASYNC events in how they are drawn by the | 561 // FLOW events are different from ASYNC events in how they are drawn by the |
547 // tracing UI. A FLOW defines asynchronous data flow, such as posting a task | 562 // tracing UI. A FLOW defines asynchronous data flow, such as posting a task |
548 // (FLOW_BEGIN) and later executing that task (FLOW_END). Expect FLOWs to be | 563 // (FLOW_BEGIN) and later executing that task (FLOW_END). Expect FLOWs to be |
549 // drawn as lines or arrows from FLOW_BEGIN scopes to FLOW_END scopes. Similar | 564 // drawn as lines or arrows from FLOW_BEGIN scopes to FLOW_END scopes. Similar |
550 // to ASYNC, a FLOW can consist of multiple phases. The first phase is defined | 565 // to ASYNC, a FLOW can consist of multiple phases. The first phase is defined |
551 // by the FLOW_BEGIN calls. Additional phases can be defined using the FLOW_STEP | 566 // by the FLOW_BEGIN calls. Additional phases can be defined using the FLOW_STEP |
552 // macros. When the operation completes, call FLOW_END. An async operation can | 567 // macros. When the operation completes, call FLOW_END. An async operation can |
553 // span threads and processes, but all events in that operation must use the | 568 // span threads and processes, but all events in that operation must use the |
554 // same |name| and |id|. Each event can have its own args. | 569 // same |name| and |id|. Each event can have its own args. |
555 #define TRACE_EVENT_FLOW_BEGIN0(category, name, id) \ | 570 #define TRACE_EVENT_FLOW_BEGIN0(category_group, name, id) \ |
556 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 571 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
557 category, name, id, TRACE_EVENT_FLAG_NONE) | 572 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
558 #define TRACE_EVENT_FLOW_BEGIN1(category, name, id, arg1_name, arg1_val) \ | 573 #define TRACE_EVENT_FLOW_BEGIN1(category_group, name, id, arg1_name, arg1_val) \ |
559 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 574 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
560 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 575 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
561 #define TRACE_EVENT_FLOW_BEGIN2(category, name, id, arg1_name, arg1_val, \ | 576 #define TRACE_EVENT_FLOW_BEGIN2(category_group, name, id, arg1_name, arg1_val, \ |
562 arg2_name, arg2_val) \ | 577 arg2_name, arg2_val) \ |
563 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 578 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
564 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 579 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
565 arg1_name, arg1_val, arg2_name, arg2_val) | 580 arg1_name, arg1_val, arg2_name, arg2_val) |
566 #define TRACE_EVENT_COPY_FLOW_BEGIN0(category, name, id) \ | 581 #define TRACE_EVENT_COPY_FLOW_BEGIN0(category_group, name, id) \ |
567 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 582 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
568 category, name, id, TRACE_EVENT_FLAG_COPY) | 583 category_group, name, id, TRACE_EVENT_FLAG_COPY) |
569 #define TRACE_EVENT_COPY_FLOW_BEGIN1(category, name, id, arg1_name, arg1_val) \ | 584 #define TRACE_EVENT_COPY_FLOW_BEGIN1(category_group, name, id, arg1_name, \ |
| 585 arg1_val) \ |
570 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 586 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
571 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 587 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
572 arg1_name, arg1_val) | 588 arg1_name, arg1_val) |
573 #define TRACE_EVENT_COPY_FLOW_BEGIN2(category, name, id, arg1_name, arg1_val, \ | 589 #define TRACE_EVENT_COPY_FLOW_BEGIN2(category_group, name, id, arg1_name, \ |
574 arg2_name, arg2_val) \ | 590 arg1_val, arg2_name, arg2_val) \ |
575 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 591 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
576 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 592 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
577 arg1_name, arg1_val, arg2_name, arg2_val) | 593 arg1_name, arg1_val, arg2_name, arg2_val) |
578 | 594 |
579 // Records a single FLOW_STEP event for |step| immediately. If the category | 595 // Records a single FLOW_STEP event for |step| immediately. If the category |
580 // is not enabled, then this does nothing. The |name| and |id| must match the | 596 // is not enabled, then this does nothing. The |name| and |id| must match the |
581 // FLOW_BEGIN event above. The |step| param identifies this step within the | 597 // FLOW_BEGIN event above. The |step| param identifies this step within the |
582 // async event. This should be called at the beginning of the next phase of an | 598 // async event. This should be called at the beginning of the next phase of an |
583 // asynchronous operation. | 599 // asynchronous operation. |
584 #define TRACE_EVENT_FLOW_STEP0(category, name, id, step) \ | 600 #define TRACE_EVENT_FLOW_STEP0(category_group, name, id, step) \ |
585 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ | 601 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ |
586 category, name, id, TRACE_EVENT_FLAG_NONE, "step", step) | 602 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) |
587 #define TRACE_EVENT_FLOW_STEP1(category, name, id, step, \ | 603 #define TRACE_EVENT_FLOW_STEP1(category_group, name, id, step, \ |
588 arg1_name, arg1_val) \ | 604 arg1_name, arg1_val) \ |
589 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ | 605 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ |
590 category, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ | 606 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ |
591 arg1_name, arg1_val) | 607 arg1_name, arg1_val) |
592 #define TRACE_EVENT_COPY_FLOW_STEP0(category, name, id, step) \ | 608 #define TRACE_EVENT_COPY_FLOW_STEP0(category_group, name, id, step) \ |
593 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ | 609 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ |
594 category, name, id, TRACE_EVENT_FLAG_COPY, "step", step) | 610 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step) |
595 #define TRACE_EVENT_COPY_FLOW_STEP1(category, name, id, step, \ | 611 #define TRACE_EVENT_COPY_FLOW_STEP1(category_group, name, id, step, \ |
596 arg1_name, arg1_val) \ | 612 arg1_name, arg1_val) \ |
597 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ | 613 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ |
598 category, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \ | 614 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \ |
599 arg1_name, arg1_val) | 615 arg1_name, arg1_val) |
600 | 616 |
601 // Records a single FLOW_END event for "name" immediately. If the category | 617 // Records a single FLOW_END event for "name" immediately. If the category |
602 // is not enabled, then this does nothing. | 618 // is not enabled, then this does nothing. |
603 #define TRACE_EVENT_FLOW_END0(category, name, id) \ | 619 #define TRACE_EVENT_FLOW_END0(category_group, name, id) \ |
604 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 620 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
605 category, name, id, TRACE_EVENT_FLAG_NONE) | 621 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
606 #define TRACE_EVENT_FLOW_END1(category, name, id, arg1_name, arg1_val) \ | 622 #define TRACE_EVENT_FLOW_END1(category_group, name, id, arg1_name, arg1_val) \ |
607 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 623 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
608 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 624 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
609 #define TRACE_EVENT_FLOW_END2(category, name, id, arg1_name, arg1_val, \ | 625 #define TRACE_EVENT_FLOW_END2(category_group, name, id, arg1_name, arg1_val, \ |
610 arg2_name, arg2_val) \ | 626 arg2_name, arg2_val) \ |
611 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 627 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
612 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 628 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
613 arg1_name, arg1_val, arg2_name, arg2_val) | 629 arg1_name, arg1_val, arg2_name, arg2_val) |
614 #define TRACE_EVENT_COPY_FLOW_END0(category, name, id) \ | 630 #define TRACE_EVENT_COPY_FLOW_END0(category_group, name, id) \ |
615 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 631 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
616 category, name, id, TRACE_EVENT_FLAG_COPY) | 632 category_group, name, id, TRACE_EVENT_FLAG_COPY) |
617 #define TRACE_EVENT_COPY_FLOW_END1(category, name, id, arg1_name, arg1_val) \ | 633 #define TRACE_EVENT_COPY_FLOW_END1(category_group, name, id, arg1_name, \ |
| 634 arg1_val) \ |
618 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 635 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
619 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 636 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
620 arg1_name, arg1_val) | 637 arg1_name, arg1_val) |
621 #define TRACE_EVENT_COPY_FLOW_END2(category, name, id, arg1_name, arg1_val, \ | 638 #define TRACE_EVENT_COPY_FLOW_END2(category_group, name, id, arg1_name, \ |
622 arg2_name, arg2_val) \ | 639 arg1_val, arg2_name, arg2_val) \ |
623 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 640 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
624 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 641 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
625 arg1_name, arg1_val, arg2_name, arg2_val) | 642 arg1_name, arg1_val, arg2_name, arg2_val) |
626 | 643 |
627 // Macros to track the life time of arbitratry client objects. | 644 // Macros to track the life time of arbitratry client objects. |
628 // See also TraceTrackableObject. | 645 // See also TraceTrackableObject. |
629 #define TRACE_EVENT_OBJECT_CREATED_WITH_ID(category, name, id) \ | 646 #define TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group, name, id) \ |
630 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_CREATE_OBJECT, \ | 647 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_CREATE_OBJECT, \ |
631 category, name, id, TRACE_EVENT_FLAG_NONE) | 648 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
632 | 649 |
633 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category, name, id) \ | 650 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ |
634 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ | 651 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ |
635 category, name, id, TRACE_EVENT_FLAG_NONE) | 652 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
636 | 653 |
637 | 654 |
638 //////////////////////////////////////////////////////////////////////////////// | 655 //////////////////////////////////////////////////////////////////////////////// |
639 // Implementation specific tracing API definitions. | 656 // Implementation specific tracing API definitions. |
640 | 657 |
641 // Get a pointer to the enabled state of the given trace category. Only | 658 // Get a pointer to the enabled state of the given trace category. Only |
642 // long-lived literal strings should be given as the category name. The returned | 659 // long-lived literal strings should be given as the category group. The |
643 // pointer can be held permanently in a local static for example. If the | 660 // returned pointer can be held permanently in a local static for example. If |
644 // unsigned char is non-zero, tracing is enabled. If tracing is enabled, | 661 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled, |
645 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled | 662 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled |
646 // between the load of the tracing state and the call to | 663 // between the load of the tracing state and the call to |
647 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out | 664 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out |
648 // for best performance when tracing is disabled. | 665 // for best performance when tracing is disabled. |
649 // const unsigned char* | 666 // const unsigned char* |
650 // TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name) | 667 // TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(const char* category_group) |
651 #define TRACE_EVENT_API_GET_CATEGORY_ENABLED \ | 668 #define TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED \ |
652 base::debug::TraceLog::GetCategoryEnabled | 669 base::debug::TraceLog::GetCategoryGroupEnabled |
653 | 670 |
654 // Add a trace event to the platform tracing system. | 671 // Add a trace event to the platform tracing system. |
655 // void TRACE_EVENT_API_ADD_TRACE_EVENT( | 672 // void TRACE_EVENT_API_ADD_TRACE_EVENT( |
656 // char phase, | 673 // char phase, |
657 // const unsigned char* category_enabled, | 674 // const unsigned char* category_group_enabled, |
658 // const char* name, | 675 // const char* name, |
659 // unsigned long long id, | 676 // unsigned long long id, |
660 // int num_args, | 677 // int num_args, |
661 // const char** arg_names, | 678 // const char** arg_names, |
662 // const unsigned char* arg_types, | 679 // const unsigned char* arg_types, |
663 // const unsigned long long* arg_values, | 680 // const unsigned long long* arg_values, |
664 // unsigned char flags) | 681 // unsigned char flags) |
665 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ | 682 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ |
666 base::debug::TraceLog::GetInstance()->AddTraceEvent | 683 base::debug::TraceLog::GetInstance()->AddTraceEvent |
667 | 684 |
668 // Add a trace event to the platform tracing system. | 685 // Add a trace event to the platform tracing system. |
669 // void TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( | 686 // void TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_TIMESTAMP( |
670 // char phase, | 687 // char phase, |
671 // const unsigned char* category_enabled, | 688 // const unsigned char* category_group_enabled, |
672 // const char* name, | 689 // const char* name, |
673 // unsigned long long id, | 690 // unsigned long long id, |
674 // int thread_id, | 691 // int thread_id, |
675 // const TimeTicks& timestamp, | 692 // const TimeTicks& timestamp, |
676 // int num_args, | 693 // int num_args, |
677 // const char** arg_names, | 694 // const char** arg_names, |
678 // const unsigned char* arg_types, | 695 // const unsigned char* arg_types, |
679 // const unsigned long long* arg_values, | 696 // const unsigned long long* arg_values, |
680 // unsigned char flags) | 697 // unsigned char flags) |
681 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ | 698 #define TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP \ |
(...skipping 24 matching lines...) Expand all Loading... |
706 trace_event_unique_##a##b | 723 trace_event_unique_##a##b |
707 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ | 724 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ |
708 INTERNAL_TRACE_EVENT_UID3(a,b) | 725 INTERNAL_TRACE_EVENT_UID3(a,b) |
709 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ | 726 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ |
710 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) | 727 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) |
711 | 728 |
712 // Implementation detail: internal macro to create static category. | 729 // Implementation detail: internal macro to create static category. |
713 // No barriers are needed, because this code is designed to operate safely | 730 // No barriers are needed, because this code is designed to operate safely |
714 // even when the unsigned char* points to garbage data (which may be the case | 731 // even when the unsigned char* points to garbage data (which may be the case |
715 // on processors without cache coherency). | 732 // on processors without cache coherency). |
716 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ | 733 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group) \ |
717 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ | 734 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ |
718 const unsigned char* INTERNAL_TRACE_EVENT_UID(catstatic) = \ | 735 const unsigned char* INTERNAL_TRACE_EVENT_UID(catstatic) = \ |
719 reinterpret_cast<const unsigned char*>(TRACE_EVENT_API_ATOMIC_LOAD( \ | 736 reinterpret_cast<const unsigned char*>(TRACE_EVENT_API_ATOMIC_LOAD( \ |
720 INTERNAL_TRACE_EVENT_UID(atomic))); \ | 737 INTERNAL_TRACE_EVENT_UID(atomic))); \ |
721 if (!INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 738 if (!INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
722 INTERNAL_TRACE_EVENT_UID(catstatic) = \ | 739 INTERNAL_TRACE_EVENT_UID(catstatic) = \ |
723 TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); \ | 740 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); \ |
724 TRACE_EVENT_API_ATOMIC_STORE(INTERNAL_TRACE_EVENT_UID(atomic), \ | 741 TRACE_EVENT_API_ATOMIC_STORE(INTERNAL_TRACE_EVENT_UID(atomic), \ |
725 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( \ | 742 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( \ |
726 INTERNAL_TRACE_EVENT_UID(catstatic))); \ | 743 INTERNAL_TRACE_EVENT_UID(catstatic))); \ |
727 } | 744 } |
728 | 745 |
729 // Implementation detail: internal macro to create static category and add | 746 // Implementation detail: internal macro to create static category and add |
730 // event if the category is enabled. | 747 // event if the category is enabled. |
731 #define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \ | 748 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ |
732 do { \ | 749 do { \ |
733 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 750 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
734 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 751 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
735 trace_event_internal::AddTraceEvent( \ | 752 trace_event_internal::AddTraceEvent( \ |
736 phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \ | 753 phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \ |
737 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ | 754 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ |
738 } \ | 755 } \ |
739 } while (0) | 756 } while (0) |
740 | 757 |
741 // Implementation detail: internal macro to create static category and add begin | 758 // Implementation detail: internal macro to create static category and add begin |
742 // event if the category is enabled. Also adds the end event when the scope | 759 // event if the category is enabled. Also adds the end event when the scope |
743 // ends. | 760 // ends. |
744 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \ | 761 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ |
745 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 762 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
746 trace_event_internal::TraceEndOnScopeClose \ | 763 trace_event_internal::TraceEndOnScopeClose \ |
747 INTERNAL_TRACE_EVENT_UID(profileScope); \ | 764 INTERNAL_TRACE_EVENT_UID(profileScope); \ |
748 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 765 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
749 trace_event_internal::AddTraceEvent( \ | 766 trace_event_internal::AddTraceEvent( \ |
750 TRACE_EVENT_PHASE_BEGIN, \ | 767 TRACE_EVENT_PHASE_BEGIN, \ |
751 INTERNAL_TRACE_EVENT_UID(catstatic), \ | 768 INTERNAL_TRACE_EVENT_UID(catstatic), \ |
752 name, trace_event_internal::kNoEventId, \ | 769 name, trace_event_internal::kNoEventId, \ |
753 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ | 770 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ |
754 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ | 771 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ |
755 INTERNAL_TRACE_EVENT_UID(catstatic), name); \ | 772 INTERNAL_TRACE_EVENT_UID(catstatic), name); \ |
756 } | 773 } |
757 | 774 |
758 // Implementation detail: internal macro to create static category and add | 775 // Implementation detail: internal macro to create static category and add |
759 // event if the category is enabled. | 776 // event if the category is enabled. |
760 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \ | 777 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ |
761 ...) \ | 778 flags, ...) \ |
762 do { \ | 779 do { \ |
763 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 780 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
764 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 781 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
765 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 782 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
766 trace_event_internal::TraceID trace_event_trace_id( \ | 783 trace_event_internal::TraceID trace_event_trace_id( \ |
767 id, &trace_event_flags); \ | 784 id, &trace_event_flags); \ |
768 trace_event_internal::AddTraceEvent( \ | 785 trace_event_internal::AddTraceEvent( \ |
769 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | 786 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
770 name, trace_event_trace_id.data(), trace_event_flags, \ | 787 name, trace_event_trace_id.data(), trace_event_flags, \ |
771 ##__VA_ARGS__); \ | 788 ##__VA_ARGS__); \ |
772 } \ | 789 } \ |
773 } while (0) | 790 } while (0) |
774 | 791 |
775 // Implementation detail: internal macro to create static category and add | 792 // Implementation detail: internal macro to create static category and add |
776 // event if the category is enabled. | 793 // event if the category is enabled. |
777 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, category, \ | 794 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ |
778 name, id, thread_id, timestamp, flags, ...) \ | 795 category_group, name, id, thread_id, timestamp, flags, ...) \ |
779 do { \ | 796 do { \ |
780 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 797 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
781 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 798 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
782 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 799 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
783 trace_event_internal::TraceID trace_event_trace_id( \ | 800 trace_event_internal::TraceID trace_event_trace_id( \ |
784 id, &trace_event_flags); \ | 801 id, &trace_event_flags); \ |
785 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 802 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
786 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | 803 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
787 name, trace_event_trace_id.data(), \ | 804 name, trace_event_trace_id.data(), \ |
788 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 805 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ |
789 trace_event_flags, ##__VA_ARGS__); \ | 806 trace_event_flags, ##__VA_ARGS__); \ |
790 } \ | 807 } \ |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 } | 1007 } |
991 | 1008 |
992 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template | 1009 // These AddTraceEvent and AddTraceEventWithThreadIdAndTimestamp template |
993 // functions are defined here instead of in the macro, because the arg_values | 1010 // functions are defined here instead of in the macro, because the arg_values |
994 // could be temporary objects, such as std::string. In order to store | 1011 // could be temporary objects, such as std::string. In order to store |
995 // pointers to the internal c_str and pass through to the tracing API, | 1012 // pointers to the internal c_str and pass through to the tracing API, |
996 // the arg_values must live throughout these procedures. | 1013 // the arg_values must live throughout these procedures. |
997 | 1014 |
998 static inline void AddTraceEventWithThreadIdAndTimestamp( | 1015 static inline void AddTraceEventWithThreadIdAndTimestamp( |
999 char phase, | 1016 char phase, |
1000 const unsigned char* category_enabled, | 1017 const unsigned char* category_group_enabled, |
1001 const char* name, | 1018 const char* name, |
1002 unsigned long long id, | 1019 unsigned long long id, |
1003 int thread_id, | 1020 int thread_id, |
1004 const base::TimeTicks& timestamp, | 1021 const base::TimeTicks& timestamp, |
1005 unsigned char flags, | 1022 unsigned char flags, |
1006 const char* arg1_name, | 1023 const char* arg1_name, |
1007 scoped_ptr<base::debug::ConvertableToTraceFormat> arg1_val) { | 1024 scoped_ptr<base::debug::ConvertableToTraceFormat> arg1_val) { |
1008 const int num_args = 1; | 1025 const int num_args = 1; |
1009 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; | 1026 unsigned char arg_types[1] = { TRACE_VALUE_TYPE_CONVERTABLE }; |
1010 scoped_ptr<base::debug::ConvertableToTraceFormat> convertable_values[1]; | 1027 scoped_ptr<base::debug::ConvertableToTraceFormat> convertable_values[1]; |
1011 convertable_values[0].reset(arg1_val.release()); | 1028 convertable_values[0].reset(arg1_val.release()); |
1012 | 1029 |
1013 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1030 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1014 phase, category_enabled, name, id, thread_id, timestamp, | 1031 phase, category_group_enabled, name, id, thread_id, timestamp, |
1015 num_args, &arg1_name, arg_types, NULL, convertable_values, flags); | 1032 num_args, &arg1_name, arg_types, NULL, convertable_values, flags); |
1016 } | 1033 } |
1017 | 1034 |
1018 static inline void AddTraceEvent( | 1035 static inline void AddTraceEvent( |
1019 char phase, | 1036 char phase, |
1020 const unsigned char* category_enabled, | 1037 const unsigned char* category_group_enabled, |
1021 const char* name, | 1038 const char* name, |
1022 unsigned long long id, | 1039 unsigned long long id, |
1023 unsigned char flags, | 1040 unsigned char flags, |
1024 const char* arg1_name, | 1041 const char* arg1_name, |
1025 scoped_ptr<base::debug::ConvertableToTraceFormat> arg1_val) { | 1042 scoped_ptr<base::debug::ConvertableToTraceFormat> arg1_val) { |
1026 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1043 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1027 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1044 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); |
1028 AddTraceEventWithThreadIdAndTimestamp(phase, category_enabled, name, id, | 1045 AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, name, id, |
1029 thread_id, now, flags, arg1_name, | 1046 thread_id, now, flags, arg1_name, |
1030 arg1_val.Pass()); | 1047 arg1_val.Pass()); |
1031 } | 1048 } |
1032 | 1049 |
1033 static inline void AddTraceEventWithThreadIdAndTimestamp( | 1050 static inline void AddTraceEventWithThreadIdAndTimestamp( |
1034 char phase, | 1051 char phase, |
1035 const unsigned char* category_enabled, | 1052 const unsigned char* category_group_enabled, |
1036 const char* name, | 1053 const char* name, |
1037 unsigned long long id, | 1054 unsigned long long id, |
1038 int thread_id, | 1055 int thread_id, |
1039 const base::TimeTicks& timestamp, | 1056 const base::TimeTicks& timestamp, |
1040 unsigned char flags, | 1057 unsigned char flags, |
1041 const char* arg1_name, | 1058 const char* arg1_name, |
1042 scoped_ptr<base::debug::ConvertableToTraceFormat> arg1_val, | 1059 scoped_ptr<base::debug::ConvertableToTraceFormat> arg1_val, |
1043 const char* arg2_name, | 1060 const char* arg2_name, |
1044 scoped_ptr<base::debug::ConvertableToTraceFormat> arg2_val) { | 1061 scoped_ptr<base::debug::ConvertableToTraceFormat> arg2_val) { |
1045 const int num_args = 2; | 1062 const int num_args = 2; |
1046 unsigned char arg_types[2] = | 1063 unsigned char arg_types[2] = |
1047 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; | 1064 { TRACE_VALUE_TYPE_CONVERTABLE, TRACE_VALUE_TYPE_CONVERTABLE }; |
1048 scoped_ptr<base::debug::ConvertableToTraceFormat> convertable_values[2]; | 1065 scoped_ptr<base::debug::ConvertableToTraceFormat> convertable_values[2]; |
1049 convertable_values[0].reset(arg1_val.release()); | 1066 convertable_values[0].reset(arg1_val.release()); |
1050 convertable_values[1].reset(arg2_val.release()); | 1067 convertable_values[1].reset(arg2_val.release()); |
1051 | 1068 |
1052 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1069 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1053 phase, category_enabled, name, id, thread_id, timestamp, | 1070 phase, category_group_enabled, name, id, thread_id, timestamp, |
1054 num_args, &arg1_name, arg_types, NULL, convertable_values, flags); | 1071 num_args, &arg1_name, arg_types, NULL, convertable_values, flags); |
1055 } | 1072 } |
1056 | 1073 |
1057 static inline void AddTraceEvent( | 1074 static inline void AddTraceEvent( |
1058 char phase, | 1075 char phase, |
1059 const unsigned char* category_enabled, | 1076 const unsigned char* category_group_enabled, |
1060 const char* name, | 1077 const char* name, |
1061 unsigned long long id, | 1078 unsigned long long id, |
1062 unsigned char flags, | 1079 unsigned char flags, |
1063 const char* arg1_name, | 1080 const char* arg1_name, |
1064 scoped_ptr<base::debug::ConvertableToTraceFormat> arg1_val, | 1081 scoped_ptr<base::debug::ConvertableToTraceFormat> arg1_val, |
1065 const char* arg2_name, | 1082 const char* arg2_name, |
1066 scoped_ptr<base::debug::ConvertableToTraceFormat> arg2_val) { | 1083 scoped_ptr<base::debug::ConvertableToTraceFormat> arg2_val) { |
1067 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1084 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1068 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1085 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); |
1069 AddTraceEventWithThreadIdAndTimestamp(phase, category_enabled, name, id, | 1086 AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, name, id, |
1070 thread_id, now, flags, | 1087 thread_id, now, flags, |
1071 arg1_name, arg1_val.Pass(), | 1088 arg1_name, arg1_val.Pass(), |
1072 arg2_name, arg2_val.Pass()); | 1089 arg2_name, arg2_val.Pass()); |
1073 } | 1090 } |
1074 | 1091 |
1075 static inline void AddTraceEventWithThreadIdAndTimestamp( | 1092 static inline void AddTraceEventWithThreadIdAndTimestamp( |
1076 char phase, | 1093 char phase, |
1077 const unsigned char* category_enabled, | 1094 const unsigned char* category_group_enabled, |
1078 const char* name, | 1095 const char* name, |
1079 unsigned long long id, | 1096 unsigned long long id, |
1080 int thread_id, | 1097 int thread_id, |
1081 const base::TimeTicks& timestamp, | 1098 const base::TimeTicks& timestamp, |
1082 unsigned char flags) { | 1099 unsigned char flags) { |
1083 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1100 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1084 phase, category_enabled, name, id, thread_id, timestamp, | 1101 phase, category_group_enabled, name, id, thread_id, timestamp, |
1085 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); | 1102 kZeroNumArgs, NULL, NULL, NULL, NULL, flags); |
1086 } | 1103 } |
1087 | 1104 |
1088 static inline void AddTraceEvent(char phase, | 1105 static inline void AddTraceEvent(char phase, |
1089 const unsigned char* category_enabled, | 1106 const unsigned char* category_group_enabled, |
1090 const char* name, | 1107 const char* name, |
1091 unsigned long long id, | 1108 unsigned long long id, |
1092 unsigned char flags) { | 1109 unsigned char flags) { |
1093 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1110 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1094 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1111 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); |
1095 AddTraceEventWithThreadIdAndTimestamp(phase, category_enabled, name, id, | 1112 AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, name, id, |
1096 thread_id, now, flags); | 1113 thread_id, now, flags); |
1097 } | 1114 } |
1098 | 1115 |
1099 template<class ARG1_TYPE> | 1116 template<class ARG1_TYPE> |
1100 static inline void AddTraceEventWithThreadIdAndTimestamp( | 1117 static inline void AddTraceEventWithThreadIdAndTimestamp( |
1101 char phase, | 1118 char phase, |
1102 const unsigned char* category_enabled, | 1119 const unsigned char* category_group_enabled, |
1103 const char* name, | 1120 const char* name, |
1104 unsigned long long id, | 1121 unsigned long long id, |
1105 int thread_id, | 1122 int thread_id, |
1106 const base::TimeTicks& timestamp, | 1123 const base::TimeTicks& timestamp, |
1107 unsigned char flags, | 1124 unsigned char flags, |
1108 const char* arg1_name, | 1125 const char* arg1_name, |
1109 const ARG1_TYPE& arg1_val) { | 1126 const ARG1_TYPE& arg1_val) { |
1110 const int num_args = 1; | 1127 const int num_args = 1; |
1111 unsigned char arg_types[1]; | 1128 unsigned char arg_types[1]; |
1112 unsigned long long arg_values[1]; | 1129 unsigned long long arg_values[1]; |
1113 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1130 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
1114 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1131 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1115 phase, category_enabled, name, id, thread_id, timestamp, | 1132 phase, category_group_enabled, name, id, thread_id, timestamp, |
1116 num_args, &arg1_name, arg_types, arg_values, NULL, flags); | 1133 num_args, &arg1_name, arg_types, arg_values, NULL, flags); |
1117 } | 1134 } |
1118 | 1135 |
1119 template<class ARG1_TYPE> | 1136 template<class ARG1_TYPE> |
1120 static inline void AddTraceEvent(char phase, | 1137 static inline void AddTraceEvent(char phase, |
1121 const unsigned char* category_enabled, | 1138 const unsigned char* category_group_enabled, |
1122 const char* name, | 1139 const char* name, |
1123 unsigned long long id, | 1140 unsigned long long id, |
1124 unsigned char flags, | 1141 unsigned char flags, |
1125 const char* arg1_name, | 1142 const char* arg1_name, |
1126 const ARG1_TYPE& arg1_val) { | 1143 const ARG1_TYPE& arg1_val) { |
1127 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1144 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1128 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1145 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); |
1129 AddTraceEventWithThreadIdAndTimestamp(phase, category_enabled, name, id, | 1146 AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, name, id, |
1130 thread_id, now, flags, arg1_name, | 1147 thread_id, now, flags, arg1_name, |
1131 arg1_val); | 1148 arg1_val); |
1132 } | 1149 } |
1133 | 1150 |
1134 template<class ARG1_TYPE, class ARG2_TYPE> | 1151 template<class ARG1_TYPE, class ARG2_TYPE> |
1135 static inline void AddTraceEventWithThreadIdAndTimestamp( | 1152 static inline void AddTraceEventWithThreadIdAndTimestamp( |
1136 char phase, | 1153 char phase, |
1137 const unsigned char* category_enabled, | 1154 const unsigned char* category_group_enabled, |
1138 const char* name, | 1155 const char* name, |
1139 unsigned long long id, | 1156 unsigned long long id, |
1140 int thread_id, | 1157 int thread_id, |
1141 const base::TimeTicks& timestamp, | 1158 const base::TimeTicks& timestamp, |
1142 unsigned char flags, | 1159 unsigned char flags, |
1143 const char* arg1_name, | 1160 const char* arg1_name, |
1144 const ARG1_TYPE& arg1_val, | 1161 const ARG1_TYPE& arg1_val, |
1145 const char* arg2_name, | 1162 const char* arg2_name, |
1146 const ARG2_TYPE& arg2_val) { | 1163 const ARG2_TYPE& arg2_val) { |
1147 const int num_args = 2; | 1164 const int num_args = 2; |
1148 const char* arg_names[2] = { arg1_name, arg2_name }; | 1165 const char* arg_names[2] = { arg1_name, arg2_name }; |
1149 unsigned char arg_types[2]; | 1166 unsigned char arg_types[2]; |
1150 unsigned long long arg_values[2]; | 1167 unsigned long long arg_values[2]; |
1151 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); | 1168 SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
1152 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); | 1169 SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
1153 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( | 1170 TRACE_EVENT_API_ADD_TRACE_EVENT_WITH_THREAD_ID_AND_TIMESTAMP( |
1154 phase, category_enabled, name, id, thread_id, timestamp, | 1171 phase, category_group_enabled, name, id, thread_id, timestamp, |
1155 num_args, arg_names, arg_types, arg_values, NULL, flags); | 1172 num_args, arg_names, arg_types, arg_values, NULL, flags); |
1156 } | 1173 } |
1157 | 1174 |
1158 template<class ARG1_TYPE, class ARG2_TYPE> | 1175 template<class ARG1_TYPE, class ARG2_TYPE> |
1159 static inline void AddTraceEvent(char phase, | 1176 static inline void AddTraceEvent(char phase, |
1160 const unsigned char* category_enabled, | 1177 const unsigned char* category_group_enabled, |
1161 const char* name, | 1178 const char* name, |
1162 unsigned long long id, | 1179 unsigned long long id, |
1163 unsigned char flags, | 1180 unsigned char flags, |
1164 const char* arg1_name, | 1181 const char* arg1_name, |
1165 const ARG1_TYPE& arg1_val, | 1182 const ARG1_TYPE& arg1_val, |
1166 const char* arg2_name, | 1183 const char* arg2_name, |
1167 const ARG2_TYPE& arg2_val) { | 1184 const ARG2_TYPE& arg2_val) { |
1168 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); | 1185 int thread_id = static_cast<int>(base::PlatformThread::CurrentId()); |
1169 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); | 1186 base::TimeTicks now = base::TimeTicks::NowFromSystemTraceTime(); |
1170 AddTraceEventWithThreadIdAndTimestamp(phase, category_enabled, name, id, | 1187 AddTraceEventWithThreadIdAndTimestamp(phase, category_group_enabled, name, id, |
1171 thread_id, now, flags, arg1_name, | 1188 thread_id, now, flags, arg1_name, |
1172 arg1_val, arg2_name, arg2_val); | 1189 arg1_val, arg2_name, arg2_val); |
1173 } | 1190 } |
1174 | 1191 |
1175 // Used by TRACE_EVENTx macro. Do not use directly. | 1192 // Used by TRACE_EVENTx macro. Do not use directly. |
1176 class TRACE_EVENT_API_CLASS_EXPORT TraceEndOnScopeClose { | 1193 class TRACE_EVENT_API_CLASS_EXPORT TraceEndOnScopeClose { |
1177 public: | 1194 public: |
1178 // Note: members of data_ intentionally left uninitialized. See Initialize. | 1195 // Note: members of data_ intentionally left uninitialized. See Initialize. |
1179 TraceEndOnScopeClose() : p_data_(NULL) {} | 1196 TraceEndOnScopeClose() : p_data_(NULL) {} |
1180 ~TraceEndOnScopeClose() { | 1197 ~TraceEndOnScopeClose() { |
1181 if (p_data_) | 1198 if (p_data_) |
1182 AddEventIfEnabled(); | 1199 AddEventIfEnabled(); |
1183 } | 1200 } |
1184 | 1201 |
1185 void Initialize(const unsigned char* category_enabled, | 1202 void Initialize(const unsigned char* category_group_enabled, |
1186 const char* name) { | 1203 const char* name) { |
1187 data_.category_enabled = category_enabled; | 1204 data_.category_group_enabled = category_group_enabled; |
1188 data_.name = name; | 1205 data_.name = name; |
1189 p_data_ = &data_; | 1206 p_data_ = &data_; |
1190 } | 1207 } |
1191 | 1208 |
1192 private: | 1209 private: |
1193 // Add the end event if the category is still enabled. | 1210 // Add the end event if the category is still enabled. |
1194 void AddEventIfEnabled() { | 1211 void AddEventIfEnabled() { |
1195 // Only called when p_data_ is non-null. | 1212 // Only called when p_data_ is non-null. |
1196 if (*p_data_->category_enabled) { | 1213 if (*p_data_->category_group_enabled) { |
1197 TRACE_EVENT_API_ADD_TRACE_EVENT( | 1214 TRACE_EVENT_API_ADD_TRACE_EVENT( |
1198 TRACE_EVENT_PHASE_END, | 1215 TRACE_EVENT_PHASE_END, |
1199 p_data_->category_enabled, | 1216 p_data_->category_group_enabled, |
1200 p_data_->name, kNoEventId, | 1217 p_data_->name, kNoEventId, |
1201 kZeroNumArgs, NULL, NULL, NULL, NULL, | 1218 kZeroNumArgs, NULL, NULL, NULL, NULL, |
1202 TRACE_EVENT_FLAG_NONE); | 1219 TRACE_EVENT_FLAG_NONE); |
1203 } | 1220 } |
1204 } | 1221 } |
1205 | 1222 |
1206 // This Data struct workaround is to avoid initializing all the members | 1223 // This Data struct workaround is to avoid initializing all the members |
1207 // in Data during construction of this object, since this object is always | 1224 // in Data during construction of this object, since this object is always |
1208 // constructed, even when tracing is disabled. If the members of Data were | 1225 // constructed, even when tracing is disabled. If the members of Data were |
1209 // members of this class instead, compiler warnings occur about potential | 1226 // members of this class instead, compiler warnings occur about potential |
1210 // uninitialized accesses. | 1227 // uninitialized accesses. |
1211 struct Data { | 1228 struct Data { |
1212 const unsigned char* category_enabled; | 1229 const unsigned char* category_group_enabled; |
1213 const char* name; | 1230 const char* name; |
1214 }; | 1231 }; |
1215 Data* p_data_; | 1232 Data* p_data_; |
1216 Data data_; | 1233 Data data_; |
1217 }; | 1234 }; |
1218 | 1235 |
1219 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. | 1236 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. |
1220 class TRACE_EVENT_API_CLASS_EXPORT ScopedTrace { | 1237 class TRACE_EVENT_API_CLASS_EXPORT ScopedTrace { |
1221 public: | 1238 public: |
1222 ScopedTrace(TRACE_EVENT_API_ATOMIC_WORD* event_uid, const char* name); | 1239 ScopedTrace(TRACE_EVENT_API_ATOMIC_WORD* event_uid, const char* name); |
1223 ~ScopedTrace(); | 1240 ~ScopedTrace(); |
1224 | 1241 |
1225 private: | 1242 private: |
1226 const unsigned char* category_enabled_; | 1243 const unsigned char* category_group_enabled_; |
1227 const char* name_; | 1244 const char* name_; |
1228 }; | 1245 }; |
1229 | 1246 |
1230 // A support macro for TRACE_EVENT_BINARY_EFFICIENTx | 1247 // A support macro for TRACE_EVENT_BINARY_EFFICIENTx |
1231 #define INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED( \ | 1248 #define INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED( \ |
1232 category, name, ...) \ | 1249 category_group, name, ...) \ |
1233 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ | 1250 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ |
1234 trace_event_internal::ScopedTrace \ | 1251 trace_event_internal::ScopedTrace \ |
1235 INTERNAL_TRACE_EVENT_UID(profileScope)( \ | 1252 INTERNAL_TRACE_EVENT_UID(profileScope)( \ |
1236 &INTERNAL_TRACE_EVENT_UID(atomic), name); \ | 1253 &INTERNAL_TRACE_EVENT_UID(atomic), name); \ |
1237 | 1254 |
1238 // This macro generates less code then TRACE_EVENT0 but is also | 1255 // This macro generates less code then TRACE_EVENT0 but is also |
1239 // slower to execute when tracing is off. It should generally only be | 1256 // slower to execute when tracing is off. It should generally only be |
1240 // used with code that is seldom executed or conditionally executed | 1257 // used with code that is seldom executed or conditionally executed |
1241 // when debugging. | 1258 // when debugging. |
1242 #define TRACE_EVENT_BINARY_EFFICIENT0(category, name) \ | 1259 #define TRACE_EVENT_BINARY_EFFICIENT0(category_group, name) \ |
1243 INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED(category, name) | 1260 INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED(category_group, name) |
1244 | 1261 |
1245 } // namespace trace_event_internal | 1262 } // namespace trace_event_internal |
1246 | 1263 |
1247 namespace base { | 1264 namespace base { |
1248 namespace debug { | 1265 namespace debug { |
1249 | 1266 |
1250 template<typename IDType> class TraceScopedTrackableObject { | 1267 template<typename IDType> class TraceScopedTrackableObject { |
1251 public: | 1268 public: |
1252 TraceScopedTrackableObject(const char* category, const char* name, IDType id) | 1269 TraceScopedTrackableObject(const char* category_group, const char* name, |
1253 : category_(category), | 1270 IDType id) |
| 1271 : category_group_(category_group), |
1254 name_(name), | 1272 name_(name), |
1255 id_(id) { | 1273 id_(id) { |
1256 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_, name_, id_); | 1274 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_); |
1257 } | 1275 } |
1258 | 1276 |
1259 ~TraceScopedTrackableObject() { | 1277 ~TraceScopedTrackableObject() { |
1260 TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_, name_, id_); | 1278 TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group_, name_, id_); |
1261 } | 1279 } |
1262 | 1280 |
1263 private: | 1281 private: |
1264 const char* category_; | 1282 const char* category_group_; |
1265 const char* name_; | 1283 const char* name_; |
1266 IDType id_; | 1284 IDType id_; |
1267 | 1285 |
1268 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1286 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
1269 }; | 1287 }; |
1270 | 1288 |
1271 } // namespace debug | 1289 } // namespace debug |
1272 } // namespace base | 1290 } // namespace base |
1273 | 1291 |
1274 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ | 1292 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ |
OLD | NEW |