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 #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_macros_common.h instead of here. | 10 // implementation-specific should go in trace_event_common.h instead of here. |
11 | 11 |
12 #include <stddef.h> | 12 #include <stddef.h> |
13 #include <stdint.h> | 13 #include <stdint.h> |
14 | 14 |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/atomicops.h" | 17 #include "base/atomicops.h" |
18 #include "base/macros.h" | 18 #include "base/macros.h" |
19 #include "base/time/time.h" | 19 #include "base/time/time.h" |
20 #include "base/trace_event/common/trace_event_common.h" | 20 #include "base/trace_event/common/trace_event_common.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
178 | 178 |
179 // Set the duration field of a COMPLETE trace event. | 179 // Set the duration field of a COMPLETE trace event. |
180 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( | 180 // void TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION( |
181 // const unsigned char* category_group_enabled, | 181 // const unsigned char* category_group_enabled, |
182 // const char* name, | 182 // const char* name, |
183 // base::trace_event::TraceEventHandle id) | 183 // base::trace_event::TraceEventHandle id) |
184 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ | 184 #define TRACE_EVENT_API_UPDATE_TRACE_EVENT_DURATION \ |
185 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration | 185 base::trace_event::TraceLog::GetInstance()->UpdateTraceEventDuration |
186 | 186 |
187 // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method | 187 // Adds a metadata event to the trace log. The |AppendValueAsTraceFormat| method |
188 // on the convertable value will be called at flush time. | 188 // on the convertable value will be called at flush time. |
fmeawad
2016/02/16 21:47:37
After a second thought I think it is better to eli
alph
2016/02/16 23:19:28
ok. done
| |
189 // TRACE_EVENT_API_ADD_METADATA_EVENT( | 189 // TRACE_EVENT_API_ADD_METADATA_EVENT( |
190 // const char* event_name, | 190 // const char* event_name, |
191 // const char* arg_name, | 191 // const char* arg_name, |
192 // scoped_refptr<ConvertableToTraceFormat> arg_value) | 192 // scoped_refptr<ConvertableToTraceFormat> arg_value) |
193 // TRACE_EVENT_API_ADD_METADATA_EVENT( | |
194 // const unsigned char* category_group_enabled, | |
195 // const char* event_name, | |
196 // const char* arg_name, | |
197 // scoped_refptr<ConvertableToTraceFormat> arg_value) | |
193 #define TRACE_EVENT_API_ADD_METADATA_EVENT \ | 198 #define TRACE_EVENT_API_ADD_METADATA_EVENT \ |
194 trace_event_internal::AddMetadataEvent | 199 trace_event_internal::AddMetadataEvent |
195 | 200 |
196 // Defines atomic operations used internally by the tracing system. | 201 // Defines atomic operations used internally by the tracing system. |
197 #define TRACE_EVENT_API_ATOMIC_WORD base::subtle::AtomicWord | 202 #define TRACE_EVENT_API_ATOMIC_WORD base::subtle::AtomicWord |
198 #define TRACE_EVENT_API_ATOMIC_LOAD(var) base::subtle::NoBarrier_Load(&(var)) | 203 #define TRACE_EVENT_API_ATOMIC_LOAD(var) base::subtle::NoBarrier_Load(&(var)) |
199 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \ | 204 #define TRACE_EVENT_API_ATOMIC_STORE(var, value) \ |
200 base::subtle::NoBarrier_Store(&(var), (value)) | 205 base::subtle::NoBarrier_Store(&(var), (value)) |
201 | 206 |
202 // Defines visibility for classes in trace_event.h | 207 // Defines visibility for classes in trace_event.h |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 &trace_event_flags); \ | 345 &trace_event_flags); \ |
341 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 346 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
342 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ | 347 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
343 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ | 348 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ |
344 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 349 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ |
345 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ | 350 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ |
346 trace_event_internal::kNoId, ##__VA_ARGS__); \ | 351 trace_event_internal::kNoId, ##__VA_ARGS__); \ |
347 } \ | 352 } \ |
348 } while (0) | 353 } while (0) |
349 | 354 |
350 // Implementation detail: internal macro to enter and leave a context based on | 355 // Implementation detail: internal macro to create static category and add |
351 // the current scope. | 356 // metadata event if the category is enabled. |
357 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ | |
358 do { \ | |
359 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | |
360 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | |
361 TRACE_EVENT_API_ADD_METADATA_EVENT( \ | |
362 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ | |
363 ##__VA_ARGS__); \ | |
364 } \ | |
365 } while (0) | |
366 | |
367 // Implementation detail: internal macro to enter and leave a | |
368 // context based on the current scope. | |
352 #define INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context) \ | 369 #define INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context) \ |
353 struct INTERNAL_TRACE_EVENT_UID(ScopedContext) { \ | 370 struct INTERNAL_TRACE_EVENT_UID(ScopedContext) { \ |
354 public: \ | 371 public: \ |
355 INTERNAL_TRACE_EVENT_UID(ScopedContext)(uint64_t cid) : cid_(cid) { \ | 372 INTERNAL_TRACE_EVENT_UID(ScopedContext)(uint64_t cid) : cid_(cid) { \ |
356 TRACE_EVENT_ENTER_CONTEXT(category_group, name, cid_); \ | 373 TRACE_EVENT_ENTER_CONTEXT(category_group, name, cid_); \ |
357 } \ | 374 } \ |
358 ~INTERNAL_TRACE_EVENT_UID(ScopedContext)() { \ | 375 ~INTERNAL_TRACE_EVENT_UID(ScopedContext)() { \ |
359 TRACE_EVENT_LEAVE_CONTEXT(category_group, name, cid_); \ | 376 TRACE_EVENT_LEAVE_CONTEXT(category_group, name, cid_); \ |
360 } \ | 377 } \ |
361 \ | 378 \ |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
846 convertable_values[1] = {arg_value}; | 863 convertable_values[1] = {arg_value}; |
847 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; | 864 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; |
848 base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( | 865 base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( |
849 event_name, | 866 event_name, |
850 1, // num_args | 867 1, // num_args |
851 arg_names, arg_types, | 868 arg_names, arg_types, |
852 nullptr, // arg_values | 869 nullptr, // arg_values |
853 convertable_values, TRACE_EVENT_FLAG_NONE); | 870 convertable_values, TRACE_EVENT_FLAG_NONE); |
854 } | 871 } |
855 | 872 |
873 static inline void AddMetadataEvent( | |
874 const unsigned char* category_group_enabled, | |
875 const char* event_name, | |
876 const char* arg_name, | |
877 scoped_refptr<base::trace_event::ConvertableToTraceFormat> arg_value) { | |
878 const char* arg_names[1] = {arg_name}; | |
879 scoped_refptr<base::trace_event::ConvertableToTraceFormat> | |
880 convertable_values[1] = {arg_value}; | |
881 unsigned char arg_types[1] = {TRACE_VALUE_TYPE_CONVERTABLE}; | |
882 base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( | |
883 category_group_enabled, event_name, | |
884 1, // num_args | |
885 arg_names, arg_types, | |
886 nullptr, // arg_values | |
887 convertable_values, TRACE_EVENT_FLAG_NONE); | |
888 } | |
889 | |
890 template <class ARG1_TYPE> | |
891 static void AddMetadataEvent(const unsigned char* category_group_enabled, | |
892 const char* event_name, | |
893 const char* arg_name, | |
894 const ARG1_TYPE& arg_val) { | |
895 const int num_args = 1; | |
896 const char* arg_names[1] = {arg_name}; | |
897 unsigned char arg_types[1]; | |
898 unsigned long long arg_values[1]; | |
899 SetTraceValue(arg_val, &arg_types[0], &arg_values[0]); | |
900 | |
901 base::trace_event::TraceLog::GetInstance()->AddMetadataEvent( | |
902 category_group_enabled, event_name, num_args, arg_names, arg_types, | |
903 arg_values, nullptr, TRACE_EVENT_FLAG_NONE); | |
904 } | |
905 | |
856 template <class ARG1_TYPE> | 906 template <class ARG1_TYPE> |
857 static void AddMetadataEvent(const char* event_name, | 907 static void AddMetadataEvent(const char* event_name, |
858 const char* arg_name, | 908 const char* arg_name, |
859 const ARG1_TYPE& arg_val) { | 909 const ARG1_TYPE& arg_val) { |
860 const int num_args = 1; | 910 const int num_args = 1; |
861 const char* arg_names[1] = {arg_name}; | 911 const char* arg_names[1] = {arg_name}; |
862 unsigned char arg_types[1]; | 912 unsigned char arg_types[1]; |
863 unsigned long long arg_values[1]; | 913 unsigned long long arg_values[1]; |
864 SetTraceValue(arg_val, &arg_types[0], &arg_values[0]); | 914 SetTraceValue(arg_val, &arg_types[0], &arg_values[0]); |
865 | 915 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
984 const char* name_; | 1034 const char* name_; |
985 IDType id_; | 1035 IDType id_; |
986 | 1036 |
987 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1037 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
988 }; | 1038 }; |
989 | 1039 |
990 } // namespace trace_event | 1040 } // namespace trace_event |
991 } // namespace base | 1041 } // namespace base |
992 | 1042 |
993 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 1043 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
OLD | NEW |