Chromium Code Reviews| 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 // This file contains the Windows-specific declarations for trace_event.h. | 5 // This file contains the Windows-specific declarations for trace_event.h. |
| 6 #ifndef BASE_DEBUG_TRACE_EVENT_WIN_H_ | 6 #ifndef BASE_DEBUG_TRACE_EVENT_WIN_H_ |
| 7 #define BASE_DEBUG_TRACE_EVENT_WIN_H_ | 7 #define BASE_DEBUG_TRACE_EVENT_WIN_H_ |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/base_export.h" | 11 #include "base/base_export.h" |
| 12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
| 13 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/win/event_trace_provider.h" | 14 #include "base/win/event_trace_provider.h" |
| 14 | 15 |
| 15 // Fwd. | 16 // Fwd. |
| 16 template <typename Type> | 17 template <typename Type> |
| 17 struct StaticMemorySingletonTraits; | 18 struct StaticMemorySingletonTraits; |
| 18 | 19 |
| 19 namespace base { | 20 namespace base { |
| 20 namespace debug { | 21 namespace debug { |
| 21 | 22 |
| 22 // This EtwTraceProvider subclass implements ETW logging | 23 // This EtwTraceProvider subclass implements ETW logging |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 51 | 52 |
| 52 // Allows passing extra as a const char* to avoid constructing temporary | 53 // Allows passing extra as a const char* to avoid constructing temporary |
| 53 // std::string instances where not needed. | 54 // std::string instances where not needed. |
| 54 static void Trace(const char* name, | 55 static void Trace(const char* name, |
| 55 char type, | 56 char type, |
| 56 const void* id, | 57 const void* id, |
| 57 const char* extra) { | 58 const char* extra) { |
| 58 return Trace(name, -1, type, id, extra, -1); | 59 return Trace(name, -1, type, id, extra, -1); |
| 59 } | 60 } |
| 60 | 61 |
| 62 // Emit a trace. The event is defined by |category_group|, |name| and |type|. | |
|
chrisha
2013/09/09 16:41:12
Emit a trace event.
fdoray
2013/09/09 19:38:59
Done.
| |
| 63 // |id| helps to identify related events. | |
| 64 // |thread_name| is the name of the thread that produced the event. | |
| 65 // |num_args| indicates the number of custom arguments to add to the trace. | |
| 66 // It must be <= |kTraceMaxNumArgs|. The names of the arguments are specified | |
| 67 // in |arg_names|. |arg_types| indicates how to interpret the value of | |
| 68 // each argument. Finally, the value of an argument is obtained from | |
| 69 // |convertable_values| if its type is TRACE_VALUE_TYPE_CONVERTABLE, | |
| 70 // from |arg_values| otherwise. | |
| 71 static void TraceWithArgs( | |
| 72 const char* category_group, | |
| 73 const char* name, | |
| 74 char type, | |
| 75 unsigned long long id, | |
| 76 const std::string& thread_name, | |
| 77 int num_args, | |
| 78 const char** arg_names, | |
| 79 const unsigned char* arg_types, | |
| 80 const unsigned long long* arg_values, | |
| 81 scoped_ptr<ConvertableToTraceFormat> convertable_values[]); | |
| 82 | |
| 61 // Retrieves the singleton. | 83 // Retrieves the singleton. |
| 62 // Note that this may return NULL post-AtExit processing. | 84 // Note that this may return NULL post-AtExit processing. |
| 63 static TraceEventETWProvider* GetInstance(); | 85 static TraceEventETWProvider* GetInstance(); |
| 64 | 86 |
| 65 // Returns true iff tracing is turned on. | 87 // Returns true iff tracing is turned on. |
| 66 bool IsTracing() { | 88 bool IsTracing() { |
| 67 return enable_level() >= TRACE_LEVEL_INFORMATION; | 89 return enable_level() >= TRACE_LEVEL_INFORMATION; |
| 68 } | 90 } |
| 69 | 91 |
| 70 // Emit a trace of type |type| containing |name|, |id|, and |extra|. | |
| 71 // Note: |name| and |extra| must be NULL, or a zero-terminated string of | |
| 72 // length |name_len| or |extra_len| respectively. | |
| 73 // Note: if name_len or extra_len are -1, the length of the corresponding | |
| 74 // string will be used. | |
| 75 void TraceEvent(const char* name, | |
| 76 size_t name_len, | |
| 77 char type, | |
| 78 const void* id, | |
| 79 const char* extra, | |
| 80 size_t extra_len); | |
| 81 | |
| 82 // Exposed for unittesting only, allows resurrecting our | 92 // Exposed for unittesting only, allows resurrecting our |
| 83 // singleton instance post-AtExit processing. | 93 // singleton instance post-AtExit processing. |
| 84 static void Resurrect(); | 94 static void Resurrect(); |
| 85 | 95 |
| 86 private: | 96 private: |
| 87 // Ensure only the provider can construct us. | 97 // Ensure only the provider can construct us. |
| 88 friend struct StaticMemorySingletonTraits<TraceEventETWProvider>; | 98 friend struct StaticMemorySingletonTraits<TraceEventETWProvider>; |
| 89 TraceEventETWProvider(); | 99 TraceEventETWProvider(); |
| 90 | 100 |
| 101 // Emit a trace. | |
|
chrisha
2013/09/09 16:41:12
Emit a trace event.
fdoray
2013/09/09 19:38:59
Done.
| |
| 102 // It's possible to add up to |kTraceMaxNumArgs| custom arguments to | |
| 103 // the trace. |arg_values| and |arg_names| are arrays of |num_args| strings | |
| 104 // that indicate the names and values of the custom arguments. | |
| 105 // The payload of the produced trace follows this format: | |
| 106 // - Name (string) | |
| 107 // - Id (unsigned long long) | |
| 108 // - Category (string) | |
| 109 // - Thread name (string) | |
| 110 // - Name of parameter 1, or '\0' (string) | |
| 111 // - Value of parameter 1, or '\0' (string) | |
| 112 // - Name of parameter 2, or '\0' (string) | |
| 113 // - Value of parameter 2, or '\0' (string) | |
| 114 // If stack capture is enabled for the trace session: | |
| 115 // - Stack size (DWORD) | |
| 116 // - Stack pointers (stack size * void*) | |
| 117 // Strings are null-terminated and have a variable size. | |
| 118 // | |
| 119 // Note: |name| and |category_group| must be NULL, or a zero-terminated | |
| 120 // string. The length of |name| must be specified by |name_len|. | |
|
chrisha
2013/09/09 16:41:12
Why do we need to specify a name_len and not a cat
fdoray
2013/09/09 19:38:59
Done.
I initially kept the |name_len| parameter f
| |
| 121 void TraceEvent(const char* category_group, | |
| 122 const char* name, | |
| 123 size_t name_len, | |
| 124 char type, | |
| 125 unsigned long long id, | |
| 126 const std::string& thread_name, | |
| 127 int num_args, | |
| 128 const char** arg_names, | |
| 129 std::string* arg_values); | |
| 130 | |
| 91 DISALLOW_COPY_AND_ASSIGN(TraceEventETWProvider); | 131 DISALLOW_COPY_AND_ASSIGN(TraceEventETWProvider); |
| 92 }; | 132 }; |
| 93 | 133 |
| 94 // The ETW trace provider GUID. | 134 // The ETW trace provider GUID. |
| 95 BASE_EXPORT extern const GUID kChromeTraceProviderName; | 135 BASE_EXPORT extern const GUID kChromeTraceProviderName; |
| 96 | 136 |
| 97 // The ETW event class GUID for 32 bit events. | 137 // The ETW event class GUID for 32 bit events. |
| 98 BASE_EXPORT extern const GUID kTraceEventClass32; | 138 BASE_EXPORT extern const GUID kTraceEventClass32; |
| 99 | 139 |
| 100 // The ETW event class GUID for 64 bit events. | 140 // The ETW event class GUID for 64 bit events. |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 114 // The "name" string as a zero-terminated ASCII string. | 154 // The "name" string as a zero-terminated ASCII string. |
| 115 // The id pointer in the machine bitness. | 155 // The id pointer in the machine bitness. |
| 116 // The "extra" string as a zero-terminated ASCII string. | 156 // The "extra" string as a zero-terminated ASCII string. |
| 117 // Optionally the stack trace, consisting of a DWORD "depth", followed | 157 // Optionally the stack trace, consisting of a DWORD "depth", followed |
| 118 // by an array of void* (machine bitness) of length "depth". | 158 // by an array of void* (machine bitness) of length "depth". |
| 119 | 159 |
| 120 } // namespace debug | 160 } // namespace debug |
| 121 } // namespace base | 161 } // namespace base |
| 122 | 162 |
| 123 #endif // BASE_DEBUG_TRACE_EVENT_WIN_H_ | 163 #endif // BASE_DEBUG_TRACE_EVENT_WIN_H_ |
| OLD | NEW |