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

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: Review fixes Created 4 years, 4 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 80
81 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_FILTERING_MODE( \
82 category_group_enabled) \
83 UNLIKELY(category_group_enabled& \
84 base::trace_event::TraceLog::ENABLED_FOR_FILTERING)
shatch 2016/08/15 21:25:47 nit: indentation seems off here
oystein (OOO til 10th of July) 2016/08/16 22:17:52 Yeah it looks weird, but I think it's actually cor
85
81 //////////////////////////////////////////////////////////////////////////////// 86 ////////////////////////////////////////////////////////////////////////////////
82 // Implementation specific tracing API definitions. 87 // Implementation specific tracing API definitions.
83 88
84 // Get a pointer to the enabled state of the given trace category. Only 89 // 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 90 // 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 91 // 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, 92 // 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 93 // 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 94 // between the load of the tracing state and the call to
90 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out 95 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 ->AddTraceEventWithThreadIdAndTimestamp 183 ->AddTraceEventWithThreadIdAndTimestamp
179 184
180 // Set the duration field of a COMPLETE trace event. 185 // Set the duration field of a COMPLETE trace event.
181 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 186 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
182 // const unsigned char* category_group_enabled, 187 // const unsigned char* category_group_enabled,
183 // const char* name, 188 // const char* name,
184 // base::trace_event::TraceEventHandle id) 189 // base::trace_event::TraceEventHandle id)
185 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ 190 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \
186 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration 191 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration
187 192
193 // Call EndEvent on the filter for a filtered event.
194 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
195 // const unsigned char* category_group_enabled,
196 // const char* name,
197 // base::trace_event::TraceEventHandle id)
198 #define TRACE_EVENT_API_END_FILTERED_EVENT \
199 base::trace_event::TraceLog::GetInstance()->EndFilteredEvent
200
188 // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method 201 // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method
189 // on the convertable value will be called at flush time. 202 // on the convertable value will be called at flush time.
190 // TRACE_EVENT_API_ADD_METADATA_EVENT( 203 // TRACE_EVENT_API_ADD_METADATA_EVENT(
191 // const unsigned char* category_group_enabled, 204 // const unsigned char* category_group_enabled,
192 // const char* event_name, 205 // const char* event_name,
193 // const char* arg_name, 206 // const char* arg_name,
194 // std::unique_ptr<ConvertableToTraceFormat> arg_value) 207 // std::unique_ptr<ConvertableToTraceFormat> arg_value)
195 #define TRACE_EVENT_API_ADD_METADATA_EVENT \ 208 #define TRACE_EVENT_API_ADD_METADATA_EVENT \
196 trace_event_internal::AddMetadataEvent 209 trace_event_internal::AddMetadataEvent
197 210
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 arg_values, nullptr, TRACE_EVENT_FLAG_NONE); 1005 arg_values, nullptr, TRACE_EVENT_FLAG_NONE);
993 } 1006 }
994 1007
995 // Used by TRACE_EVENTx macros. Do not use directly. 1008 // Used by TRACE_EVENTx macros. Do not use directly.
996 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer { 1009 class TRACE_EVENT_API_CLASS_EXPORT ScopedTracer {
997 public: 1010 public:
998 // Note: members of data_ intentionally left uninitialized. See Initialize. 1011 // Note: members of data_ intentionally left uninitialized. See Initialize.
999 ScopedTracer() : p_data_(NULL) {} 1012 ScopedTracer() : p_data_(NULL) {}
1000 1013
1001 ~ScopedTracer() { 1014 ~ScopedTracer() {
1002 if (p_data_ && *data_.category_group_enabled) 1015 if (p_data_ && *data_.category_group_enabled) {
1003 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( 1016 TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION(
1004 data_.category_group_enabled, data_.name, data_.event_handle); 1017 data_.category_group_enabled, data_.name, data_.event_handle);
1018 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_FILTERING_MODE(
1019 *data_.category_group_enabled)) {
1020 TRACE_EVENT_API_END_FILTERED_EVENT(data_.category_group_enabled,
1021 data_.name, data_.event_handle);
1022 }
1023 }
1005 } 1024 }
1006 1025
1007 void Initialize(const unsigned char* category_group_enabled, 1026 void Initialize(const unsigned char* category_group_enabled,
1008 const char* name, 1027 const char* name,
1009 base::trace_event::TraceEventHandle event_handle) { 1028 base::trace_event::TraceEventHandle event_handle) {
1010 data_.category_group_enabled = category_group_enabled; 1029 data_.category_group_enabled = category_group_enabled;
1011 data_.name = name; 1030 data_.name = name;
1012 data_.event_handle = event_handle; 1031 data_.event_handle = event_handle;
1013 p_data_ = &data_; 1032 p_data_ = &data_;
1014 } 1033 }
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1108 const char* name_; 1127 const char* name_;
1109 IDType id_; 1128 IDType id_;
1110 1129
1111 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1130 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1112 }; 1131 };
1113 1132
1114 } // namespace trace_event 1133 } // namespace trace_event
1115 } // namespace base 1134 } // namespace base
1116 1135
1117 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1136 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698