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

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

Issue 1923533004: Tracing pre-filtering (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added test Created 4 years, 7 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
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 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_
6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_
7 7
8 // This header file defines implementation details of how the trace macros in 8 // This header file defines implementation details of how the trace macros in
9 // trace_event_common.h collect and store trace events. Anything not 9 // trace_event_common.h collect and store trace events. Anything not
10 // implementation-specific should go in trace_event_common.h instead of here. 10 // implementation-specific should go in trace_event_common.h instead of here.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 trace_event_internal::TraceEventSamplingStateScope<bucket_number> \ 69 trace_event_internal::TraceEventSamplingStateScope<bucket_number> \
70 traceEventSamplingScope(category "\0" name); 70 traceEventSamplingScope(category "\0" name);
71 71
72 #define TRACE_EVENT_API_CURRENT_THREAD_ID \ 72 #define TRACE_EVENT_API_CURRENT_THREAD_ID \
73 static_cast<int>(base::PlatformThread::CurrentId()) 73 static_cast<int>(base::PlatformThread::CurrentId())
74 74
75 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ 75 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \
76 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ 76 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \
77 (base::trace_event::TraceLog::ENABLED_FOR_RECORDING | \ 77 (base::trace_event::TraceLog::ENABLED_FOR_RECORDING | \
78 base::trace_event::TraceLog::ENABLED_FOR_EVENT_CALLBACK | \ 78 base::trace_event::TraceLog::ENABLED_FOR_EVENT_CALLBACK | \
79 base::trace_event::TraceLog::ENABLED_FOR_ETW_EXPORT)) 79 base::trace_event::TraceLog::ENABLED_FOR_ETW_EXPORT | \
80 base::trace_event::TraceLog::ENABLED_FOR_FILTERING))
Primiano Tucci (use gerrit) 2016/05/31 15:41:23 Do you really need this or-ed here? I'd assume tha
oystein (OOO til 10th of July) 2016/08/01 13:39:49 I think that's right, 2) makes sense to me. The on
81
82 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_FILTERING_MODE( \
83 category_group_enabled) \
84 UNLIKELY(category_group_enabled& \
85 base::trace_event::TraceLog::ENABLED_FOR_FILTERING)
80 86
81 //////////////////////////////////////////////////////////////////////////////// 87 ////////////////////////////////////////////////////////////////////////////////
82 // Implementation specific tracing API definitions. 88 // Implementation specific tracing API definitions.
83 89
84 // Get a pointer to the enabled state of the given trace category. Only 90 // Get a pointer to the enabled state of the given trace category. Only
85 // long-lived literal strings should be given as the category group. The 91 // long-lived literal strings should be given as the category group. The
86 // returned pointer can be held permanently in a local static for example. If 92 // returned pointer can be held permanently in a local static for example. If
87 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled, 93 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled,
88 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled 94 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
89 // between the load of the tracing state and the call to 95 // between the load of the tracing state and the call to
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 ->AddTraceEventWithThreadIdAndTimestamp 184 ->AddTraceEventWithThreadIdAndTimestamp
179 185
180 // Set the duration field of a COMPLETE trace event. 186 // Set the duration field of a COMPLETE trace event.
181 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 187 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
182 // const unsigned char* category_group_enabled, 188 // const unsigned char* category_group_enabled,
183 // const char* name, 189 // const char* name,
184 // base::trace_event::TraceEventHandle id) 190 // base::trace_event::TraceEventHandle id)
185 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ 191 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \
186 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration 192 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration
187 193
194 // Call EndEvent on the filter for a filtered event.
195 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
196 // const unsigned char* category_group_enabled,
197 // const char* name,
198 // base::trace_event::TraceEventHandle id)
199 #define TRACE_EVENT_API_END_FILTERED_EVENT \
200 base::trace_event::TraceLog::GetInstance()->EndFilteredEvent
Primiano Tucci (use gerrit) 2016/05/27 17:47:06 Not sure you need this macro since you need this o
201
188 // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method 202 // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method
189 // on the convertable value will be called at flush time. 203 // on the convertable value will be called at flush time.
190 // TRACE_EVENT_API_ADD_METADATA_EVENT( 204 // TRACE_EVENT_API_ADD_METADATA_EVENT(
191 // const unsigned char* category_group_enabled, 205 // const unsigned char* category_group_enabled,
192 // const char* event_name, 206 // const char* event_name,
193 // const char* arg_name, 207 // const char* arg_name,
194 // std::unique_ptr<ConvertableToTraceFormat> arg_value) 208 // std::unique_ptr<ConvertableToTraceFormat> arg_value)
195 #define TRACE_EVENT_API_ADD_METADATA_EVENT \ 209 #define TRACE_EVENT_API_ADD_METADATA_EVENT \
196 trace_event_internal::AddMetadataEvent 210 trace_event_internal::AddMetadataEvent
197 211
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
967 arg_values, nullptr, TRACE_EVENT_FLAG_NONE); 981 arg_values, nullptr, TRACE_EVENT_FLAG_NONE);
968 } 982 }
969 983
970 // Used by TRACE_EVENTx macros. Do not use directly. 984 // Used by TRACE_EVENTx macros. Do not use directly.
971 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { 985 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer {
972 public: 986 public:
973 // Note: members of data_ intentionally left uninitialized. See Initialize. 987 // Note: members of data_ intentionally left uninitialized. See Initialize.
974 ScopedTracer() : p_data_(NULL) {} 988 ScopedTracer() : p_data_(NULL) {}
975 989
976 ~ScopedTracer() { 990 ~ScopedTracer() {
977 if (p_data_ && *data_.category_group_enabled) 991 if (p_data_ && *data_.category_group_enabled) {
978 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 992 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
979 data_.category_group_enabled, data_.name, data_.event_handle); 993 data_.category_group_enabled, data_.name, data_.event_handle);
994 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_FILTERING_MODE(
995 *data_.category_group_enabled)) {
996 TRACE_EVENT_API_END_FILTERED_EVENT(data_.category_group_enabled,
997 data_.name, data_.event_handle);
998 }
999 }
980 } 1000 }
981 1001
982 void Initialize(const unsigned char* category_group_enabled, 1002 void Initialize(const unsigned char* category_group_enabled,
983 const char* name, 1003 const char* name,
984 base::trace_event::TraceEventHandle event_handle) { 1004 base::trace_event::TraceEventHandle event_handle) {
985 data_.category_group_enabled = category_group_enabled; 1005 data_.category_group_enabled = category_group_enabled;
986 data_.name = name; 1006 data_.name = name;
987 data_.event_handle = event_handle; 1007 data_.event_handle = event_handle;
988 p_data_ = &data_; 1008 p_data_ = &data_;
989 } 1009 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1083 const char* name_; 1103 const char* name_;
1084 IDType id_; 1104 IDType id_;
1085 1105
1086 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1106 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1087 }; 1107 };
1088 1108
1089 } // namespace trace_event 1109 } // namespace trace_event
1090 } // namespace base 1110 } // namespace base
1091 1111
1092 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1112 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698