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