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 is designed to give you trace_event macros without specifying | 5 // This header is designed to give you 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 // event to some other universe, you can copy-and-paste this file, | 7 // event to some other universe, you can copy-and-paste this file, |
8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for | 8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for |
9 // the target platform. The end result is that multiple libraries can funnel | 9 // the target platform. The end result is that multiple libraries can funnel |
10 // events through to a shared trace event collector. | 10 // events through to a shared trace event collector. |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 // Records the value of a counter called "name" immediately. Value | 342 // Records the value of a counter called "name" immediately. Value |
343 // must be representable as a 32 bit integer. | 343 // must be representable as a 32 bit integer. |
344 // - category and name strings must have application lifetime (statics or | 344 // - category and name strings must have application lifetime (statics or |
345 // literals). They may not include " chars. | 345 // literals). They may not include " chars. |
346 // - |id| is used to disambiguate counters with the same name. It must either | 346 // - |id| is used to disambiguate counters with the same name. It must either |
347 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits | 347 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits |
348 // will be xored with a hash of the process ID so that the same pointer on | 348 // will be xored with a hash of the process ID so that the same pointer on |
349 // two different processes will not collide. | 349 // two different processes will not collide. |
350 #define TRACE_COUNTER_ID1(category, name, id, value) \ | 350 #define TRACE_COUNTER_ID1(category, name, id, value) \ |
351 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 351 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
352 category, name, id, TRACE_EVENT_FLAG_HAS_ID, \ | 352 category, name, id, TRACE_EVENT_FLAG_NONE, \ |
353 "value", static_cast<int>(value)) | 353 "value", static_cast<int>(value)) |
354 #define TRACE_COPY_COUNTER_ID1(category, name, id, value) \ | 354 #define TRACE_COPY_COUNTER_ID1(category, name, id, value) \ |
355 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 355 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
356 category, name, id, TRACE_EVENT_FLAG_COPY | TRACE_EVENT_FLAG_HAS_ID, \ | 356 category, name, id, TRACE_EVENT_FLAG_COPY, \ |
357 "value", static_cast<int>(value)) | 357 "value", static_cast<int>(value)) |
358 | 358 |
359 // Records the values of a multi-parted counter called "name" immediately. | 359 // Records the values of a multi-parted counter called "name" immediately. |
360 // The UI will treat value1 and value2 as parts of a whole, displaying their | 360 // The UI will treat value1 and value2 as parts of a whole, displaying their |
361 // values as a stacked-bar chart. | 361 // values as a stacked-bar chart. |
362 // - category and name strings must have application lifetime (statics or | 362 // - category and name strings must have application lifetime (statics or |
363 // literals). They may not include " chars. | 363 // literals). They may not include " chars. |
364 // - |id| is used to disambiguate counters with the same name. It must either | 364 // - |id| is used to disambiguate counters with the same name. It must either |
365 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits | 365 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits |
366 // will be xored with a hash of the process ID so that the same pointer on | 366 // will be xored with a hash of the process ID so that the same pointer on |
367 // two different processes will not collide. | 367 // two different processes will not collide. |
368 #define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ | 368 #define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ |
369 value2_name, value2_val) \ | 369 value2_name, value2_val) \ |
370 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 370 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
371 category, name, id, TRACE_EVENT_FLAG_HAS_ID, \ | 371 category, name, id, TRACE_EVENT_FLAG_NONE, \ |
372 value1_name, static_cast<int>(value1_val), \ | 372 value1_name, static_cast<int>(value1_val), \ |
373 value2_name, static_cast<int>(value2_val)) | 373 value2_name, static_cast<int>(value2_val)) |
374 #define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \ | 374 #define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \ |
375 value2_name, value2_val) \ | 375 value2_name, value2_val) \ |
376 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 376 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
377 category, name, id, TRACE_EVENT_FLAG_COPY | TRACE_EVENT_FLAG_HAS_ID, \ | 377 category, name, id, TRACE_EVENT_FLAG_COPY, \ |
378 value1_name, static_cast<int>(value1_val), \ | 378 value1_name, static_cast<int>(value1_val), \ |
379 value2_name, static_cast<int>(value2_val)) | 379 value2_name, static_cast<int>(value2_val)) |
380 | 380 |
381 | 381 |
382 // Records a single START event called "name" immediately, with 0, 1 or 2 | 382 // Records a single START event called "name" immediately, with 0, 1 or 2 |
383 // associated arguments. If the category is not enabled, then this | 383 // associated arguments. If the category is not enabled, then this |
384 // does nothing. | 384 // does nothing. |
385 // - category and name strings must have application lifetime (statics or | 385 // - category and name strings must have application lifetime (statics or |
386 // literals). They may not include " chars. | 386 // literals). They may not include " chars. |
387 // - |id| is used to match the START event with the FINISH event. It must either | 387 // - |id| is used to match the START event with the FINISH event. It must either |
388 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits | 388 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits |
389 // will be xored with a hash of the process ID so that the same pointer on | 389 // will be xored with a hash of the process ID so that the same pointer on |
390 // two different processes will not collide. | 390 // two different processes will not collide. |
391 #define TRACE_EVENT_START0(category, name, id) \ | 391 #define TRACE_EVENT_START0(category, name, id) \ |
392 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ | 392 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
393 category, name, id, TRACE_EVENT_FLAG_HAS_ID) | 393 category, name, id, TRACE_EVENT_FLAG_NONE) |
394 #define TRACE_EVENT_START1(category, name, id, arg1_name, arg1_val) \ | 394 #define TRACE_EVENT_START1(category, name, id, arg1_name, arg1_val) \ |
395 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ | 395 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
396 category, name, id, TRACE_EVENT_FLAG_HAS_ID, arg1_name, arg1_val) | 396 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
397 #define TRACE_EVENT_START2(category, name, id, arg1_name, arg1_val, \ | 397 #define TRACE_EVENT_START2(category, name, id, arg1_name, arg1_val, \ |
398 arg2_name, arg2_val) \ | 398 arg2_name, arg2_val) \ |
399 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ | 399 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
400 category, name, id, TRACE_EVENT_FLAG_HAS_ID, \ | 400 category, name, id, TRACE_EVENT_FLAG_NONE, \ |
401 arg1_name, arg1_val, arg2_name, arg2_val) | 401 arg1_name, arg1_val, arg2_name, arg2_val) |
402 #define TRACE_EVENT_COPY_START0(category, name, id) \ | 402 #define TRACE_EVENT_COPY_START0(category, name, id) \ |
403 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ | 403 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
404 category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY) | 404 category, name, id, TRACE_EVENT_FLAG_COPY) |
405 #define TRACE_EVENT_COPY_START1(category, name, id, arg1_name, arg1_val) \ | 405 #define TRACE_EVENT_COPY_START1(category, name, id, arg1_name, arg1_val) \ |
406 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ | 406 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
407 category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ | 407 category, name, id, TRACE_EVENT_FLAG_COPY, \ |
408 arg1_name, arg1_val) | 408 arg1_name, arg1_val) |
409 #define TRACE_EVENT_COPY_START2(category, name, id, arg1_name, arg1_val, \ | 409 #define TRACE_EVENT_COPY_START2(category, name, id, arg1_name, arg1_val, \ |
410 arg2_name, arg2_val) \ | 410 arg2_name, arg2_val) \ |
411 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ | 411 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
412 category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ | 412 category, name, id, TRACE_EVENT_FLAG_COPY, \ |
413 arg1_name, arg1_val, arg2_name, arg2_val) | 413 arg1_name, arg1_val, arg2_name, arg2_val) |
414 | 414 |
415 // Records a single FINISH event for "name" immediately. If the category | 415 // Records a single FINISH event for "name" immediately. If the category |
416 // is not enabled, then this does nothing. | 416 // is not enabled, then this does nothing. |
417 #define TRACE_EVENT_FINISH0(category, name, id) \ | 417 #define TRACE_EVENT_FINISH0(category, name, id) \ |
418 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ | 418 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
419 category, name, id, TRACE_EVENT_FLAG_HAS_ID) | 419 category, name, id, TRACE_EVENT_FLAG_NONE) |
420 #define TRACE_EVENT_FINISH1(category, name, id, arg1_name, arg1_val) \ | 420 #define TRACE_EVENT_FINISH1(category, name, id, arg1_name, arg1_val) \ |
421 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ | 421 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
422 category, name, id, TRACE_EVENT_FLAG_HAS_ID, arg1_name, arg1_val) | 422 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
423 #define TRACE_EVENT_FINISH2(category, name, id, arg1_name, arg1_val, \ | 423 #define TRACE_EVENT_FINISH2(category, name, id, arg1_name, arg1_val, \ |
424 arg2_name, arg2_val) \ | 424 arg2_name, arg2_val) \ |
425 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ | 425 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
426 category, name, id, TRACE_EVENT_FLAG_HAS_ID, \ | 426 category, name, id, TRACE_EVENT_FLAG_NONE, \ |
427 arg1_name, arg1_val, arg2_name, arg2_val) | 427 arg1_name, arg1_val, arg2_name, arg2_val) |
428 #define TRACE_EVENT_COPY_FINISH0(category, name, id) \ | 428 #define TRACE_EVENT_COPY_FINISH0(category, name, id) \ |
429 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ | 429 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
430 category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY) | 430 category, name, id, TRACE_EVENT_FLAG_COPY) |
431 #define TRACE_EVENT_COPY_FINISH1(category, name, id, arg1_name, arg1_val) \ | 431 #define TRACE_EVENT_COPY_FINISH1(category, name, id, arg1_name, arg1_val) \ |
432 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ | 432 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
433 category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ | 433 category, name, id, TRACE_EVENT_FLAG_COPY, \ |
434 arg1_name, arg1_val) | 434 arg1_name, arg1_val) |
435 #define TRACE_EVENT_COPY_FINISH2(category, name, id, arg1_name, arg1_val, \ | 435 #define TRACE_EVENT_COPY_FINISH2(category, name, id, arg1_name, arg1_val, \ |
436 arg2_name, arg2_val) \ | 436 arg2_name, arg2_val) \ |
437 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ | 437 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
438 category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ | 438 category, name, id, TRACE_EVENT_FLAG_COPY, \ |
439 arg1_name, arg1_val, arg2_name, arg2_val) | 439 arg1_name, arg1_val, arg2_name, arg2_val) |
440 | 440 |
441 | 441 |
442 //////////////////////////////////////////////////////////////////////////////// | 442 //////////////////////////////////////////////////////////////////////////////// |
443 // Implementation specific tracing API definitions. | 443 // Implementation specific tracing API definitions. |
444 | 444 |
445 // Get a pointer to the enabled state of the given trace category. Only | 445 // Get a pointer to the enabled state of the given trace category. Only |
446 // long-lived literal strings should be given as the category name. The returned | 446 // long-lived literal strings should be given as the category name. The returned |
447 // pointer can be held permanently in a local static for example. If the | 447 // pointer can be held permanently in a local static for example. If the |
448 // unsigned char is non-zero, tracing is enabled. If tracing is enabled, | 448 // unsigned char is non-zero, tracing is enabled. If tracing is enabled, |
(...skipping 16 matching lines...) Expand all Loading... |
465 // int num_args, | 465 // int num_args, |
466 // const char** arg_names, | 466 // const char** arg_names, |
467 // const unsigned char* arg_types, | 467 // const unsigned char* arg_types, |
468 // const unsigned long long* arg_values, | 468 // const unsigned long long* arg_values, |
469 // int threshold_begin_id, | 469 // int threshold_begin_id, |
470 // long long threshold, | 470 // long long threshold, |
471 // unsigned char flags) | 471 // unsigned char flags) |
472 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ | 472 #define TRACE_EVENT_API_ADD_TRACE_EVENT \ |
473 base::debug::TraceLog::GetInstance()->AddTraceEvent | 473 base::debug::TraceLog::GetInstance()->AddTraceEvent |
474 | 474 |
475 // Mangle pointer with a hash so that if it occurs on more than one process, | |
476 // it will not collide in the trace data. Pass the returned value to | |
477 // TRACE_EVENT_API_ADD_TRACE_EVENT as the id parameter. | |
478 // unsigned long long TRACE_EVENT_API_GET_ID_FROM_POINTER(void* pointer) | |
479 #define TRACE_EVENT_API_GET_ID_FROM_POINTER \ | |
480 base::debug::TraceLog::GetInstance()->GetInterProcessID | |
481 | |
482 //////////////////////////////////////////////////////////////////////////////// | 475 //////////////////////////////////////////////////////////////////////////////// |
483 | 476 |
484 // Implementation detail: trace event macros create temporary variables | 477 // Implementation detail: trace event macros create temporary variables |
485 // to keep instrumentation overhead low. These macros give each temporary | 478 // to keep instrumentation overhead low. These macros give each temporary |
486 // variable a unique name based on the line number to prevent name collissions. | 479 // variable a unique name based on the line number to prevent name collissions. |
487 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ | 480 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ |
488 trace_event_unique_##a##b | 481 trace_event_unique_##a##b |
489 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ | 482 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ |
490 INTERNAL_TRACE_EVENT_UID3(a,b) | 483 INTERNAL_TRACE_EVENT_UID3(a,b) |
491 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ | 484 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 INTERNAL_TRACE_EVENT_UID(catstatic), name, \ | 540 INTERNAL_TRACE_EVENT_UID(catstatic), name, \ |
548 INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \ | 541 INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \ |
549 } | 542 } |
550 | 543 |
551 // Implementation detail: internal macro to create static category and add | 544 // Implementation detail: internal macro to create static category and add |
552 // event if the category is enabled. | 545 // event if the category is enabled. |
553 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \ | 546 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \ |
554 ...) \ | 547 ...) \ |
555 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 548 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
556 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 549 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
| 550 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
| 551 trace_event_internal::TraceID trace_event_trace_id( \ |
| 552 id, &trace_event_flags); \ |
557 trace_event_internal::AddTraceEvent( \ | 553 trace_event_internal::AddTraceEvent( \ |
558 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | 554 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
559 name, trace_event_internal::TraceID(id).data(), flags, \ | 555 name, trace_event_trace_id.data(), trace_event_flags, \ |
560 ##__VA_ARGS__); \ | 556 ##__VA_ARGS__); \ |
561 } | 557 } |
562 | 558 |
563 // Notes regarding the following definitions: | 559 // Notes regarding the following definitions: |
564 // New values can be added and propagated to third party libraries, but existing | 560 // New values can be added and propagated to third party libraries, but existing |
565 // definitions must never be changed, because third party libraries may use old | 561 // definitions must never be changed, because third party libraries may use old |
566 // definitions. | 562 // definitions. |
567 | 563 |
568 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. | 564 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
569 #define TRACE_EVENT_PHASE_BEGIN ('B') | 565 #define TRACE_EVENT_PHASE_BEGIN ('B') |
570 #define TRACE_EVENT_PHASE_END ('E') | 566 #define TRACE_EVENT_PHASE_END ('E') |
571 #define TRACE_EVENT_PHASE_INSTANT ('I') | 567 #define TRACE_EVENT_PHASE_INSTANT ('I') |
572 #define TRACE_EVENT_PHASE_START ('S') | 568 #define TRACE_EVENT_PHASE_START ('S') |
573 #define TRACE_EVENT_PHASE_FINISH ('F') | 569 #define TRACE_EVENT_PHASE_FINISH ('F') |
574 #define TRACE_EVENT_PHASE_METADATA ('M') | 570 #define TRACE_EVENT_PHASE_METADATA ('M') |
575 #define TRACE_EVENT_PHASE_COUNTER ('C') | 571 #define TRACE_EVENT_PHASE_COUNTER ('C') |
576 | 572 |
577 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. | 573 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. |
578 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0)) | 574 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0)) |
579 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1<<0)) | 575 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0)) |
580 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1<<1)) | 576 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1)) |
| 577 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2)) |
581 | 578 |
582 // Type values for identifying types in the TraceValue union. | 579 // Type values for identifying types in the TraceValue union. |
583 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) | 580 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) |
584 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) | 581 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) |
585 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3)) | 582 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3)) |
586 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4)) | 583 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4)) |
587 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5)) | 584 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5)) |
588 #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6)) | 585 #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6)) |
589 #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7)) | 586 #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7)) |
590 | 587 |
591 namespace trace_event_internal { | 588 namespace trace_event_internal { |
592 | 589 |
593 // Specify these values when the corresponding argument of AddTraceEvent is not | 590 // Specify these values when the corresponding argument of AddTraceEvent is not |
594 // used. | 591 // used. |
595 const int kZeroNumArgs = 0; | 592 const int kZeroNumArgs = 0; |
596 const int kNoThreshholdBeginId = -1; | 593 const int kNoThreshholdBeginId = -1; |
597 const long long kNoThresholdValue = 0; | 594 const long long kNoThresholdValue = 0; |
598 const unsigned long long kNoEventId = 0; | 595 const unsigned long long kNoEventId = 0; |
599 | 596 |
600 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers | 597 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers |
601 // are mangled with the Process ID so that they are unlikely to collide when the | 598 // are mangled with the Process ID so that they are unlikely to collide when the |
602 // same pointer is used on different processes. | 599 // same pointer is used on different processes. |
603 class TraceID { | 600 class TraceID { |
604 public: | 601 public: |
605 explicit TraceID(void* rhs) : | 602 explicit TraceID(const void* id, unsigned char* flags) : |
606 data_(TRACE_EVENT_API_GET_ID_FROM_POINTER(rhs)) {} | 603 data_(static_cast<unsigned long long>( |
607 explicit TraceID(unsigned long long rhs) : data_(rhs) {} | 604 reinterpret_cast<unsigned long>(id))) { |
608 explicit TraceID(unsigned long rhs) : data_(rhs) {} | 605 *flags |= TRACE_EVENT_FLAG_MANGLE_ID; |
609 explicit TraceID(unsigned int rhs) : data_(rhs) {} | 606 } |
610 explicit TraceID(unsigned short rhs) : data_(rhs) {} | 607 explicit TraceID(unsigned long long id, unsigned char* flags) : |
611 explicit TraceID(unsigned char rhs) : data_(rhs) {} | 608 data_(id) { (void)flags; } |
612 explicit TraceID(long long rhs) : | 609 explicit TraceID(unsigned long id, unsigned char* flags) : |
613 data_(static_cast<unsigned long long>(rhs)) {} | 610 data_(id) { (void)flags; } |
614 explicit TraceID(long rhs) : data_(static_cast<unsigned long long>(rhs)) {} | 611 explicit TraceID(unsigned int id, unsigned char* flags) : |
615 explicit TraceID(int rhs) : data_(static_cast<unsigned long long>(rhs)) {} | 612 data_(id) { (void)flags; } |
616 explicit TraceID(short rhs) : data_(static_cast<unsigned long long>(rhs)) {} | 613 explicit TraceID(unsigned short id, unsigned char* flags) : |
617 explicit TraceID(signed char rhs) : | 614 data_(id) { (void)flags; } |
618 data_(static_cast<unsigned long long>(rhs)) {} | 615 explicit TraceID(unsigned char id, unsigned char* flags) : |
| 616 data_(id) { (void)flags; } |
| 617 explicit TraceID(long long id, unsigned char* flags) : |
| 618 data_(static_cast<unsigned long long>(id)) { (void)flags; } |
| 619 explicit TraceID(long id, unsigned char* flags) : |
| 620 data_(static_cast<unsigned long long>(id)) { (void)flags; } |
| 621 explicit TraceID(int id, unsigned char* flags) : |
| 622 data_(static_cast<unsigned long long>(id)) { (void)flags; } |
| 623 explicit TraceID(short id, unsigned char* flags) : |
| 624 data_(static_cast<unsigned long long>(id)) { (void)flags; } |
| 625 explicit TraceID(signed char id, unsigned char* flags) : |
| 626 data_(static_cast<unsigned long long>(id)) { (void)flags; } |
619 | 627 |
620 unsigned long long data() const { return data_; } | 628 unsigned long long data() const { return data_; } |
621 | 629 |
622 private: | 630 private: |
623 unsigned long long data_; | 631 unsigned long long data_; |
624 }; | 632 }; |
625 | 633 |
626 // Simple union to store various types as unsigned long long. | 634 // Simple union to store various types as unsigned long long. |
627 union TraceValueUnion { | 635 union TraceValueUnion { |
628 bool as_bool; | 636 bool as_bool; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
815 const char* name; | 823 const char* name; |
816 int threshold_begin_id; | 824 int threshold_begin_id; |
817 }; | 825 }; |
818 Data* p_data_; | 826 Data* p_data_; |
819 Data data_; | 827 Data data_; |
820 }; | 828 }; |
821 | 829 |
822 } // namespace trace_event_internal | 830 } // namespace trace_event_internal |
823 | 831 |
824 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 832 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
OLD | NEW |