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

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

Issue 536503002: Add NESTABLE_ASYNC APIs to Tracing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 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 512 matching lines...) Expand 10 before | Expand all | Expand 10 after
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, NESTABLE_ASYNC_* 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
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 NESTABLE_ASYNC_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 NESTABLE_ASYNC_BEGIN event with the
649 // NESTABLE_ASYNC_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 NESTABLE_ASYNC_END event will be parsed as an instant event,
655 // and unmatched NESTABLE_ASYNC_BEGIN event will be parsed as an event, which
656 // starts at the time of the NESTABLE_ASYNC_BEGIN event and ends at the last
657 // NESTABLE_ASYNC_END event of that |id|.
658 //
659 // NESTABLE_ASYNC_* APIs are used to capture asynchronous operations which can
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_*.
662
663 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
664 arg1_val, arg2_name, arg2_val) \
665 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
666 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
667 arg2_name, arg2_val)
668 // Records a single NESTABLE_ASYNC_END event for "name" immediately.
669 // If the category is not enabled, then this does nothing.
670 #define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \
671 arg1_val, arg2_name, arg2_val) \
672 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
673 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
674 arg2_name, arg2_val)
675 // Records a single NESTABLE_ASYNC_INSTANT event for "name" immediately.
676 // If the category is not enabled, then this does nothing.
677 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(category_group, name, id, \
678 arg1_name, arg1_val, arg2_name, arg2_val) \
679 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
965 #define TRACE_EVENT_PHASE_ASYNC_END ('F') 1011 #define TRACE_EVENT_PHASE_ASYNC_END ('F')
966 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') 1012 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s')
967 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') 1013 #define TRACE_EVENT_PHASE_FLOW_STEP ('t')
968 #define TRACE_EVENT_PHASE_FLOW_END ('f') 1014 #define TRACE_EVENT_PHASE_FLOW_END ('f')
969 #define TRACE_EVENT_PHASE_METADATA ('M') 1015 #define TRACE_EVENT_PHASE_METADATA ('M')
970 #define TRACE_EVENT_PHASE_COUNTER ('C') 1016 #define TRACE_EVENT_PHASE_COUNTER ('C')
971 #define TRACE_EVENT_PHASE_SAMPLE ('P') 1017 #define TRACE_EVENT_PHASE_SAMPLE ('P')
972 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') 1018 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N')
973 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O') 1019 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O')
974 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') 1020 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D')
1021 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN ('b')
1022 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_END ('e')
1023 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT ('n')
dsinclair 2014/09/03 15:02:47 bikeshed: should these be ASYNC_NESTABLE (and the
xunjieli 2014/09/03 15:09:15 Done. ASYNC_NESTABLE does sound better. Thanks!
975 1024
976 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. 1025 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
977 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0)) 1026 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0))
978 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0)) 1027 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0))
979 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1)) 1028 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1))
980 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2)) 1029 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2))
981 #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned char>(1 << 3)) 1030 #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned char>(1 << 3))
982 1031
983 #define TRACE_EVENT_FLAG_SCOPE_MASK (static_cast<unsigned char>( \ 1032 #define TRACE_EVENT_FLAG_SCOPE_MASK (static_cast<unsigned char>( \
984 TRACE_EVENT_FLAG_SCOPE_OFFSET | (TRACE_EVENT_FLAG_SCOPE_OFFSET << 1))) 1033 TRACE_EVENT_FLAG_SCOPE_OFFSET | (TRACE_EVENT_FLAG_SCOPE_OFFSET << 1)))
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
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_ */
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698