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 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
718 | 718 |
719 #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, snapshot) \ | 719 #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, snapshot) \ |
720 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \ | 720 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \ |
721 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\ | 721 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\ |
722 "snapshot", snapshot) | 722 "snapshot", snapshot) |
723 | 723 |
724 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ | 724 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ |
725 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ | 725 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ |
726 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) | 726 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) |
727 | 727 |
728 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE( \ | |
Xianzhu
2013/12/19 01:01:05
Nit: I think this macro should be prefixed with IN
haraken
2013/12/19 01:34:02
Done.
| |
729 category_group_enabled) \ | |
730 *INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ | |
731 (base::debug::TraceLog::ENABLED_FOR_RECORDING | \ | |
732 base::debug::TraceLog::ENABLED_FOR_EVENT_CALLBACK) | |
728 | 733 |
729 // Macro to efficiently determine if a given category group is enabled. | 734 // Macro to efficiently determine if a given category group is enabled. |
730 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ | 735 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ |
731 do { \ | 736 do { \ |
732 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 737 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
733 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 738 if (TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE( \ |
739 category_group_enabled)) { \ | |
734 *ret = true; \ | 740 *ret = true; \ |
735 } else { \ | 741 } else { \ |
736 *ret = false; \ | 742 *ret = false; \ |
737 } \ | 743 } \ |
738 } while (0) | 744 } while (0) |
739 | 745 |
740 // Macro to efficiently determine, through polling, if a new trace has begun. | 746 // Macro to efficiently determine, through polling, if a new trace has begun. |
741 #define TRACE_EVENT_IS_NEW_TRACE(ret) \ | 747 #define TRACE_EVENT_IS_NEW_TRACE(ret) \ |
742 do { \ | 748 do { \ |
743 static int INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = 0; \ | 749 static int INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = 0; \ |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 const unsigned char* INTERNAL_TRACE_EVENT_UID(category_group_enabled); \ | 869 const unsigned char* INTERNAL_TRACE_EVENT_UID(category_group_enabled); \ |
864 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES(category_group, \ | 870 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES(category_group, \ |
865 INTERNAL_TRACE_EVENT_UID(atomic), \ | 871 INTERNAL_TRACE_EVENT_UID(atomic), \ |
866 INTERNAL_TRACE_EVENT_UID(category_group_enabled)); | 872 INTERNAL_TRACE_EVENT_UID(category_group_enabled)); |
867 | 873 |
868 // Implementation detail: internal macro to create static category and add | 874 // Implementation detail: internal macro to create static category and add |
869 // event if the category is enabled. | 875 // event if the category is enabled. |
870 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ | 876 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ |
871 do { \ | 877 do { \ |
872 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 878 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
873 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 879 if (TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE( \ |
880 category_group_enabled)) { \ | |
874 trace_event_internal::AddTraceEvent( \ | 881 trace_event_internal::AddTraceEvent( \ |
875 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ | 882 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
876 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ | 883 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ |
877 } \ | 884 } \ |
878 } while (0) | 885 } while (0) |
879 | 886 |
880 // Implementation detail: internal macro to create static category and add begin | 887 // Implementation detail: internal macro to create static category and add begin |
881 // event if the category is enabled. Also adds the end event when the scope | 888 // event if the category is enabled. Also adds the end event when the scope |
882 // ends. | 889 // ends. |
883 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ | 890 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ |
884 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 891 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
885 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ | 892 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ |
886 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 893 if (TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE( \ |
894 category_group_enabled)) { \ | |
887 base::debug::TraceEventHandle h = trace_event_internal::AddTraceEvent( \ | 895 base::debug::TraceEventHandle h = trace_event_internal::AddTraceEvent( \ |
888 TRACE_EVENT_PHASE_COMPLETE, \ | 896 TRACE_EVENT_PHASE_COMPLETE, \ |
889 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 897 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
890 name, trace_event_internal::kNoEventId, \ | 898 name, trace_event_internal::kNoEventId, \ |
891 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ | 899 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ |
892 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ | 900 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ |
893 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ | 901 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ |
894 } | 902 } |
895 | 903 |
896 // Implementation detail: internal macro to create static category and add | 904 // Implementation detail: internal macro to create static category and add |
897 // event if the category is enabled. | 905 // event if the category is enabled. |
898 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ | 906 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ |
899 flags, ...) \ | 907 flags, ...) \ |
900 do { \ | 908 do { \ |
901 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 909 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
902 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 910 if (TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE( \ |
911 category_group_enabled)) { \ | |
903 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 912 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
904 trace_event_internal::TraceID trace_event_trace_id( \ | 913 trace_event_internal::TraceID trace_event_trace_id( \ |
905 id, &trace_event_flags); \ | 914 id, &trace_event_flags); \ |
906 trace_event_internal::AddTraceEvent( \ | 915 trace_event_internal::AddTraceEvent( \ |
907 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 916 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
908 name, trace_event_trace_id.data(), trace_event_flags, \ | 917 name, trace_event_trace_id.data(), trace_event_flags, \ |
909 ##__VA_ARGS__); \ | 918 ##__VA_ARGS__); \ |
910 } \ | 919 } \ |
911 } while (0) | 920 } while (0) |
912 | 921 |
913 // Implementation detail: internal macro to create static category and add | 922 // Implementation detail: internal macro to create static category and add |
914 // event if the category is enabled. | 923 // event if the category is enabled. |
915 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ | 924 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ |
916 category_group, name, id, thread_id, timestamp, flags, ...) \ | 925 category_group, name, id, thread_id, timestamp, flags, ...) \ |
917 do { \ | 926 do { \ |
918 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 927 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
919 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 928 if (TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE( \ |
929 category_group_enabled)) { \ | |
920 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 930 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
921 trace_event_internal::TraceID trace_event_trace_id( \ | 931 trace_event_internal::TraceID trace_event_trace_id( \ |
922 id, &trace_event_flags); \ | 932 id, &trace_event_flags); \ |
923 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 933 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
924 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 934 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
925 name, trace_event_trace_id.data(), \ | 935 name, trace_event_trace_id.data(), \ |
926 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 936 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ |
927 trace_event_flags, ##__VA_ARGS__); \ | 937 trace_event_flags, ##__VA_ARGS__); \ |
928 } \ | 938 } \ |
929 } while (0) | 939 } while (0) |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1488 const char* name_; | 1498 const char* name_; |
1489 IDType id_; | 1499 IDType id_; |
1490 | 1500 |
1491 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1501 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
1492 }; | 1502 }; |
1493 | 1503 |
1494 } // namespace debug | 1504 } // namespace debug |
1495 } // namespace base | 1505 } // namespace base |
1496 | 1506 |
1497 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ | 1507 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ |
OLD | NEW |