Index: base/debug/trace_event.h |
diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h |
index 444c97514dc925ed31f46bbd3f7fdfb04399333b..d51bc6b5483170fd10a37803c73f13c5bbc4facd 100644 |
--- a/base/debug/trace_event.h |
+++ b/base/debug/trace_event.h |
@@ -160,9 +160,52 @@ |
#include "base/third_party/dynamic_annotations/dynamic_annotations.h" |
#include "base/timer.h" |
+//////////////////////////////////////////////////////////////////////////////// |
+/// Customize these defines to call through to platform tracing APIs. |
+ |
+// volatile bool* |
+// TRACE_EVENT_API_GET_CATEGORY_ENABLED(const char* category_name) |
+#define TRACE_EVENT_API_GET_CATEGORY_ENABLED \ |
+ base::debug::TraceLog::GetCategoryEnabled |
+ |
+// Returns the threshold_begin_id used by TRACE_IF_LONGER_THAN macros. |
+// int TRACE_EVENT_API_ADD_TRACE_EVENT( |
+// char phase, |
+// const volatile bool* category_enabled, |
+// const char* name, |
+// uint64 id, |
+// int num_args, |
+// const char** arg_names, |
+// const uint8* arg_types, |
+// const uint64* arg_values, |
+// int threshold_begin_id, |
+// int64 threshold, |
+// uint8 flags) |
+#define TRACE_EVENT_API_ADD_TRACE_EVENT \ |
+ base::debug::TraceLog::GetInstance()->AddTraceEvent |
+ |
+// void TRACE_EVENT_API_ADD_COUNTER_EVENT( |
+// const volatile bool* category_enabled, |
+// const char* name, |
+// uint64 id, |
+// const char* arg1_name, int32 arg1_val, |
+// const char* arg2_name, int32 arg2_val, |
+// uint8 flags) |
+#define TRACE_EVENT_API_ADD_COUNTER_EVENT \ |
+ base::debug::TraceLog::GetInstance()->AddCounterEvent |
+ |
+// Mangle |pointer| with a process ID hash so that if |pointer| occurs on more |
+// than one process, it will not collide in the trace data. |
+// uint64 TRACE_EVENT_API_GET_ID_FROM_POINTER(void* pointer) |
+#define TRACE_EVENT_API_GET_ID_FROM_POINTER \ |
+ base::debug::TraceLog::GetInstance()->GetInterProcessID |
+ |
+//////////////////////////////////////////////////////////////////////////////// |
+ |
// By default, const char* argument values are assumed to have long-lived scope |
// and will not be copied. Use this macro to force a const char* to be copied. |
-#define TRACE_STR_COPY(str) base::debug::TraceValue::StringWithCopy(str) |
+#define TRACE_STR_COPY(str) \ |
+ trace_event_internal::TraceStringWithCopy(str) |
// Older style trace macros with explicit id and extra data |
// Only these macros result in publishing data to ETW as currently implemented. |
@@ -187,12 +230,12 @@ |
// - category and name strings must have application lifetime (statics or |
// literals). They may not include " chars. |
#define TRACE_EVENT0(category, name) \ |
- TRACE_EVENT1(category, name, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name) |
#define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ |
- TRACE_EVENT2(category, name, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val) |
#define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
- INTERNAL_TRACE_EVENT_ADD_SCOPED( \ |
- category, name, arg1_name, arg1_val, arg2_name, arg2_val) |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \ |
+ arg2_name, arg2_val) |
// Same as TRACE_EVENT except that they are not included in official builds. |
#ifdef OFFICIAL_BUILD |
@@ -229,25 +272,27 @@ |
// - category and name strings must have application lifetime (statics or |
// literals). They may not include " chars. |
#define TRACE_EVENT_INSTANT0(category, name) \ |
- TRACE_EVENT_INSTANT1(category, name, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
+ category, name, TRACE_EVENT_FLAG_NONE) |
#define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ |
- TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
+ category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
#define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
- category, name, arg1_name, arg1_val, arg2_name, arg2_val, \ |
- TRACE_EVENT_FLAG_NONE) |
+ category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
+ arg2_name, arg2_val) |
#define TRACE_EVENT_COPY_INSTANT0(category, name) \ |
- TRACE_EVENT_COPY_INSTANT1(category, name, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
+ category, name, TRACE_EVENT_FLAG_COPY) |
#define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ |
- TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
+ category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
#define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
- category, name, \ |
- arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ |
- arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ |
- TRACE_EVENT_FLAG_COPY) |
+ category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
+ arg2_name, arg2_val) |
// Records a single BEGIN event called "name" immediately, with 0, 1 or 2 |
// associated arguments. If the category is not enabled, then this |
@@ -255,50 +300,54 @@ |
// - category and name strings must have application lifetime (statics or |
// literals). They may not include " chars. |
#define TRACE_EVENT_BEGIN0(category, name) \ |
- TRACE_EVENT_BEGIN1(category, name, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
+ category, name, TRACE_EVENT_FLAG_NONE) |
#define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ |
- TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
+ category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
#define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
- category, name, arg1_name, arg1_val, arg2_name, arg2_val, \ |
- TRACE_EVENT_FLAG_NONE) |
+ category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
+ arg2_name, arg2_val) |
#define TRACE_EVENT_COPY_BEGIN0(category, name) \ |
- TRACE_EVENT_COPY_BEGIN1(category, name, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
+ category, name, TRACE_EVENT_FLAG_COPY) |
#define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ |
- TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
+ category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
#define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
- category, name, \ |
- arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ |
- arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ |
- TRACE_EVENT_FLAG_COPY) |
+ category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
+ arg2_name, arg2_val) |
// Records a single END event for "name" immediately. If the category |
// is not enabled, then this does nothing. |
// - category and name strings must have application lifetime (statics or |
// literals). They may not include " chars. |
#define TRACE_EVENT_END0(category, name) \ |
- TRACE_EVENT_END1(category, name, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
+ category, name, TRACE_EVENT_FLAG_NONE) |
#define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ |
- TRACE_EVENT_END2(category, name, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
+ category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
#define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
- category, name, arg1_name, arg1_val, arg2_name, arg2_val, \ |
- TRACE_EVENT_FLAG_NONE) |
+ category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
+ arg2_name, arg2_val) |
#define TRACE_EVENT_COPY_END0(category, name) \ |
- TRACE_EVENT_COPY_END1(category, name, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
+ category, name, TRACE_EVENT_FLAG_COPY) |
#define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ |
- TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
+ category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
#define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
- category, name, \ |
- arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ |
- arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ |
- TRACE_EVENT_FLAG_COPY) |
+ category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
+ arg2_name, arg2_val) |
// Time threshold event: |
// Only record the event if the duration is greater than the specified |
@@ -309,15 +358,15 @@ |
// - category and name strings must have application lifetime (statics or |
// literals). They may not include " chars. |
#define TRACE_EVENT_IF_LONGER_THAN0(threshold_us, category, name) \ |
- TRACE_EVENT_IF_LONGER_THAN1(threshold_us, category, name, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold_us, category, name) |
#define TRACE_EVENT_IF_LONGER_THAN1( \ |
- threshold_us, category, name, arg1_name, arg1_val) \ |
- TRACE_EVENT_IF_LONGER_THAN2(threshold_us, category, name, \ |
- arg1_name, arg1_val, NULL, 0) |
+ threshold_us, category, name, arg1_name, arg1_val) \ |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN( \ |
+ threshold_us, category, name, arg1_name, arg1_val) |
#define TRACE_EVENT_IF_LONGER_THAN2( \ |
threshold_us, category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
- INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold_us, \ |
- category, name, arg1_name, arg1_val, arg2_name, arg2_val) |
+ INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN( \ |
+ threshold_us, category, name, arg1_name, arg1_val, arg2_name, arg2_val) |
// Records the value of a counter called "name" immediately. Value |
// must be representable as a 32 bit integer. |
@@ -336,14 +385,14 @@ |
#define TRACE_COUNTER2(category, name, value1_name, value1_val, \ |
value2_name, value2_val) \ |
INTERNAL_TRACE_EVENT_ADD_COUNTER( \ |
- category, name, 0, value1_name, value1_val, value2_name, value2_val, \ |
+ category, name, trace_event_internal::kNoEventId, \ |
+ value1_name, value1_val, value2_name, value2_val, \ |
TRACE_EVENT_FLAG_NONE) |
#define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ |
value2_name, value2_val) \ |
INTERNAL_TRACE_EVENT_ADD_COUNTER( \ |
- category, name, 0, \ |
- value1_name, value1_val, \ |
- value2_name, value2_val, \ |
+ category, name, trace_event_internal::kNoEventId, \ |
+ value1_name, value1_val, value2_name, value2_val, \ |
TRACE_EVENT_FLAG_COPY) |
// Records the value of a counter called "name" immediately. Value |
@@ -392,48 +441,54 @@ |
// will be xored with a hash of the process ID so that the same pointer on |
// two different processes will not collide. |
#define TRACE_EVENT_START0(category, name, id) \ |
- TRACE_EVENT_START1(category, name, id, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID) |
#define TRACE_EVENT_START1(category, name, id, arg1_name, arg1_val) \ |
- TRACE_EVENT_START2(category, name, id, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID, arg1_name, arg1_val) |
#define TRACE_EVENT_START2(category, name, id, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
- category, name, id, arg1_name, arg1_val, arg2_name, arg2_val, \ |
- TRACE_EVENT_FLAG_HAS_ID) |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID, \ |
+ arg1_name, arg1_val, arg2_name, arg2_val) |
#define TRACE_EVENT_COPY_START0(category, name, id) \ |
- TRACE_EVENT_COPY_START1(category, name, id, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY) |
#define TRACE_EVENT_COPY_START1(category, name, id, arg1_name, arg1_val) \ |
- TRACE_EVENT_COPY_START2(category, name, id, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ |
+ arg1_name, arg1_val) |
#define TRACE_EVENT_COPY_START2(category, name, id, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_START, \ |
- category, name, id, \ |
- arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ |
- arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ |
- TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY) |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ |
+ arg1_name, arg1_val, arg2_name, arg2_val) |
// Records a single FINISH event for "name" immediately. If the category |
// is not enabled, then this does nothing. |
#define TRACE_EVENT_FINISH0(category, name, id) \ |
- TRACE_EVENT_FINISH1(category, name, id, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID) |
#define TRACE_EVENT_FINISH1(category, name, id, arg1_name, arg1_val) \ |
- TRACE_EVENT_FINISH2(category, name, id, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID, arg1_name, arg1_val) |
#define TRACE_EVENT_FINISH2(category, name, id, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
- category, name, id, arg1_name, arg1_val, arg2_name, arg2_val, \ |
- TRACE_EVENT_FLAG_HAS_ID) |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID, \ |
+ arg1_name, arg1_val, arg2_name, arg2_val) |
#define TRACE_EVENT_COPY_FINISH0(category, name, id) \ |
- TRACE_EVENT_COPY_FINISH1(category, name, id, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY) |
#define TRACE_EVENT_COPY_FINISH1(category, name, id, arg1_name, arg1_val) \ |
- TRACE_EVENT_COPY_FINISH2(category, name, id, arg1_name, arg1_val, NULL, 0) |
+ INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ |
+ arg1_name, arg1_val) |
#define TRACE_EVENT_COPY_FINISH2(category, name, id, arg1_name, arg1_val, \ |
arg2_name, arg2_val) \ |
INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FINISH, \ |
- category, name, id, \ |
- arg1_name, base::debug::TraceValue::ForceCopy(arg1_val), \ |
- arg2_name, base::debug::TraceValue::ForceCopy(arg2_val), \ |
- TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY) |
+ category, name, id, TRACE_EVENT_FLAG_HAS_ID | TRACE_EVENT_FLAG_COPY, \ |
+ arg1_name, arg1_val, arg2_name, arg2_val) |
// Implementation detail: trace event macros create temporary variables |
@@ -449,23 +504,22 @@ |
// Implementation detail: internal macro to create static category. |
// - ANNOTATE_BENIGN_RACE, see Thread Safety above. |
#define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ |
- static const base::debug::TraceCategory* \ |
+ static const volatile bool* \ |
INTERNAL_TRACE_EVENT_UID(catstatic) = NULL; \ |
ANNOTATE_BENIGN_RACE(&INTERNAL_TRACE_EVENT_UID(catstatic), \ |
"trace_event category"); \ |
if (!INTERNAL_TRACE_EVENT_UID(catstatic)) \ |
INTERNAL_TRACE_EVENT_UID(catstatic) = \ |
- base::debug::TraceLog::GetCategory(category); |
+ TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); |
// Implementation detail: internal macro to create static category and add |
// event if the category is enabled. |
-#define INTERNAL_TRACE_EVENT_ADD( \ |
- phase, category, name, arg1_name, arg1_val, arg2_name, arg2_val, flags) \ |
+#define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \ |
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
- if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ |
- base::debug::TraceLog::GetInstance()->AddTraceEvent( \ |
- phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
- name, 0, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, flags); \ |
+ if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
+ trace_event_internal::AddTraceEvent( \ |
+ phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \ |
+ trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ |
} |
// Implementation detail: internal macro to create static category and |
@@ -473,26 +527,26 @@ |
#define INTERNAL_TRACE_EVENT_ADD_COUNTER( \ |
category, name, id, arg1_name, arg1_val, arg2_name, arg2_val, flags) \ |
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
- if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ |
- base::debug::TraceLog::GetInstance()->AddCounterEvent( \ |
+ if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
+ TRACE_EVENT_API_ADD_COUNTER_EVENT( \ |
INTERNAL_TRACE_EVENT_UID(catstatic), \ |
- name, id, arg1_name, arg1_val, arg2_name, arg2_val, flags); \ |
+ name, trace_event_internal::TraceID(id).data(), \ |
+ arg1_name, arg1_val, arg2_name, arg2_val, flags); \ |
} |
// Implementation detail: internal macro to create static category and add begin |
// event if the category is enabled. Also adds the end event when the scope |
// ends. |
-#define INTERNAL_TRACE_EVENT_ADD_SCOPED( \ |
- category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
+#define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \ |
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
- base::debug::internal::TraceEndOnScopeClose \ |
+ trace_event_internal::TraceEndOnScopeClose \ |
INTERNAL_TRACE_EVENT_UID(profileScope); \ |
- if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ |
- base::debug::TraceLog::GetInstance()->AddTraceEvent( \ |
+ if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
+ trace_event_internal::AddTraceEvent( \ |
TRACE_EVENT_PHASE_BEGIN, \ |
INTERNAL_TRACE_EVENT_UID(catstatic), \ |
- name, 0, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \ |
- TRACE_EVENT_FLAG_NONE); \ |
+ name, trace_event_internal::kNoEventId, \ |
+ TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ |
INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ |
INTERNAL_TRACE_EVENT_UID(catstatic), name); \ |
} |
@@ -501,17 +555,17 @@ |
// event if the category is enabled. Also adds the end event when the scope |
// ends. If the elapsed time is < threshold time, the begin/end pair is erased. |
#define INTERNAL_TRACE_EVENT_ADD_SCOPED_IF_LONGER_THAN(threshold, \ |
- category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
+ category, name, ...) \ |
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
- base::debug::internal::TraceEndOnScopeCloseThreshold \ |
+ trace_event_internal::TraceEndOnScopeCloseThreshold \ |
INTERNAL_TRACE_EVENT_UID(profileScope); \ |
- if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ |
+ if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
int INTERNAL_TRACE_EVENT_UID(begin_event_id) = \ |
- base::debug::TraceLog::GetInstance()->AddTraceEvent( \ |
+ trace_event_internal::AddTraceEvent( \ |
TRACE_EVENT_PHASE_BEGIN, \ |
INTERNAL_TRACE_EVENT_UID(catstatic), \ |
- name, 0, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, \ |
- TRACE_EVENT_FLAG_NONE); \ |
+ name, trace_event_internal::kNoEventId, \ |
+ TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ |
INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ |
INTERNAL_TRACE_EVENT_UID(catstatic), name, \ |
INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \ |
@@ -519,13 +573,14 @@ |
// Implementation detail: internal macro to create static category and add |
// event if the category is enabled. |
-#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, \ |
- arg1_name, arg1_val, arg2_name, arg2_val, flags) \ |
+#define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \ |
+ ...) \ |
INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
- if (INTERNAL_TRACE_EVENT_UID(catstatic)->enabled) { \ |
- base::debug::TraceLog::GetInstance()->AddTraceEvent( \ |
+ if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
+ trace_event_internal::AddTraceEvent( \ |
phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
- name, id, arg1_name, arg1_val, arg2_name, arg2_val, -1, 0, flags); \ |
+ name, trace_event_internal::TraceID(id).data(), flags, \ |
+ ##__VA_ARGS__); \ |
} |
template <typename Type> |
@@ -537,142 +592,43 @@ class RefCountedString; |
namespace debug { |
-// Categories allow enabling/disabling of streams of trace events |
-struct TraceCategory { |
- const char* name; |
- volatile bool enabled; |
-}; |
+const int kTraceMaxNumArgs = 2; |
-const size_t kTraceMaxNumArgs = 2; |
+// Notes regarding the following definitions: |
+// New values can be added and propagated to third party libraries, but existing |
+// definitions must never be changed, because third party libraries may use old |
+// definitions. |
// Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
-typedef char TraceEventPhase; |
-#define TRACE_EVENT_PHASE_BEGIN (base::debug::TraceEventPhase('B')) |
-#define TRACE_EVENT_PHASE_END (base::debug::TraceEventPhase('E')) |
-#define TRACE_EVENT_PHASE_INSTANT (base::debug::TraceEventPhase('I')) |
-#define TRACE_EVENT_PHASE_START (base::debug::TraceEventPhase('S')) |
-#define TRACE_EVENT_PHASE_FINISH (base::debug::TraceEventPhase('F')) |
-#define TRACE_EVENT_PHASE_METADATA (base::debug::TraceEventPhase('M')) |
-#define TRACE_EVENT_PHASE_COUNTER (base::debug::TraceEventPhase('C')) |
- |
-typedef uint8 TraceEventFlags; |
-#define TRACE_EVENT_FLAG_NONE (base::debug::TraceEventFlags(0)) |
-#define TRACE_EVENT_FLAG_COPY (base::debug::TraceEventFlags(1<<0)) |
-#define TRACE_EVENT_FLAG_HAS_ID (base::debug::TraceEventFlags(1<<1)) |
- |
-// Simple union of values. This is much lighter weight than base::Value, which |
-// requires dynamic allocation and a vtable. To keep the trace runtime overhead |
-// low, we want constant size storage here. |
-class BASE_EXPORT TraceValue { |
- public: |
- enum Type { |
- TRACE_TYPE_UNDEFINED, |
- TRACE_TYPE_BOOL, |
- TRACE_TYPE_UINT, |
- TRACE_TYPE_INT, |
- TRACE_TYPE_DOUBLE, |
- TRACE_TYPE_POINTER, |
- TRACE_TYPE_STRING, |
- TRACE_TYPE_STATIC_STRING |
- }; |
- |
- TraceValue() : type_(TRACE_TYPE_UNDEFINED) { |
- value_.as_uint = 0ull; |
- } |
- TraceValue(bool rhs) : type_(TRACE_TYPE_BOOL) { |
- value_.as_bool = rhs; |
- } |
- TraceValue(uint64 rhs) : type_(TRACE_TYPE_UINT) { |
- value_.as_uint = rhs; |
- } |
- TraceValue(uint32 rhs) : type_(TRACE_TYPE_UINT) { |
- value_.as_uint = rhs; |
- } |
- TraceValue(uint16 rhs) : type_(TRACE_TYPE_UINT) { |
- value_.as_uint = rhs; |
- } |
- TraceValue(uint8 rhs) : type_(TRACE_TYPE_UINT) { |
- value_.as_uint = rhs; |
- } |
- TraceValue(int64 rhs) : type_(TRACE_TYPE_INT) { |
- value_.as_int = rhs; |
- } |
- TraceValue(int32 rhs) : type_(TRACE_TYPE_INT) { |
- value_.as_int = rhs; |
- } |
- TraceValue(int16 rhs) : type_(TRACE_TYPE_INT) { |
- value_.as_int = rhs; |
- } |
- TraceValue(int8 rhs) : type_(TRACE_TYPE_INT) { |
- value_.as_int = rhs; |
- } |
- TraceValue(double rhs) : type_(TRACE_TYPE_DOUBLE) { |
- value_.as_double = rhs; |
- } |
- TraceValue(const void* rhs) : type_(TRACE_TYPE_POINTER) { |
- value_.as_pointer = rhs; |
- } |
- TraceValue(const std::string& rhs) : type_(TRACE_TYPE_STRING) { |
- value_.as_string = rhs.c_str(); |
- } |
- TraceValue(const char* rhs) : type_(TRACE_TYPE_STATIC_STRING) { |
- value_.as_string = rhs; |
- } |
- |
- static TraceValue StringWithCopy(const char* rhs) { |
- TraceValue value(rhs); |
- if (rhs) |
- value.type_ = TRACE_TYPE_STRING; |
- return value; |
- } |
- |
- static TraceValue ForceCopy(const TraceValue& rhs) { |
- TraceValue value(rhs); |
- if (value.type_ == TRACE_TYPE_STATIC_STRING && value.as_string()) |
- value.type_ = TRACE_TYPE_STRING; |
- return value; |
- } |
- |
- bool is_string() const { |
- return type_ == TRACE_TYPE_STRING || type_ == TRACE_TYPE_STATIC_STRING; |
- } |
- |
- void AppendAsJSON(std::string* out) const; |
+#define TRACE_EVENT_PHASE_BEGIN ('B') |
+#define TRACE_EVENT_PHASE_END ('E') |
+#define TRACE_EVENT_PHASE_INSTANT ('I') |
+#define TRACE_EVENT_PHASE_START ('S') |
+#define TRACE_EVENT_PHASE_FINISH ('F') |
+#define TRACE_EVENT_PHASE_METADATA ('M') |
+#define TRACE_EVENT_PHASE_COUNTER ('C') |
+ |
+// Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. |
+#define TRACE_EVENT_FLAG_NONE (uint8(0)) |
+#define TRACE_EVENT_FLAG_COPY (uint8(1<<0)) |
+#define TRACE_EVENT_FLAG_HAS_ID (uint8(1<<1)) |
+ |
+// Type values for identifying types in the TraceValue union. |
+#define TRACE_VALUE_TYPE_BOOL (uint8(1)) |
+#define TRACE_VALUE_TYPE_UINT (uint8(2)) |
+#define TRACE_VALUE_TYPE_INT (uint8(3)) |
+#define TRACE_VALUE_TYPE_DOUBLE (uint8(4)) |
+#define TRACE_VALUE_TYPE_POINTER (uint8(5)) |
+#define TRACE_VALUE_TYPE_STRING (uint8(6)) |
+#define TRACE_VALUE_TYPE_COPY_STRING (uint8(7)) |
- Type type() const { |
- return type_; |
- } |
- uint64 as_uint() const { |
- DCHECK_EQ(TRACE_TYPE_UINT, type_); |
- return value_.as_uint; |
- } |
- bool as_bool() const { |
- DCHECK_EQ(TRACE_TYPE_BOOL, type_); |
- return value_.as_bool; |
- } |
- int64 as_int() const { |
- DCHECK_EQ(TRACE_TYPE_INT, type_); |
- return value_.as_int; |
- } |
- double as_double() const { |
- DCHECK_EQ(TRACE_TYPE_DOUBLE, type_); |
- return value_.as_double; |
- } |
- const void* as_pointer() const { |
- DCHECK_EQ(TRACE_TYPE_POINTER, type_); |
- return value_.as_pointer; |
- } |
- const char* as_string() const { |
- DCHECK(is_string()); |
- return value_.as_string; |
- } |
- const char** as_assignable_string() { |
- DCHECK_EQ(TRACE_TYPE_STRING, type_); |
- return &value_.as_string; |
- } |
- |
- private: |
- union Value { |
+// Output records are "Events" and can be obtained via the |
+// OutputCallback whenever the tracing system decides to flush. This |
+// can happen at any time, on any thread, or you can programatically |
+// force it to happen. |
+class BASE_EXPORT TraceEvent { |
+ public: |
+ union TraceValue { |
bool as_bool; |
uint64 as_uint; |
int64 as_int; |
@@ -681,56 +637,20 @@ class BASE_EXPORT TraceValue { |
const char* as_string; |
}; |
- Type type_; |
- Value value_; |
-}; |
- |
-// TraceID encapsulates an ID that can either be an integer or pointer. Pointers |
-// are mangled with the Process ID so that they are unlikely to collide when the |
-// same pointer is used on different processes. |
-class BASE_EXPORT TraceID { |
- public: |
- TraceID() : data_(0u) {} |
- TraceID(void* rhs); |
- TraceID(unsigned long long rhs) : data_(static_cast<uint64>(rhs)) {} |
- TraceID(unsigned long rhs) : data_(static_cast<uint64>(rhs)) {} |
- TraceID(unsigned int rhs) : data_(static_cast<uint64>(rhs)) {} |
- TraceID(long long rhs) : data_(static_cast<uint64>(rhs)) {} |
- TraceID(long rhs) : data_(static_cast<uint64>(rhs)) {} |
- TraceID(int rhs) : data_(static_cast<uint64>(rhs)) {} |
- |
- uint64 data() const { return data_; } |
- |
- private: |
- uint64 data_; |
-}; |
- |
-// Output records are "Events" and can be obtained via the |
-// OutputCallback whenever the tracing system decides to flush. This |
-// can happen at any time, on any thread, or you can programatically |
-// force it to happen. |
-class BASE_EXPORT TraceEvent { |
- public: |
TraceEvent(); |
TraceEvent(int thread_id, |
TimeTicks timestamp, |
- TraceEventPhase phase, |
- const TraceCategory* category, |
+ char phase, |
+ const volatile bool* category_enabled, |
const char* name, |
- TraceID id, |
- const char* arg1_name, const TraceValue& arg1_val, |
- const char* arg2_name, const TraceValue& arg2_val, |
- TraceEventFlags flags); |
+ uint64 id, |
+ int num_args, |
+ const char** arg_names, |
+ const uint8* arg_types, |
+ const uint64* arg_values, |
+ uint8 flags); |
~TraceEvent(); |
- static char GetPhaseChar(TraceEventPhase phase) { |
- return static_cast<char>(phase); |
- } |
- |
- static TraceEventPhase GetPhase(const char* phase) { |
- return static_cast<TraceEventPhase>(*phase); |
- } |
- |
// Serialize event data to JSON |
static void AppendEventsAsJSON(const std::vector<TraceEvent>& events, |
size_t start, |
@@ -752,15 +672,16 @@ class BASE_EXPORT TraceEvent { |
// Note: these are ordered by size (largest first) for optimal packing. |
TimeTicks timestamp_; |
// id_ can be used to store phase-specific data. |
- TraceID id_; |
+ uint64 id_; |
TraceValue arg_values_[kTraceMaxNumArgs]; |
const char* arg_names_[kTraceMaxNumArgs]; |
- const TraceCategory* category_; |
+ const volatile bool* category_enabled_; |
const char* name_; |
scoped_refptr<base::RefCountedString> parameter_copy_storage_; |
int thread_id_; |
- TraceEventPhase phase_; |
- TraceEventFlags flags_; |
+ char phase_; |
+ uint8 flags_; |
+ uint8 arg_types_[kTraceMaxNumArgs]; |
}; |
@@ -870,7 +791,8 @@ class BASE_EXPORT TraceLog { |
void Flush(); |
// Called by TRACE_EVENT* macros, don't call this directly. |
- static const TraceCategory* GetCategory(const char* name); |
+ static const volatile bool* GetCategoryEnabled(const char* name); |
+ static const char* GetCategoryName(const volatile bool* category_enabled); |
// Called by TRACE_EVENT* macros, don't call this directly. |
// Returns the index in the internal vector of the event if it was added, or |
@@ -880,36 +802,41 @@ class BASE_EXPORT TraceLog { |
// is less than the threshold, the begin/end event pair is dropped. |
// If |copy| is set, |name|, |arg_name1| and |arg_name2| will be deep copied |
// into the event; see "Memory scoping note" and TRACE_EVENT_COPY_XXX above. |
- int AddTraceEvent(TraceEventPhase phase, |
- const TraceCategory* category, |
+ int AddTraceEvent(char phase, |
+ const volatile bool* category_enabled, |
const char* name, |
- TraceID id, |
- const char* arg1_name, TraceValue arg1_val, |
- const char* arg2_name, TraceValue arg2_val, |
+ uint64 id, |
+ int num_args, |
+ const char** arg_names, |
+ const uint8* arg_types, |
+ const uint64* arg_values, |
int threshold_begin_id, |
int64 threshold, |
- TraceEventFlags flags); |
- static void AddTraceEventEtw(TraceEventPhase phase, |
+ uint8 flags); |
+ static void AddTraceEventEtw(char phase, |
const char* name, |
const void* id, |
const char* extra); |
- static void AddTraceEventEtw(TraceEventPhase phase, |
+ static void AddTraceEventEtw(char phase, |
const char* name, |
const void* id, |
const std::string& extra); |
// A wrapper around AddTraceEvent used by TRACE_COUNTERx macros |
// that allows only integer values for the counters. |
- int AddCounterEvent(const TraceCategory* category, |
- const char* name, |
- TraceID id, |
- const char* arg1_name, int32 arg1_val, |
- const char* arg2_name, int32 arg2_val, |
- TraceEventFlags flags); |
- |
- // Mangle |id| with a hash based on the process ID so that if |id| occurs on |
+ void AddCounterEvent(const volatile bool* category_enabled, |
+ const char* name, |
+ uint64 id, |
+ const char* arg1_name, int32 arg1_val, |
+ const char* arg2_name, int32 arg2_val, |
+ uint8 flags); |
+ |
+ // Mangle |ptr| with a hash based on the process ID so that if |ptr| occurs on |
// more than one process, it will not collide. |
- uint64 GetIntraProcessID(uint64 id) const { return id ^ process_id_hash_; } |
+ uint64 GetInterProcessID(void* ptr) const { |
+ return static_cast<uint64>(reinterpret_cast<uintptr_t>(ptr)) ^ |
+ process_id_hash_; |
+ } |
int process_id() const { return process_id_; } |
@@ -937,7 +864,7 @@ class BASE_EXPORT TraceLog { |
TraceLog(); |
~TraceLog(); |
- const TraceCategory* GetCategoryInternal(const char* name); |
+ const volatile bool* GetCategoryEnabledInternal(const char* name); |
void AddThreadNameMetadataEvents(); |
void AddClockSyncMetadataEvents(); |
@@ -961,7 +888,155 @@ class BASE_EXPORT TraceLog { |
DISALLOW_COPY_AND_ASSIGN(TraceLog); |
}; |
-namespace internal { |
+} // namespace debug |
+} // namespace base |
+ |
+namespace trace_event_internal { |
+ |
+// Specify these values when the corresponding argument of AddTraceEvent is not |
+// used. |
+const int kZeroNumArgs = 0; |
+const int kNoThreshholdBeginId = -1; |
+const int64 kNoThresholdValue = 0; |
+const uint64 kNoEventId = 0; |
+ |
+// TraceID encapsulates an ID that can either be an integer or pointer. Pointers |
+// are mangled with the Process ID so that they are unlikely to collide when the |
+// same pointer is used on different processes. |
+class BASE_EXPORT TraceID { |
+ public: |
+ explicit TraceID(void* rhs) : |
+ data_(TRACE_EVENT_API_GET_ID_FROM_POINTER(rhs)) {} |
+ explicit TraceID(unsigned long long rhs) : data_(static_cast<uint64>(rhs)) {} |
+ explicit TraceID(unsigned long rhs) : data_(static_cast<uint64>(rhs)) {} |
+ explicit TraceID(unsigned int rhs) : data_(static_cast<uint64>(rhs)) {} |
+ explicit TraceID(long long rhs) : data_(static_cast<uint64>(rhs)) {} |
+ explicit TraceID(long rhs) : data_(static_cast<uint64>(rhs)) {} |
+ explicit TraceID(int rhs) : data_(static_cast<uint64>(rhs)) {} |
+ |
+ uint64 data() const { return data_; } |
+ |
+ private: |
+ uint64 data_; |
+}; |
+ |
+// Simple union to store various types as uint64. |
+union TraceValueUnion { |
+ bool as_bool; |
+ uint64 as_uint; |
+ int64 as_int; |
+ double as_double; |
+ const void* as_pointer; |
+ const char* as_string; |
+}; |
+ |
+// Simple container for const char* that should be copied instead of retained. |
+class TraceStringWithCopy { |
+ public: |
+ explicit TraceStringWithCopy(const char* str) : str_(str) {} |
+ operator const char* () const { return str_; } |
+ private: |
+ const char* str_; |
+}; |
+ |
+// Define SetTraceValue for each allowed type. It stores the type and |
+// value in the return arguments. This allows this API to avoid declaring any |
+// structures so that it is portable to third_party libraries. |
+#define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, \ |
+ union_member, \ |
+ value_type_id) \ |
+ static inline void SetTraceValue(actual_type arg, \ |
+ uint8* type, \ |
+ uint64* value) { \ |
+ TraceValueUnion type_value; \ |
+ type_value.union_member = arg; \ |
+ *type = value_type_id; \ |
+ *value = type_value.as_uint; \ |
+ } |
+ |
+INTERNAL_DECLARE_SET_TRACE_VALUE(bool, as_bool, TRACE_VALUE_TYPE_BOOL) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(uint64, as_uint, TRACE_VALUE_TYPE_UINT) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(uint32, as_uint, TRACE_VALUE_TYPE_UINT) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(uint16, as_uint, TRACE_VALUE_TYPE_UINT) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(uint8, as_uint, TRACE_VALUE_TYPE_UINT) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(int64, as_int, TRACE_VALUE_TYPE_INT) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(int32, as_int, TRACE_VALUE_TYPE_INT) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(int16, as_int, TRACE_VALUE_TYPE_INT) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(int8, as_int, TRACE_VALUE_TYPE_INT) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(double, as_double, TRACE_VALUE_TYPE_DOUBLE) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, as_pointer, |
+ TRACE_VALUE_TYPE_POINTER) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, as_string, |
+ TRACE_VALUE_TYPE_STRING) |
+INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, as_string, |
+ TRACE_VALUE_TYPE_COPY_STRING) |
+ |
+// std::string version of SetTraceValue so that trace arguments can be strings. |
+static inline void SetTraceValue(const std::string& arg, |
+ uint8* type, |
+ uint64* value) { |
+ TraceValueUnion type_value; |
+ type_value.as_string = arg.c_str(); |
+ *type = TRACE_VALUE_TYPE_COPY_STRING; |
+ *value = type_value.as_uint; |
+} |
+ |
+// These AddTraceEvent template functions are defined here instead of in the |
+// macro, because the arg_values could be temporary objects, such as |
+// std::string. In order to store pointers to the internal c_str and pass |
+// through to the tracing API, the arg_values must live throughout |
+// these procedures. |
+ |
+static inline int AddTraceEvent(char phase, |
+ const volatile bool* category_enabled, |
+ const char* name, |
+ uint64 id, |
+ uint8 flags) { |
+ return TRACE_EVENT_API_ADD_TRACE_EVENT( |
+ phase, category_enabled, name, id, |
+ kZeroNumArgs, NULL, NULL, NULL, |
+ kNoThreshholdBeginId, kNoThresholdValue, flags); |
+} |
+ |
+template<class ARG1_TYPE> |
+static inline int AddTraceEvent(char phase, |
+ const volatile bool* category_enabled, |
+ const char* name, |
+ uint64 id, |
+ uint8 flags, |
+ const char* arg1_name, |
+ const ARG1_TYPE& arg1_val) { |
+ const int num_args = 1; |
+ uint8 arg_types[1]; |
+ uint64 arg_values[1]; |
+ SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
+ return TRACE_EVENT_API_ADD_TRACE_EVENT( |
+ phase, category_enabled, name, id, |
+ num_args, &arg1_name, arg_types, arg_values, |
+ kNoThreshholdBeginId, kNoThresholdValue, flags); |
+} |
+ |
+template<class ARG1_TYPE, class ARG2_TYPE> |
+static inline int AddTraceEvent(char phase, |
+ const volatile bool* category_enabled, |
+ const char* name, |
+ uint64 id, |
+ uint8 flags, |
+ const char* arg1_name, |
+ const ARG1_TYPE& arg1_val, |
+ const char* arg2_name, |
+ const ARG2_TYPE& arg2_val) { |
+ const int num_args = 2; |
+ const char* arg_names[2] = { arg1_name, arg2_name }; |
+ uint8 arg_types[2]; |
+ uint64 arg_values[2]; |
+ SetTraceValue(arg1_val, &arg_types[0], &arg_values[0]); |
+ SetTraceValue(arg2_val, &arg_types[1], &arg_values[1]); |
+ return TRACE_EVENT_API_ADD_TRACE_EVENT( |
+ phase, category_enabled, name, id, |
+ num_args, arg_names, arg_types, arg_values, |
+ kNoThreshholdBeginId, kNoThresholdValue, flags); |
+} |
// Used by TRACE_EVENTx macro. Do not use directly. |
class BASE_EXPORT TraceEndOnScopeClose { |
@@ -973,7 +1048,7 @@ class BASE_EXPORT TraceEndOnScopeClose { |
AddEventIfEnabled(); |
} |
- void Initialize(const TraceCategory* category, |
+ void Initialize(const volatile bool* category_enabled, |
const char* name); |
private: |
@@ -986,7 +1061,7 @@ class BASE_EXPORT TraceEndOnScopeClose { |
// members of this class instead, compiler warnings occur about potential |
// uninitialized accesses. |
struct Data { |
- const TraceCategory* category; |
+ const volatile bool* category_enabled; |
const char* name; |
}; |
Data* p_data_; |
@@ -1005,7 +1080,7 @@ class BASE_EXPORT TraceEndOnScopeCloseThreshold { |
// Called by macros only when tracing is enabled at the point when the begin |
// event is added. |
- void Initialize(const TraceCategory* category, |
+ void Initialize(const volatile bool* category_enabled, |
const char* name, |
int threshold_begin_id, |
int64 threshold); |
@@ -1021,7 +1096,7 @@ class BASE_EXPORT TraceEndOnScopeCloseThreshold { |
// uninitialized accesses. |
struct Data { |
int64 threshold; |
- const TraceCategory* category; |
+ const volatile bool* category_enabled; |
const char* name; |
int threshold_begin_id; |
}; |
@@ -1029,9 +1104,6 @@ class BASE_EXPORT TraceEndOnScopeCloseThreshold { |
Data data_; |
}; |
-} // namespace internal |
- |
-} // namespace debug |
-} // namespace base |
+} // namespace trace_event_internal |
#endif // BASE_DEBUG_TRACE_EVENT_H_ |