Chromium Code Reviews| 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. |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 186 // 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 |
| 187 // and resolving the category. | 187 // and resolving the category. |
| 188 | 188 |
| 189 #ifndef BASE_DEBUG_TRACE_EVENT_H_ | 189 #ifndef BASE_DEBUG_TRACE_EVENT_H_ |
| 190 #define BASE_DEBUG_TRACE_EVENT_H_ | 190 #define BASE_DEBUG_TRACE_EVENT_H_ |
| 191 | 191 |
| 192 #include <string> | 192 #include <string> |
| 193 | 193 |
| 194 #include "base/atomicops.h" | 194 #include "base/atomicops.h" |
| 195 #include "base/debug/trace_event_impl.h" | 195 #include "base/debug/trace_event_impl.h" |
| 196 #include "base/debug/trace_memory.h" | |
| 196 #include "build/build_config.h" | 197 #include "build/build_config.h" |
| 197 | 198 |
| 198 // By default, const char* argument values are assumed to have long-lived scope | 199 // By default, const char* argument values are assumed to have long-lived scope |
| 199 // and will not be copied. Use this macro to force a const char* to be copied. | 200 // and will not be copied. Use this macro to force a const char* to be copied. |
| 200 #define TRACE_STR_COPY(str) \ | 201 #define TRACE_STR_COPY(str) \ |
| 201 trace_event_internal::TraceStringWithCopy(str) | 202 trace_event_internal::TraceStringWithCopy(str) |
| 202 | 203 |
| 203 // This will mark the trace event as disabled by default. The user will need | 204 // This will mark the trace event as disabled by default. The user will need |
| 204 // to explicitly enable the event. | 205 // to explicitly enable the event. |
| 205 #define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name | 206 #define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name |
| 206 | 207 |
| 207 // By default, uint64 ID argument values are not mangled with the Process ID in | 208 // By default, uint64 ID argument values are not mangled with the Process ID in |
| 208 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. | 209 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. |
| 209 #define TRACE_ID_MANGLE(id) \ | 210 #define TRACE_ID_MANGLE(id) \ |
| 210 trace_event_internal::TraceID::ForceMangle(id) | 211 trace_event_internal::TraceID::ForceMangle(id) |
| 211 | 212 |
| 212 // By default, pointers are mangled with the Process ID in TRACE_EVENT_ASYNC | 213 // By default, pointers are mangled with the Process ID in TRACE_EVENT_ASYNC |
| 213 // macros. Use this macro to prevent Process ID mangling. | 214 // macros. Use this macro to prevent Process ID mangling. |
| 214 #define TRACE_ID_DONT_MANGLE(id) \ | 215 #define TRACE_ID_DONT_MANGLE(id) \ |
| 215 trace_event_internal::TraceID::DontMangle(id) | 216 trace_event_internal::TraceID::DontMangle(id) |
| 216 | 217 |
| 217 // Records a pair of begin and end events called "name" for the current | 218 // Records a pair of begin and end events called "name" for the current |
| 218 // scope, with 0, 1 or 2 associated arguments. If the category is not | 219 // scope, with 0, 1 or 2 associated arguments. If the category is not |
| 219 // enabled, then this does nothing. | 220 // enabled, then this does nothing. |
| 220 // - category and name strings must have application lifetime (statics or | 221 // - category and name strings must have application lifetime (statics or |
| 221 // literals). They may not include " chars. | 222 // literals). They may not include " chars. |
| 222 #define TRACE_EVENT0(category_group, name) \ | 223 #define TRACE_EVENT0(category_group, name) \ |
| 224 TRACE_MEMORY(category_group, name) \ | |
| 223 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name) | 225 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name) |
| 224 #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ | 226 #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ |
| 227 TRACE_MEMORY(category_group, name) \ | |
| 225 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val) | 228 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val) |
| 226 #define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \ | 229 #define TRACE_EVENT2( \ |
| 227 arg2_val) \ | 230 category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
| 228 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val, \ | 231 TRACE_MEMORY(category_group, name) \ |
|
nduca
2013/06/20 20:09:29
should we prefix these defines with INTERNAL_TRACE
James Cook
2013/06/29 00:02:42
Done.
| |
| 229 arg2_name, arg2_val) | 232 INTERNAL_TRACE_EVENT_ADD_SCOPED( \ |
| 233 category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) | |
| 230 | 234 |
| 231 // Same as TRACE_EVENT except that they are not included in official builds. | 235 // Same as TRACE_EVENT except that they are not included in official builds. |
| 232 #ifdef OFFICIAL_BUILD | 236 #ifdef OFFICIAL_BUILD |
| 233 #define UNSHIPPED_TRACE_EVENT0(category_group, name) (void)0 | 237 #define UNSHIPPED_TRACE_EVENT0(category_group, name) (void)0 |
| 234 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ | 238 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ |
| 235 (void)0 | 239 (void)0 |
| 236 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \ | 240 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \ |
| 237 arg2_name, arg2_val) (void)0 | 241 arg2_name, arg2_val) (void)0 |
| 238 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name, scope) (void)0 | 242 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name, scope) (void)0 |
| 239 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, scope, \ | 243 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, scope, \ |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 302 #define TRACE_EVENT_SAMPLE_STATE(thread_bucket, category, name) \ | 306 #define TRACE_EVENT_SAMPLE_STATE(thread_bucket, category, name) \ |
| 303 TRACE_EVENT_API_ATOMIC_STORE( \ | 307 TRACE_EVENT_API_ATOMIC_STORE( \ |
| 304 TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \ | 308 TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \ |
| 305 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(category "\0" name)); | 309 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>(category "\0" name)); |
| 306 | 310 |
| 307 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 | 311 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 |
| 308 // associated arguments. If the category is not enabled, then this | 312 // associated arguments. If the category is not enabled, then this |
| 309 // does nothing. | 313 // does nothing. |
| 310 // - category and name strings must have application lifetime (statics or | 314 // - category and name strings must have application lifetime (statics or |
| 311 // literals). They may not include " chars. | 315 // literals). They may not include " chars. |
| 312 #define TRACE_EVENT_BEGIN0(category_group, name) \ | 316 #define TRACE_EVENT_BEGIN0(category_group, name) \ |
|
nduca
2013/06/20 20:09:29
these need to go into memory too...
James Cook
2013/06/29 00:02:42
Are we guaranteed that each begin will get an end?
| |
| 313 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 317 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
| 314 category_group, name, TRACE_EVENT_FLAG_NONE) | 318 category_group, name, TRACE_EVENT_FLAG_NONE) |
| 315 #define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val) \ | 319 #define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val) \ |
| 316 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 320 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
| 317 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 321 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
| 318 #define TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_val, \ | 322 #define TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_val, \ |
| 319 arg2_name, arg2_val) \ | 323 arg2_name, arg2_val) \ |
| 320 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 324 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
| 321 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 325 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
| 322 arg2_name, arg2_val) | 326 arg2_name, arg2_val) |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 346 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \ | 350 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \ |
| 347 category_group, name, id, thread_id, timestamp) \ | 351 category_group, name, id, thread_id, timestamp) \ |
| 348 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 352 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 349 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ | 353 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ |
| 350 timestamp, TRACE_EVENT_FLAG_COPY) | 354 timestamp, TRACE_EVENT_FLAG_COPY) |
| 351 | 355 |
| 352 // Records a single END event for "name" immediately. If the category | 356 // Records a single END event for "name" immediately. If the category |
| 353 // is not enabled, then this does nothing. | 357 // is not enabled, then this does nothing. |
| 354 // - category and name strings must have application lifetime (statics or | 358 // - category and name strings must have application lifetime (statics or |
| 355 // literals). They may not include " chars. | 359 // literals). They may not include " chars. |
| 356 #define TRACE_EVENT_END0(category_group, name) \ | 360 #define TRACE_EVENT_END0(category_group, name) \ |
|
nduca
2013/06/20 20:09:29
so do these
| |
| 357 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 361 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 358 category_group, name, TRACE_EVENT_FLAG_NONE) | 362 category_group, name, TRACE_EVENT_FLAG_NONE) |
| 359 #define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val) \ | 363 #define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val) \ |
| 360 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 364 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 361 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 365 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
| 362 #define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, \ | 366 #define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, \ |
| 363 arg2_name, arg2_val) \ | 367 arg2_name, arg2_val) \ |
| 364 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 368 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 365 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 369 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
| 366 arg2_name, arg2_val) | 370 arg2_name, arg2_val) |
| 367 #define TRACE_EVENT_COPY_END0(category_group, name) \ | 371 #define TRACE_EVENT_COPY_END0(category_group, name) \ |
| 368 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 372 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 369 category_group, name, TRACE_EVENT_FLAG_COPY) | 373 category_group, name, TRACE_EVENT_FLAG_COPY) |
| 370 #define TRACE_EVENT_COPY_END1(category_group, name, arg1_name, arg1_val) \ | 374 #define TRACE_EVENT_COPY_END1(category_group, name, arg1_name, arg1_val) \ |
| 371 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 375 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 372 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 376 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
| 373 #define TRACE_EVENT_COPY_END2(category_group, name, arg1_name, arg1_val, \ | 377 #define TRACE_EVENT_COPY_END2(category_group, name, arg1_name, arg1_val, \ |
| 374 arg2_name, arg2_val) \ | 378 arg2_name, arg2_val) \ |
| 375 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 379 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
| 376 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 380 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
| 377 arg2_name, arg2_val) | 381 arg2_name, arg2_val) |
| 378 | 382 |
| 379 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided. | 383 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided. |
| 380 // - |id| is used to match the _BEGIN event with the _END event. | 384 // - |id| is used to match the _BEGIN event with the _END event. |
| 381 // Events are considered to match if their category_group, name and id values | 385 // Events are considered to match if their category_group, name and id values |
| 382 // all match. |id| must either be a pointer or an integer value up to 64 bits. | 386 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
| 383 // If it's a pointer, the bits will be xored with a hash of the process ID so | 387 // If it's a pointer, the bits will be xored with a hash of the process ID so |
| 384 // that the same pointer on two different processes will not collide. | 388 // that the same pointer on two different processes will not collide. |
| 385 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category_group, \ | 389 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category_group, \ |
| 386 name, id, thread_id, timestamp) \ | 390 name, id, thread_id, timestamp) \ |
|
nduca
2013/06/20 20:09:29
and these
| |
| 387 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 391 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 388 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ | 392 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ |
| 389 timestamp, TRACE_EVENT_FLAG_NONE) | 393 timestamp, TRACE_EVENT_FLAG_NONE) |
| 390 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \ | 394 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \ |
| 391 category_group, name, id, thread_id, timestamp) \ | 395 category_group, name, id, thread_id, timestamp) \ |
| 392 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 396 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 393 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ | 397 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ |
| 394 timestamp, TRACE_EVENT_FLAG_COPY) | 398 timestamp, TRACE_EVENT_FLAG_COPY) |
| 395 | 399 |
| 396 // Records the value of a counter called "name" immediately. Value | 400 // Records the value of a counter called "name" immediately. Value |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1467 const char* name_; | 1471 const char* name_; |
| 1468 IDType id_; | 1472 IDType id_; |
| 1469 | 1473 |
| 1470 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1474 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 1471 }; | 1475 }; |
| 1472 | 1476 |
| 1473 } // namespace debug | 1477 } // namespace debug |
| 1474 } // namespace base | 1478 } // namespace base |
| 1475 | 1479 |
| 1476 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ | 1480 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ |
| OLD | NEW |