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