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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 504 value1_name, static_cast<int>(value1_val), \ | 504 value1_name, static_cast<int>(value1_val), \ |
| 505 value2_name, static_cast<int>(value2_val)) | 505 value2_name, static_cast<int>(value2_val)) |
| 506 #define TRACE_COPY_COUNTER_ID2(category_group, name, id, value1_name, \ | 506 #define TRACE_COPY_COUNTER_ID2(category_group, name, id, value1_name, \ |
| 507 value1_val, value2_name, value2_val) \ | 507 value1_val, value2_name, value2_val) \ |
| 508 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 508 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
| 509 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ | 509 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
| 510 value1_name, static_cast<int>(value1_val), \ | 510 value1_name, static_cast<int>(value1_val), \ |
| 511 value2_name, static_cast<int>(value2_val)) | 511 value2_name, static_cast<int>(value2_val)) |
| 512 | 512 |
| 513 | 513 |
| 514 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 | 514 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 |
|
nduca
2014/09/08 22:21:13
I want to discourage people from using this api. p
xunjieli
2014/09/09 13:31:19
Done.
| |
| 515 // associated arguments. If the category is not enabled, then this | 515 // associated arguments. If the category is not enabled, then this |
| 516 // does nothing. | 516 // does nothing. |
| 517 // - category and name strings must have application lifetime (statics or | 517 // - category and name strings must have application lifetime (statics or |
| 518 // literals). They may not include " chars. | 518 // literals). They may not include " chars. |
| 519 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC | 519 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC |
| 520 // events are considered to match if their category_group, name and id values | 520 // events are considered to match if their category_group, name and id values |
| 521 // all match. |id| must either be a pointer or an integer value up to 64 bits. | 521 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
| 522 // If it's a pointer, the bits will be xored with a hash of the process ID so | 522 // If it's a pointer, the bits will be xored with a hash of the process ID so |
| 523 // that the same pointer on two different processes will not collide. | 523 // that the same pointer on two different processes will not collide. |
| 524 // | 524 // |
| 525 // An asynchronous operation can consist of multiple phases. The first phase is | 525 // An asynchronous operation can consist of multiple phases. The first phase is |
| 526 // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the | 526 // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the |
| 527 // ASYNC_STEP_INTO or ASYNC_STEP_PAST macros. The ASYNC_STEP_INTO macro will | 527 // ASYNC_STEP_INTO or ASYNC_STEP_PAST macros. The ASYNC_STEP_INTO macro will |
| 528 // annotate the block following the call. The ASYNC_STEP_PAST macro will | 528 // annotate the block following the call. The ASYNC_STEP_PAST macro will |
| 529 // annotate the block prior to the call. Note that any particular event must use | 529 // annotate the block prior to the call. Note that any particular event must use |
| 530 // only STEP_INTO or STEP_PAST macros; they can not mix and match. When the | 530 // only STEP_INTO or STEP_PAST macros; they can not mix and match. When the |
| 531 // operation completes, call ASYNC_END. | 531 // operation completes, call ASYNC_END. |
| 532 // | 532 // |
| 533 // ASYNC_STEP_INTO and ASYNC_STEP_PAST can only represent one level of phases, | |
| 534 // between a pair of ASYNC_BEGIN and ASYNC_END. If an asynchronous operation | |
| 535 // has multiple levels of nesting phases/events, ASYNC_NESTABLE_* APIs can be | |
| 536 // used. | |
| 537 // | |
| 533 // An ASYNC trace typically occurs on a single thread (if not, they will only be | 538 // An ASYNC trace typically occurs on a single thread (if not, they will only be |
| 534 // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that | 539 // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that |
| 535 // operation must use the same |name| and |id|. Each step can have its own | 540 // operation must use the same |name| and |id|. Each step can have its own |
| 536 // args. | 541 // args. |
| 537 #define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \ | 542 #define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \ |
| 538 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 543 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
| 539 category_group, name, id, TRACE_EVENT_FLAG_NONE) | 544 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
| 540 #define TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ | 545 #define TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ |
| 541 arg1_val) \ | 546 arg1_val) \ |
| 542 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 547 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 627 arg1_name, arg1_val, arg2_name, arg2_val) | 632 arg1_name, arg1_val, arg2_name, arg2_val) |
| 628 | 633 |
| 629 // Similar to TRACE_EVENT_ASYNC_ENDx but with a custom |at| timestamp provided. | 634 // Similar to TRACE_EVENT_ASYNC_ENDx but with a custom |at| timestamp provided. |
| 630 #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(category_group, \ | 635 #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(category_group, \ |
| 631 name, id, timestamp) \ | 636 name, id, timestamp) \ |
| 632 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 637 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 633 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \ | 638 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \ |
| 634 static_cast<int>(base::PlatformThread::CurrentId()), \ | 639 static_cast<int>(base::PlatformThread::CurrentId()), \ |
| 635 timestamp, TRACE_EVENT_FLAG_NONE) | 640 timestamp, TRACE_EVENT_FLAG_NONE) |
| 636 | 641 |
| 642 | |
| 643 // Records a single ASYNC_NESTABLE_BEGIN event called "name" immediately, with 2 | |
| 644 // associated arguments. If the category is not enabled, then this | |
| 645 // does nothing. | |
| 646 // - category and name strings must have application lifetime (statics or | |
| 647 // literals). They may not include " chars. | |
| 648 // - |id| is used to match the ASYNC_NESTABLE_BEGIN event with the | |
| 649 // ASYNC_NESTABLE_END event. Events are considered to match if their | |
| 650 // category_group, name and id values all match. |id| must either be a | |
| 651 // pointer or an integer value up to 64 bits. If it's a pointer, the bits | |
| 652 // will be xored with a hash of the process ID so that the same pointer on two | |
| 653 // different processes will not collide. | |
| 654 // - Unmatched ASYNC_NESTABLE_END event will be parsed as an instant event, | |
|
nduca
2014/09/08 22:21:13
Your docstrings here look like they're explaining
xunjieli
2014/09/09 13:31:18
Done.
| |
| 655 // and unmatched ASYNC_NESTABLE_BEGIN event will be parsed as an event, which | |
| 656 // starts at the time of the ASYNC_NESTABLE_BEGIN event and ends at the last | |
| 657 // ASYNC_NESTABLE_END event of that |id|. | |
| 658 // | |
| 659 // ASYNC_NESTABLE_* APIs are used to capture asynchronous operations which can | |
|
nduca
2014/09/08 22:21:13
this seems like its better up top of this comment
xunjieli
2014/09/09 13:31:19
Done. Thanks for the detailed explanation!
| |
| 660 // have multiple levels of nested events/phases. If an asynchronous operation | |
| 661 // only has one level of sub-events, one should consider using ASYNC_STEP_*. | |
|
nduca
2014/09/08 22:21:13
I don't think we're intending people to point at a
xunjieli
2014/09/09 13:31:19
Done.
| |
| 662 | |
| 663 #define TRACE_EVENT_ASYNC_NESTABLE_BEGIN2(category_group, name, id, arg1_name, \ | |
| 664 arg1_val, arg2_name, arg2_val) \ | |
| 665 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_NESTABLE_BEGIN, \ | |
| 666 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | |
| 667 arg2_name, arg2_val) | |
| 668 // Records a single ASYNC_NESTABLE_END event for "name" immediately. | |
| 669 // If the category is not enabled, then this does nothing. | |
| 670 #define TRACE_EVENT_ASYNC_NESTABLE_END2(category_group, name, id, arg1_name, \ | |
| 671 arg1_val, arg2_name, arg2_val) \ | |
| 672 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_NESTABLE_END, \ | |
| 673 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | |
| 674 arg2_name, arg2_val) | |
| 675 // Records a single ASYNC_NESTABLE_INSTANT event for "name" immediately. | |
| 676 // If the category is not enabled, then this does nothing. | |
| 677 #define TRACE_EVENT_ASYNC_NESTABLE_INSTANT2(category_group, name, id, \ | |
| 678 arg1_name, arg1_val, arg2_name, arg2_val) \ | |
| 679 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_NESTABLE_INSTANT, \ | |
| 680 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | |
| 681 arg2_name, arg2_val) | |
| 682 | |
| 637 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 | 683 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 |
| 638 // associated arguments. If the category is not enabled, then this | 684 // associated arguments. If the category is not enabled, then this |
| 639 // does nothing. | 685 // does nothing. |
| 640 // - category and name strings must have application lifetime (statics or | 686 // - category and name strings must have application lifetime (statics or |
| 641 // literals). They may not include " chars. | 687 // literals). They may not include " chars. |
| 642 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW | 688 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW |
| 643 // events are considered to match if their category_group, name and id values | 689 // events are considered to match if their category_group, name and id values |
| 644 // all match. |id| must either be a pointer or an integer value up to 64 bits. | 690 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
| 645 // If it's a pointer, the bits will be xored with a hash of the process ID so | 691 // If it's a pointer, the bits will be xored with a hash of the process ID so |
| 646 // that the same pointer on two different processes will not collide. | 692 // that the same pointer on two different processes will not collide. |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 956 | 1002 |
| 957 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. | 1003 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
| 958 #define TRACE_EVENT_PHASE_BEGIN ('B') | 1004 #define TRACE_EVENT_PHASE_BEGIN ('B') |
| 959 #define TRACE_EVENT_PHASE_END ('E') | 1005 #define TRACE_EVENT_PHASE_END ('E') |
| 960 #define TRACE_EVENT_PHASE_COMPLETE ('X') | 1006 #define TRACE_EVENT_PHASE_COMPLETE ('X') |
| 961 #define TRACE_EVENT_PHASE_INSTANT ('I') | 1007 #define TRACE_EVENT_PHASE_INSTANT ('I') |
| 962 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') | 1008 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') |
| 963 #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T') | 1009 #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T') |
| 964 #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p') | 1010 #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p') |
| 965 #define TRACE_EVENT_PHASE_ASYNC_END ('F') | 1011 #define TRACE_EVENT_PHASE_ASYNC_END ('F') |
| 1012 #define TRACE_EVENT_PHASE_ASYNC_NESTABLE_BEGIN ('b') | |
| 1013 #define TRACE_EVENT_PHASE_ASYNC_NESTABLE_END ('e') | |
| 1014 #define TRACE_EVENT_PHASE_ASYNC_NESTABLE_INSTANT ('n') | |
| 966 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') | 1015 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') |
| 967 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') | 1016 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') |
| 968 #define TRACE_EVENT_PHASE_FLOW_END ('f') | 1017 #define TRACE_EVENT_PHASE_FLOW_END ('f') |
| 969 #define TRACE_EVENT_PHASE_METADATA ('M') | 1018 #define TRACE_EVENT_PHASE_METADATA ('M') |
| 970 #define TRACE_EVENT_PHASE_COUNTER ('C') | 1019 #define TRACE_EVENT_PHASE_COUNTER ('C') |
| 971 #define TRACE_EVENT_PHASE_SAMPLE ('P') | 1020 #define TRACE_EVENT_PHASE_SAMPLE ('P') |
| 972 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') | 1021 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') |
| 973 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O') | 1022 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O') |
| 974 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') | 1023 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') |
| 975 | 1024 |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1526 const char* name_; | 1575 const char* name_; |
| 1527 IDType id_; | 1576 IDType id_; |
| 1528 | 1577 |
| 1529 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1578 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 1530 }; | 1579 }; |
| 1531 | 1580 |
| 1532 } // namespace debug | 1581 } // namespace debug |
| 1533 } // namespace base | 1582 } // namespace base |
| 1534 | 1583 |
| 1535 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ | 1584 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ |
| OLD | NEW |