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

Unified Diff: base/debug/trace_event.h

Issue 11366109: Adding raw tracing to trace framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ThreadIdNameManager to retrieve correct thread names. Created 8 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/debug/trace_event_impl.h » ('j') | base/debug/trace_event_impl.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event.h
diff --git a/base/debug/trace_event.h b/base/debug/trace_event.h
index 07863ad997b3d56fd46f8033a0775f08b56b279a..1b1e5fd700e43589f4d25bd37aa2db8622fe5787 100644
--- a/base/debug/trace_event.h
+++ b/base/debug/trace_event.h
@@ -265,6 +265,19 @@
category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \
arg2_name, arg2_val)
+// Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided.
+// - |id| is used to match the _BEGIN event with the _END event.
+// Events are considered to match if their category, name and id values all
+// match. |id| must either be a pointer or an integer value up to 64 bits. If
+// it's a pointer, the bits 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_BEGIN_EXPLICIT0(category, name, tid, id, ts) \
+ INTERNAL_TRACE_EVENT_ADD_EXPLICIT(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
+ category, name, tid, ts, id, TRACE_EVENT_FLAG_NONE)
+#define TRACE_EVENT_COPY_BEGIN_EXPLICIT0(category, name, tid, id, ts) \
+ INTERNAL_TRACE_EVENT_ADD_EXPLICIT(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
+ category, name, tid, ts, id, TRACE_EVENT_FLAG_COPY)
+
// 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
@@ -292,6 +305,19 @@
category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \
arg2_name, arg2_val)
+// Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided.
+// - |id| is used to match the _BEGIN event with the _END event.
+// Events are considered to match if their category, name and id values all
+// match. |id| must either be a pointer or an integer value up to 64 bits. If
+// it's a pointer, the bits 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_END_EXPLICIT0(category, name, tid, id, ts) \
+ INTERNAL_TRACE_EVENT_ADD_EXPLICIT(TRACE_EVENT_PHASE_ASYNC_END, \
+ category, name, tid, ts, id, TRACE_EVENT_FLAG_NONE)
+#define TRACE_EVENT_COPY_END_EXPLICIT0(category, name, tid, id, ts) \
+ INTERNAL_TRACE_EVENT_ADD_EXPLICIT(TRACE_EVENT_PHASE_ASYNC_END, \
+ category, name, tid, ts, id, TRACE_EVENT_FLAG_COPY)
+
// Time threshold event:
// Only record the event if the duration is greater than the specified
// threshold_us (time in microseconds).
@@ -597,6 +623,25 @@
#define TRACE_EVENT_API_ADD_TRACE_EVENT \
base::debug::TraceLog::GetInstance()->AddTraceEvent
+// Add a trace event to the platform tracing system. Returns thresholdBeginId
+// for use in a corresponding end TRACE_EVENT_API_ADD_TRACE_EVENT_EXPLICIT call.
+// int TRACE_EVENT_API_ADD_TRACE_EVENT_EXPLICIT(
+// char phase,
+// const unsigned char* category_enabled,
+// const char* name,
+// int thread_id,
+// int64 timestamp,
+// unsigned long long id,
+// int num_args,
+// const char** arg_names,
+// const unsigned char* arg_types,
+// const unsigned long long* arg_values,
+// int threshold_begin_id,
+// long long threshold,
+// unsigned char flags)
+#define TRACE_EVENT_API_ADD_TRACE_EVENT_EXPLICIT \
nduca 2012/12/11 19:40:58 How about always providing the tid? And always pro
dsinclair 2012/12/14 16:08:20 Done.
+ base::debug::TraceLog::GetInstance()->AddTraceEventExplicit
+
////////////////////////////////////////////////////////////////////////////////
// Implementation detail: trace event macros create temporary variables
@@ -638,6 +683,23 @@
} \
} while (0)
+// Implementation detail: internal macro to create static category and add
+// event if the category is enabled.
+#define INTERNAL_TRACE_EVENT_ADD_EXPLICIT(phase, category, name, tid, \
+ ts, id, flags, ...) \
+ do { \
+ INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \
+ if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \
+ unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \
+ trace_event_internal::TraceID trace_event_trace_id( \
+ id, &trace_event_flags); \
+ trace_event_internal::AddTraceEventExplicit( \
+ phase, INTERNAL_TRACE_EVENT_UID(catstatic), \
+ name, tid, ts, trace_event_trace_id.data(), \
+ trace_event_flags, ##__VA_ARGS__); \
+ } \
+ } while (0)
+
// 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.
@@ -930,6 +992,18 @@ static inline int AddTraceEvent(char phase,
kNoThreshholdBeginId, kNoThresholdValue, flags);
}
+static inline int AddTraceEventExplicit(char phase,
+ const unsigned char* category_enabled,
+ const char* name,
+ int thread_id,
+ int64 timestamp,
+ unsigned long long id,
+ unsigned char flags) {
+ return TRACE_EVENT_API_ADD_TRACE_EVENT_EXPLICIT(
+ phase, category_enabled, name, thread_id, timestamp, id, kZeroNumArgs,
+ NULL, NULL, NULL, kNoThreshholdBeginId, kNoThresholdValue, flags);
+}
+
// Used by TRACE_EVENTx macro. Do not use directly.
class BASE_EXPORT TraceEndOnScopeClose {
public:
« no previous file with comments | « no previous file | base/debug/trace_event_impl.h » ('j') | base/debug/trace_event_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698