Chromium Code Reviews| 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..452b88a5c1e6f1f8f595454ff06f6fa4c5896687 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/scoped_ptr.h" |
| #include "base/win/event_trace_provider.h" |
| // Fwd. |
| @@ -27,36 +28,44 @@ 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. |
| - // If -1 is passed for name_len or extra_len, the strlen of the string will |
| - // be used for length. |
| static void Trace(const char* name, |
| - size_t name_len, |
| char type, |
| const void* id, |
| - const char* extra, |
| - size_t extra_len); |
| + const char* extra); |
| // Allows passing extra as a std::string for convenience. |
| static void Trace(const char* name, |
| char type, |
| const void* id, |
| const std::string& extra) { |
| - return Trace(name, -1, type, id, extra.c_str(), extra.length()); |
| + return Trace(name, type, id, extra.c_str()); |
| } |
| - // Allows passing extra as a const char* to avoid constructing temporary |
| - // std::string instances where not needed. |
| - static void Trace(const char* name, |
| - char type, |
| - const void* id, |
| - const char* extra) { |
| - 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. |
| + // |thread_name| is the name of the thread that produced the event. |
| + // |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, |
| + const std::string& thread_name, |
| + int num_args, |
| + const char** arg_names, |
| + const unsigned char* arg_types, |
| + const unsigned long long* arg_values, |
| + scoped_ptr<ConvertableToTraceFormat> convertable_values[]); |
| // Retrieves the singleton. |
| // Note that this may return NULL post-AtExit processing. |
| @@ -67,18 +76,6 @@ class BASE_EXPORT TraceEventETWProvider : public base::win::EtwTraceProvider { |
| return enable_level() >= TRACE_LEVEL_INFORMATION; |
| } |
| - // 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. |
| - void TraceEvent(const char* name, |
| - size_t name_len, |
| - char type, |
| - const void* id, |
| - const char* extra, |
| - size_t extra_len); |
| - |
| // Exposed for unittesting only, allows resurrecting our |
| // singleton instance post-AtExit processing. |
| static void Resurrect(); |
| @@ -88,6 +85,35 @@ class BASE_EXPORT TraceEventETWProvider : public base::win::EtwTraceProvider { |
| friend struct StaticMemorySingletonTraits<TraceEventETWProvider>; |
| TraceEventETWProvider(); |
| + // Emit a trace event. |
|
Sigurður Ásgeirsson
2013/09/10 21:15:54
If you're defining a message format that's incompa
fdoray
2013/09/16 00:51:03
Done.
|
| + // It's possible to add up to |kTraceMaxNumArgs| custom arguments to |
| + // the trace. |arg_values| and |arg_names| are arrays of |num_args| strings |
| + // that indicate the names and values of the custom arguments. |
| + // The payload of the produced trace follows this format: |
| + // - Name (string) |
| + // - Id (unsigned long long) |
| + // - Category (string) |
| + // - Thread name (string) |
| + // - Name of parameter 1, or '\0' (string) |
| + // - Value of parameter 1, or '\0' (string) |
| + // - Name of parameter 2, or '\0' (string) |
| + // - Value of parameter 2, or '\0' (string) |
| + // If stack capture is enabled for the trace session: |
|
Sigurður Ásgeirsson
2013/09/10 21:15:54
It's not clear to me that this message format can
fdoray
2013/09/16 00:51:03
The new format can be parsed using this schema: ht
|
| + // - Stack size (DWORD) |
| + // - Stack pointers (stack size * void*) |
| + // Strings are null-terminated and have a variable size. |
| + // |
| + // Note: |name| and |category_group| must be NULL, or a zero-terminated |
| + // string. The length of |name| must be specified by |name_len|. |
| + void TraceEvent(const char* category_group, |
| + const char* name, |
| + char type, |
| + unsigned long long id, |
| + const std::string& thread_name, |
| + int num_args, |
| + const char** arg_names, |
| + std::string* arg_values); |
| + |
| DISALLOW_COPY_AND_ASSIGN(TraceEventETWProvider); |
| }; |