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 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 728 |
729 // Macro to efficiently determine if a given category group is enabled. | 729 // Macro to efficiently determine if a given category group is enabled. |
730 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ | 730 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ |
731 do { \ | 731 do { \ |
732 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 732 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
733 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 733 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ |
734 base::debug::TraceLog::ENABLED_FOR_RECORDING) { \ | |
haraken
2013/12/19 00:19:14
I'll land the same fix to TraceEvent.h in Blink.
Xianzhu
2013/12/19 00:39:57
We also need to check ENABLED_FOR_EVENT_CALLBACK h
haraken
2013/12/19 00:53:59
Done.
| |
734 *ret = true; \ | 735 *ret = true; \ |
735 } else { \ | 736 } else { \ |
736 *ret = false; \ | 737 *ret = false; \ |
737 } \ | 738 } \ |
738 } while (0) | 739 } while (0) |
739 | 740 |
740 // Macro to efficiently determine, through polling, if a new trace has begun. | 741 // Macro to efficiently determine, through polling, if a new trace has begun. |
741 #define TRACE_EVENT_IS_NEW_TRACE(ret) \ | 742 #define TRACE_EVENT_IS_NEW_TRACE(ret) \ |
742 do { \ | 743 do { \ |
743 static int INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = 0; \ | 744 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); \ | 864 const unsigned char* INTERNAL_TRACE_EVENT_UID(category_group_enabled); \ |
864 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES(category_group, \ | 865 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO_CUSTOM_VARIABLES(category_group, \ |
865 INTERNAL_TRACE_EVENT_UID(atomic), \ | 866 INTERNAL_TRACE_EVENT_UID(atomic), \ |
866 INTERNAL_TRACE_EVENT_UID(category_group_enabled)); | 867 INTERNAL_TRACE_EVENT_UID(category_group_enabled)); |
867 | 868 |
868 // Implementation detail: internal macro to create static category and add | 869 // Implementation detail: internal macro to create static category and add |
869 // event if the category is enabled. | 870 // event if the category is enabled. |
870 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ | 871 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ |
871 do { \ | 872 do { \ |
872 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 873 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
873 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 874 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ |
875 base::debug::TraceLog::ENABLED_FOR_RECORDING) { \ | |
874 trace_event_internal::AddTraceEvent( \ | 876 trace_event_internal::AddTraceEvent( \ |
875 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ | 877 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
876 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ | 878 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ |
877 } \ | 879 } \ |
878 } while (0) | 880 } while (0) |
879 | 881 |
880 // Implementation detail: internal macro to create static category and add begin | 882 // 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 | 883 // event if the category is enabled. Also adds the end event when the scope |
882 // ends. | 884 // ends. |
883 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ | 885 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ |
884 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 886 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
885 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ | 887 trace_event_internal::ScopedTracer INTERNAL_TRACE_EVENT_UID(tracer); \ |
886 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 888 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ |
889 base::debug::TraceLog::ENABLED_FOR_RECORDING) { \ | |
887 base::debug::TraceEventHandle h = trace_event_internal::AddTraceEvent( \ | 890 base::debug::TraceEventHandle h = trace_event_internal::AddTraceEvent( \ |
888 TRACE_EVENT_PHASE_COMPLETE, \ | 891 TRACE_EVENT_PHASE_COMPLETE, \ |
889 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 892 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
890 name, trace_event_internal::kNoEventId, \ | 893 name, trace_event_internal::kNoEventId, \ |
891 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ | 894 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ |
892 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ | 895 INTERNAL_TRACE_EVENT_UID(tracer).Initialize( \ |
893 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ | 896 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, h); \ |
894 } | 897 } |
895 | 898 |
896 // Implementation detail: internal macro to create static category and add | 899 // Implementation detail: internal macro to create static category and add |
897 // event if the category is enabled. | 900 // event if the category is enabled. |
898 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ | 901 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ |
899 flags, ...) \ | 902 flags, ...) \ |
900 do { \ | 903 do { \ |
901 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 904 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
902 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 905 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ |
906 base::debug::TraceLog::ENABLED_FOR_RECORDING) { \ | |
903 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 907 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
904 trace_event_internal::TraceID trace_event_trace_id( \ | 908 trace_event_internal::TraceID trace_event_trace_id( \ |
905 id, &trace_event_flags); \ | 909 id, &trace_event_flags); \ |
906 trace_event_internal::AddTraceEvent( \ | 910 trace_event_internal::AddTraceEvent( \ |
907 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 911 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
908 name, trace_event_trace_id.data(), trace_event_flags, \ | 912 name, trace_event_trace_id.data(), trace_event_flags, \ |
909 ##__VA_ARGS__); \ | 913 ##__VA_ARGS__); \ |
910 } \ | 914 } \ |
911 } while (0) | 915 } while (0) |
912 | 916 |
913 // Implementation detail: internal macro to create static category and add | 917 // Implementation detail: internal macro to create static category and add |
914 // event if the category is enabled. | 918 // event if the category is enabled. |
915 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ | 919 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ |
916 category_group, name, id, thread_id, timestamp, flags, ...) \ | 920 category_group, name, id, thread_id, timestamp, flags, ...) \ |
917 do { \ | 921 do { \ |
918 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 922 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
919 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled)) { \ | 923 if (*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ |
924 base::debug::TraceLog::ENABLED_FOR_RECORDING) { \ | |
920 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 925 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
921 trace_event_internal::TraceID trace_event_trace_id( \ | 926 trace_event_internal::TraceID trace_event_trace_id( \ |
922 id, &trace_event_flags); \ | 927 id, &trace_event_flags); \ |
923 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 928 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
924 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 929 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
925 name, trace_event_trace_id.data(), \ | 930 name, trace_event_trace_id.data(), \ |
926 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 931 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ |
927 trace_event_flags, ##__VA_ARGS__); \ | 932 trace_event_flags, ##__VA_ARGS__); \ |
928 } \ | 933 } \ |
929 } while (0) | 934 } while (0) |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1488 const char* name_; | 1493 const char* name_; |
1489 IDType id_; | 1494 IDType id_; |
1490 | 1495 |
1491 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1496 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
1492 }; | 1497 }; |
1493 | 1498 |
1494 } // namespace debug | 1499 } // namespace debug |
1495 } // namespace base | 1500 } // namespace base |
1496 | 1501 |
1497 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ | 1502 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ |
OLD | NEW |