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

Unified Diff: base/debug/trace_event_win.h

Issue 23934003: Have all trace points emit to ETW. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/debug/trace_event_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/debug/trace_event_win.h
diff --git a/base/debug/trace_event_win.h b/base/debug/trace_event_win.h
index 2a900bb4314f055b67a24bfea4bcdc766a569424..9e1aab69ab46a2b41c338a00443a144b4a46bbe8 100644
--- a/base/debug/trace_event_win.h
+++ b/base/debug/trace_event_win.h
@@ -10,6 +10,7 @@
#include "base/base_export.h"
#include "base/debug/trace_event.h"
+#include "base/memory/ref_counted.h"
#include "base/win/event_trace_provider.h"
// Fwd.
@@ -27,8 +28,7 @@ class BASE_EXPORT TraceEventETWProvider : public base::win::EtwTraceProvider {
// This is a noop in this implementation.
static bool StartTracing();
- // Trace begin/end/instant events, this is the bottleneck implementation
- // all the others defer to.
+ // Trace begin/end/instant events.
// Allowing the use of std::string for name or extra is a convenience,
// whereas passing name or extra as a const char* avoids the construction
// of temporary std::string instances.
@@ -58,6 +58,26 @@ class BASE_EXPORT TraceEventETWProvider : public base::win::EtwTraceProvider {
return Trace(name, -1, type, id, extra, -1);
}
+ // Emit a trace event.
+ // The event is defined by |category_group|, |name| and |type|.
+ // |id| helps to identify related events.
+ // |num_args| indicates the number of custom arguments to add to the trace.
+ // It must be <= |kTraceMaxNumArgs|. The names of the arguments are specified
+ // in |arg_names|. |arg_types| indicates how to interpret the value of
+ // each argument. Finally, the value of an argument is obtained from
+ // |convertable_values| if its type is TRACE_VALUE_TYPE_CONVERTABLE,
+ // from |arg_values| otherwise.
+ static void TraceWithArgs(
+ const char* category_group,
+ const char* name,
+ char type,
+ unsigned long long id,
+ int num_args,
+ const char** arg_names,
+ const unsigned char* arg_types,
+ const unsigned long long* arg_values,
+ const scoped_refptr<ConvertableToTraceFormat>* convertable_values);
+
// Retrieves the singleton.
// Note that this may return NULL post-AtExit processing.
static TraceEventETWProvider* GetInstance();
@@ -67,11 +87,24 @@ class BASE_EXPORT TraceEventETWProvider : public base::win::EtwTraceProvider {
return enable_level() >= TRACE_LEVEL_INFORMATION;
}
+ // Exposed for unittesting only, allows resurrecting our
+ // singleton instance post-AtExit processing.
+ static void Resurrect();
+
+ private:
+ // Ensure only the provider can construct us.
+ friend struct StaticMemorySingletonTraits<TraceEventETWProvider>;
+ TraceEventETWProvider();
+
// Emit a trace of type |type| containing |name|, |id|, and |extra|.
// Note: |name| and |extra| must be NULL, or a zero-terminated string of
// length |name_len| or |extra_len| respectively.
- // Note: if name_len or extra_len are -1, the length of the corresponding
- // string will be used.
+ // The event format consists of:
+ // The "name" string as a zero-terminated ASCII string.
+ // The id pointer in the machine bitness.
+ // The "extra" string as a zero-terminated ASCII string.
+ // Optionally the stack trace, consisting of a DWORD "depth", followed
+ // by an array of void* (machine bitness) of length "depth".
void TraceEvent(const char* name,
size_t name_len,
char type,
@@ -79,14 +112,25 @@ class BASE_EXPORT TraceEventETWProvider : public base::win::EtwTraceProvider {
const char* extra,
size_t extra_len);
- // Exposed for unittesting only, allows resurrecting our
- // singleton instance post-AtExit processing.
- static void Resurrect();
-
- private:
- // Ensure only the provider can construct us.
- friend struct StaticMemorySingletonTraits<TraceEventETWProvider>;
- TraceEventETWProvider();
+ // Emit a trace event.
+ // The event format consists of:
+ // The "name" as a zero-terminated ASCII string.
+ // A 64 bits "id" to help identify related events.
+ // The "category" as a zero-terminated ASCII string.
+ // For each extra argument, a "name" followed by a "value", both
+ // zero-terminated strings.
+ // Optionally the stack trace, consisting of a DWORD "depth", followed
+ // by an array of void* (machine bitness) of length "depth".
+ void TraceEventWithArgs(
+ const char* category_group,
+ const char* name,
+ char type,
+ unsigned long long id,
+ int num_args,
+ const char** arg_names,
+ const unsigned char* arg_types,
+ const unsigned long long* arg_values,
+ const scoped_refptr<ConvertableToTraceFormat>* convertable_values);
DISALLOW_COPY_AND_ASSIGN(TraceEventETWProvider);
};
@@ -94,28 +138,26 @@ class BASE_EXPORT TraceEventETWProvider : public base::win::EtwTraceProvider {
// The ETW trace provider GUID.
BASE_EXPORT extern const GUID kChromeTraceProviderName;
-// The ETW event class GUID for 32 bit events.
+// The ETW event class GUID for old events from TRACE_EVENT_*_ETW macros.
BASE_EXPORT extern const GUID kTraceEventClass32;
-// The ETW event class GUID for 64 bit events.
-BASE_EXPORT extern const GUID kTraceEventClass64;
-
// The ETW event types, IDs 0x00-0x09 are reserved, so start at 0x10.
const base::win::EtwEventType kTraceEventTypeBegin = 0x10;
const base::win::EtwEventType kTraceEventTypeEnd = 0x11;
const base::win::EtwEventType kTraceEventTypeInstant = 0x12;
-// If this flag is set in enable flags
+// Enable flags that can be set for the trace session.
enum TraceEventETWFlags {
+ // Include a stack trace for each event.
CAPTURE_STACK_TRACE = 0x0001,
-};
-// The event format consists of:
-// The "name" string as a zero-terminated ASCII string.
-// The id pointer in the machine bitness.
-// The "extra" string as a zero-terminated ASCII string.
-// Optionally the stack trace, consisting of a DWORD "depth", followed
-// by an array of void* (machine bitness) of length "depth".
+ // Include simple arguments with traced events.
+ CAPTURE_SIMPLE_ARGUMENTS = 0x0002,
+
+ // Include all arguments with traced events. Some arguments can be quite
+ // large. Tracing them adds an overhead that can affect performance.
+ CAPTURE_ALL_ARGUMENTS = 0x0004
+};
} // namespace debug
} // namespace base
« no previous file with comments | « base/debug/trace_event_impl.cc ('k') | base/debug/trace_event_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698