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

Side by Side Diff: base/trace_event/trace_event.h

Issue 1256263006: Moved the cross-project parts of trace_event.h to trace_event_common.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « base/trace_event/BUILD.gn ('k') | base/trace_event/trace_event.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 header file defines the set of trace_event macros without specifying
6 // how the events actually get collected and stored. If you need to expose trace
7 // events to some other universe, you can copy-and-paste this file as well as
8 // trace_event.h, modifying the macros contained there as necessary for the
9 // target platform. The end result is that multiple libraries can funnel events
10 // through to a shared trace event collector.
11
12 // Trace events are for tracking application performance and resource usage.
13 // Macros are provided to track:
14 // Begin and end of function calls
15 // Counters
16 //
17 // Events are issued against categories. Whereas LOG's
18 // categories are statically defined, TRACE categories are created
19 // implicitly with a string. For example:
20 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent",
21 // TRACE_EVENT_SCOPE_THREAD)
22 //
23 // It is often the case that one trace may belong in multiple categories at the
24 // same time. The first argument to the trace can be a comma-separated list of
25 // categories, forming a category group, like:
26 //
27 // TRACE_EVENT_INSTANT0("input,views", "OnMouseOver", TRACE_EVENT_SCOPE_THREAD)
28 //
29 // We can enable/disable tracing of OnMouseOver by enabling/disabling either
30 // category.
31 //
32 // Events can be INSTANT, or can be pairs of BEGIN and END in the same scope:
33 // TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly")
34 // doSomethingCostly()
35 // TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly")
36 // Note: our tools can't always determine the correct BEGIN/END pairs unless
37 // these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you
38 // need them to be in separate scopes.
39 //
40 // A common use case is to trace entire function scopes. This
41 // issues a trace BEGIN and END automatically:
42 // void doSomethingCostly() {
43 // TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly");
44 // ...
45 // }
46 //
47 // Additional parameters can be associated with an event:
48 // void doSomethingCostly2(int howMuch) {
49 // TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly",
50 // "howMuch", howMuch);
51 // ...
52 // }
53 //
54 // The trace system will automatically add to this information the
55 // current process id, thread id, and a timestamp in microseconds.
56 //
57 // To trace an asynchronous procedure such as an IPC send/receive, use
58 // ASYNC_BEGIN and ASYNC_END:
59 // [single threaded sender code]
60 // static int send_count = 0;
61 // ++send_count;
62 // TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count);
63 // Send(new MyMessage(send_count));
64 // [receive code]
65 // void OnMyMessage(send_count) {
66 // TRACE_EVENT_ASYNC_END0("ipc", "message", send_count);
67 // }
68 // The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs.
69 // ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process.
70 // Pointers can be used for the ID parameter, and they will be mangled
71 // internally so that the same pointer on two different processes will not
72 // match. For example:
73 // class MyTracedClass {
74 // public:
75 // MyTracedClass() {
76 // TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this);
77 // }
78 // ~MyTracedClass() {
79 // TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this);
80 // }
81 // }
82 //
83 // Trace event also supports counters, which is a way to track a quantity
84 // as it varies over time. Counters are created with the following macro:
85 // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue);
86 //
87 // Counters are process-specific. The macro itself can be issued from any
88 // thread, however.
89 //
90 // Sometimes, you want to track two counters at once. You can do this with two
91 // counter macros:
92 // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]);
93 // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]);
94 // Or you can do it with a combined macro:
95 // TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter",
96 // "bytesPinned", g_myCounterValue[0],
97 // "bytesAllocated", g_myCounterValue[1]);
98 // This indicates to the tracing UI that these counters should be displayed
99 // in a single graph, as a summed area chart.
100 //
101 // Since counters are in a global namespace, you may want to disambiguate with a
102 // unique ID, by using the TRACE_COUNTER_ID* variations.
103 //
104 // By default, trace collection is compiled in, but turned off at runtime.
105 // Collecting trace data is the responsibility of the embedding
106 // application. In Chrome's case, navigating to about:tracing will turn on
107 // tracing and display data collected across all active processes.
108 //
109 //
110 // Memory scoping note:
111 // Tracing copies the pointers, not the string content, of the strings passed
112 // in for category_group, name, and arg_names. Thus, the following code will
113 // cause problems:
114 // char* str = strdup("importantName");
115 // TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD!
116 // free(str); // Trace system now has dangling pointer
117 //
118 // To avoid this issue with the |name| and |arg_name| parameters, use the
119 // TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime overhead.
120 // Notes: The category must always be in a long-lived char* (i.e. static const).
121 // The |arg_values|, when used, are always deep copied with the _COPY
122 // macros.
123 //
124 // When are string argument values copied:
125 // const char* arg_values are only referenced by default:
126 // TRACE_EVENT1("category", "name",
127 // "arg1", "literal string is only referenced");
128 // Use TRACE_STR_COPY to force copying of a const char*:
129 // TRACE_EVENT1("category", "name",
130 // "arg1", TRACE_STR_COPY("string will be copied"));
131 // std::string arg_values are always copied:
132 // TRACE_EVENT1("category", "name",
133 // "arg1", std::string("string will be copied"));
134 //
135 //
136 // Convertable notes:
137 // Converting a large data type to a string can be costly. To help with this,
138 // the trace framework provides an interface ConvertableToTraceFormat. If you
139 // inherit from it and implement the AppendAsTraceFormat method the trace
140 // framework will call back to your object to convert a trace output time. This
141 // means, if the category for the event is disabled, the conversion will not
142 // happen.
143 //
144 // class MyData : public base::trace_event::ConvertableToTraceFormat {
145 // public:
146 // MyData() {}
147 // void AppendAsTraceFormat(std::string* out) const override {
148 // out->append("{\"foo\":1}");
149 // }
150 // private:
151 // ~MyData() override {}
152 // DISALLOW_COPY_AND_ASSIGN(MyData);
153 // };
154 //
155 // TRACE_EVENT1("foo", "bar", "data",
156 // scoped_refptr<ConvertableToTraceFormat>(new MyData()));
157 //
158 // The trace framework will take ownership if the passed pointer and it will
159 // be free'd when the trace buffer is flushed.
160 //
161 // Note, we only do the conversion when the buffer is flushed, so the provided
162 // data object should not be modified after it's passed to the trace framework.
163 //
164 //
165 // Thread Safety:
166 // A thread safe singleton and mutex are used for thread safety. Category
167 // enabled flags are used to limit the performance impact when the system
168 // is not enabled.
169 //
170 // TRACE_EVENT macros first cache a pointer to a category. The categories are
171 // statically allocated and safe at all times, even after exit. Fetching a
172 // category is protected by the TraceLog::lock_. Multiple threads initializing
173 // the static variable is safe, as they will be serialized by the lock and
174 // multiple calls will return the same pointer to the category.
175 //
176 // Then the category_group_enabled flag is checked. This is a unsigned char, and
177 // not intended to be multithread safe. It optimizes access to AddTraceEvent
178 // which is threadsafe internally via TraceLog::lock_. The enabled flag may
179 // cause some threads to incorrectly call or skip calling AddTraceEvent near
180 // the time of the system being enabled or disabled. This is acceptable as
181 // we tolerate some data loss while the system is being enabled/disabled and
182 // because AddTraceEvent is threadsafe internally and checks the enabled state
183 // again under lock.
184 //
185 // Without the use of these static category pointers and enabled flags all
186 // trace points would carry a significant performance cost of acquiring a lock
187 // and resolving the category.
188
189 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_
190 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_
191 7
8 // This header file defines implementation details of how the trace macros in
9 // trace_event_common.h collect and store trace events. Anything not
10 // implementation-specific should go in trace_macros_common.h instead of here.
11
192 #include <string> 12 #include <string>
193 13
194 #include "base/atomicops.h" 14 #include "base/atomicops.h"
195 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "base/trace_event/trace_event_common.h"
196 #include "base/trace_event/trace_event_memory.h" 17 #include "base/trace_event/trace_event_memory.h"
197 #include "base/trace_event/trace_event_system_stats_monitor.h" 18 #include "base/trace_event/trace_event_system_stats_monitor.h"
198 #include "base/trace_event/trace_log.h" 19 #include "base/trace_event/trace_log.h"
199 #include "build/build_config.h" 20 #include "build/build_config.h"
200 21
201 // By default, const char* argument values are assumed to have long-lived scope 22 // By default, const char* argument values are assumed to have long-lived scope
202 // and will not be copied. Use this macro to force a const char* to be copied. 23 // and will not be copied. Use this macro to force a const char* to be copied.
203 #define TRACE_STR_COPY(str) \ 24 #define TRACE_STR_COPY(str) \
204 trace_event_internal::TraceStringWithCopy(str) 25 trace_event_internal::TraceStringWithCopy(str)
205 26
206 // This will mark the trace event as disabled by default. The user will need
207 // to explicitly enable the event.
208 #define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name
209
210 // By default, uint64 ID argument values are not mangled with the Process ID in 27 // By default, uint64 ID argument values are not mangled with the Process ID in
211 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. 28 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling.
212 #define TRACE_ID_MANGLE(id) \ 29 #define TRACE_ID_MANGLE(id) \
213 trace_event_internal::TraceID::ForceMangle(id) 30 trace_event_internal::TraceID::ForceMangle(id)
214 31
215 // By default, pointers are mangled with the Process ID in TRACE_EVENT_ASYNC 32 // By default, pointers are mangled with the Process ID in TRACE_EVENT_ASYNC
216 // macros. Use this macro to prevent Process ID mangling. 33 // macros. Use this macro to prevent Process ID mangling.
217 #define TRACE_ID_DONT_MANGLE(id) \ 34 #define TRACE_ID_DONT_MANGLE(id) \
218 trace_event_internal::TraceID::DontMangle(id) 35 trace_event_internal::TraceID::DontMangle(id)
219 36
220 // Records a pair of begin and end events called "name" for the current
221 // scope, with 0, 1 or 2 associated arguments. If the category is not
222 // enabled, then this does nothing.
223 // - category and name strings must have application lifetime (statics or
224 // literals). They may not include " chars.
225 #define TRACE_EVENT0(category_group, name) \
226 INTERNAL_TRACE_MEMORY(category_group, name) \
227 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name)
228 #define TRACE_EVENT_WITH_FLOW0(category_group, name, bind_id, flow_flags) \
229 INTERNAL_TRACE_MEMORY(category_group, name) \
230 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \
231 flow_flags)
232 #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
233 INTERNAL_TRACE_MEMORY(category_group, name) \
234 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val)
235 #define TRACE_EVENT_WITH_FLOW1(category_group, name, bind_id, flow_flags, \
236 arg1_name, arg1_val) \
237 INTERNAL_TRACE_MEMORY(category_group, name) \
238 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW( \
239 category_group, name, bind_id, flow_flags, arg1_name, arg1_val)
240 #define TRACE_EVENT2( \
241 category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) \
242 INTERNAL_TRACE_MEMORY(category_group, name) \
243 INTERNAL_TRACE_EVENT_ADD_SCOPED( \
244 category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)
245 #define TRACE_EVENT_WITH_FLOW2(category_group, name, bind_id, flow_flags, \
246 arg1_name, arg1_val, arg2_name, arg2_val) \
247 INTERNAL_TRACE_MEMORY(category_group, name) \
248 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \
249 flow_flags, arg1_name, \
250 arg1_val, arg2_name, arg2_val)
251
252 // Records events like TRACE_EVENT2 but uses |memory_tag| for memory tracing.
253 // Use this where |name| is too generic to accurately aggregate allocations.
254 #define TRACE_EVENT_WITH_MEMORY_TAG2( \
255 category, name, memory_tag, arg1_name, arg1_val, arg2_name, arg2_val) \
256 INTERNAL_TRACE_MEMORY(category, memory_tag) \
257 INTERNAL_TRACE_EVENT_ADD_SCOPED( \
258 category, name, arg1_name, arg1_val, arg2_name, arg2_val)
259
260 // UNSHIPPED_TRACE_EVENT* are like TRACE_EVENT* except that they are not
261 // included in official builds.
262
263 #if OFFICIAL_BUILD
264 #undef TRACING_IS_OFFICIAL_BUILD
265 #define TRACING_IS_OFFICIAL_BUILD 1
266 #elif !defined(TRACING_IS_OFFICIAL_BUILD)
267 #define TRACING_IS_OFFICIAL_BUILD 0
268 #endif
269
270 #if TRACING_IS_OFFICIAL_BUILD
271 #define UNSHIPPED_TRACE_EVENT0(category_group, name) (void)0
272 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
273 (void)0
274 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \
275 arg2_name, arg2_val) (void)0
276 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name, scope) (void)0
277 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, scope, \
278 arg1_name, arg1_val) (void)0
279 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category_group, name, scope, \
280 arg1_name, arg1_val, \
281 arg2_name, arg2_val) (void)0
282 #else
283 #define UNSHIPPED_TRACE_EVENT0(category_group, name) \
284 TRACE_EVENT0(category_group, name)
285 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \
286 TRACE_EVENT1(category_group, name, arg1_name, arg1_val)
287 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \
288 arg2_name, arg2_val) \
289 TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val)
290 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name, scope) \
291 TRACE_EVENT_INSTANT0(category_group, name, scope)
292 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, scope, \
293 arg1_name, arg1_val) \
294 TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val)
295 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category_group, name, scope, \
296 arg1_name, arg1_val, \
297 arg2_name, arg2_val) \
298 TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \
299 arg2_name, arg2_val)
300 #endif
301
302 // Records a single event called "name" immediately, with 0, 1 or 2
303 // associated arguments. If the category is not enabled, then this
304 // does nothing.
305 // - category and name strings must have application lifetime (statics or
306 // literals). They may not include " chars.
307 #define TRACE_EVENT_INSTANT0(category_group, name, scope) \
308 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \
309 category_group, name, TRACE_EVENT_FLAG_NONE | scope)
310 #define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) \
311 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \
312 category_group, name, TRACE_EVENT_FLAG_NONE | scope, \
313 arg1_name, arg1_val)
314 #define TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \
315 arg2_name, arg2_val) \
316 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \
317 category_group, name, TRACE_EVENT_FLAG_NONE | scope, \
318 arg1_name, arg1_val, arg2_name, arg2_val)
319 #define TRACE_EVENT_COPY_INSTANT0(category_group, name, scope) \
320 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \
321 category_group, name, TRACE_EVENT_FLAG_COPY | scope)
322 #define TRACE_EVENT_COPY_INSTANT1(category_group, name, scope, \
323 arg1_name, arg1_val) \
324 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \
325 category_group, name, TRACE_EVENT_FLAG_COPY | scope, arg1_name, \
326 arg1_val)
327 #define TRACE_EVENT_COPY_INSTANT2(category_group, name, scope, \
328 arg1_name, arg1_val, \
329 arg2_name, arg2_val) \
330 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \
331 category_group, name, TRACE_EVENT_FLAG_COPY | scope, \
332 arg1_name, arg1_val, arg2_name, arg2_val)
333
334 // Sets the current sample state to the given category and name (both must be 37 // Sets the current sample state to the given category and name (both must be
335 // constant strings). These states are intended for a sampling profiler. 38 // constant strings). These states are intended for a sampling profiler.
336 // Implementation note: we store category and name together because we don't 39 // Implementation note: we store category and name together because we don't
337 // want the inconsistency/expense of storing two pointers. 40 // want the inconsistency/expense of storing two pointers.
338 // |thread_bucket| is [0..2] and is used to statically isolate samples in one 41 // |thread_bucket| is [0..2] and is used to statically isolate samples in one
339 // thread from others. 42 // thread from others.
340 #define TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET( \ 43 #define TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET( \
341 bucket_number, category, name) \ 44 bucket_number, category, name) \
342 trace_event_internal:: \ 45 trace_event_internal:: \
343 TraceEventSamplingStateScope<bucket_number>::Set(category "\0" name) 46 TraceEventSamplingStateScope<bucket_number>::Set(category "\0" name)
344 47
345 // Returns a current sampling state of the given bucket. 48 // Returns a current sampling state of the given bucket.
346 #define TRACE_EVENT_GET_SAMPLING_STATE_FOR_BUCKET(bucket_number) \ 49 #define TRACE_EVENT_GET_SAMPLING_STATE_FOR_BUCKET(bucket_number) \
347 trace_event_internal::TraceEventSamplingStateScope<bucket_number>::Current() 50 trace_event_internal::TraceEventSamplingStateScope<bucket_number>::Current()
348 51
349 // Creates a scope of a sampling state of the given bucket. 52 // Creates a scope of a sampling state of the given bucket.
350 // 53 //
351 // { // The sampling state is set within this scope. 54 // { // The sampling state is set within this scope.
352 // TRACE_EVENT_SAMPLING_STATE_SCOPE_FOR_BUCKET(0, "category", "name"); 55 // TRACE_EVENT_SAMPLING_STATE_SCOPE_FOR_BUCKET(0, "category", "name");
353 // ...; 56 // ...;
354 // } 57 // }
355 #define TRACE_EVENT_SCOPED_SAMPLING_STATE_FOR_BUCKET( \ 58 #define TRACE_EVENT_SCOPED_SAMPLING_STATE_FOR_BUCKET( \
356 bucket_number, category, name) \ 59 bucket_number, category, name) \
357 trace_event_internal::TraceEventSamplingStateScope<bucket_number> \ 60 trace_event_internal::TraceEventSamplingStateScope<bucket_number> \
358 traceEventSamplingScope(category "\0" name); 61 traceEventSamplingScope(category "\0" name);
359 62
360 // Syntactic sugars for the sampling tracing in the main thread. 63 #define TRACE_EVENT_API_CURRENT_THREAD_ID \
361 #define TRACE_EVENT_SCOPED_SAMPLING_STATE(category, name) \ 64 static_cast<int>(base::PlatformThread::CurrentId())
362 TRACE_EVENT_SCOPED_SAMPLING_STATE_FOR_BUCKET(0, category, name)
363 #define TRACE_EVENT_GET_SAMPLING_STATE() \
364 TRACE_EVENT_GET_SAMPLING_STATE_FOR_BUCKET(0)
365 #define TRACE_EVENT_SET_SAMPLING_STATE(category, name) \
366 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(0, category, name)
367
368
369 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2
370 // associated arguments. If the category is not enabled, then this
371 // does nothing.
372 // - category and name strings must have application lifetime (statics or
373 // literals). They may not include " chars.
374 #define TRACE_EVENT_BEGIN0(category_group, name) \
375 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \
376 category_group, name, TRACE_EVENT_FLAG_NONE)
377 #define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val) \
378 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \
379 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
380 #define TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_val, \
381 arg2_name, arg2_val) \
382 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \
383 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
384 arg2_name, arg2_val)
385 #define TRACE_EVENT_COPY_BEGIN0(category_group, name) \
386 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \
387 category_group, name, TRACE_EVENT_FLAG_COPY)
388 #define TRACE_EVENT_COPY_BEGIN1(category_group, name, arg1_name, arg1_val) \
389 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \
390 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
391 #define TRACE_EVENT_COPY_BEGIN2(category_group, name, arg1_name, arg1_val, \
392 arg2_name, arg2_val) \
393 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \
394 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \
395 arg2_name, arg2_val)
396
397 // Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided.
398 // - |id| is used to match the _BEGIN event with the _END event.
399 // Events are considered to match if their category_group, name and id values
400 // all match. |id| must either be a pointer or an integer value up to 64 bits.
401 // If it's a pointer, the bits will be xored with a hash of the process ID so
402 // that the same pointer on two different processes will not collide.
403 #define TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(category_group, \
404 name, id, thread_id, timestamp) \
405 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
406 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \
407 timestamp, TRACE_EVENT_FLAG_NONE)
408 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \
409 category_group, name, id, thread_id, timestamp) \
410 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
411 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \
412 timestamp, TRACE_EVENT_FLAG_COPY)
413 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP1( \
414 category_group, name, id, thread_id, timestamp, arg1_name, arg1_val) \
415 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
416 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \
417 timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
418 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP2( \
419 category_group, name, id, thread_id, timestamp, arg1_name, arg1_val, \
420 arg2_name, arg2_val) \
421 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
422 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \
423 timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, \
424 arg2_val)
425
426 // Records a single END event for "name" immediately. If the category
427 // is not enabled, then this does nothing.
428 // - category and name strings must have application lifetime (statics or
429 // literals). They may not include " chars.
430 #define TRACE_EVENT_END0(category_group, name) \
431 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \
432 category_group, name, TRACE_EVENT_FLAG_NONE)
433 #define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val) \
434 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \
435 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
436 #define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, \
437 arg2_name, arg2_val) \
438 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \
439 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
440 arg2_name, arg2_val)
441 #define TRACE_EVENT_COPY_END0(category_group, name) \
442 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \
443 category_group, name, TRACE_EVENT_FLAG_COPY)
444 #define TRACE_EVENT_COPY_END1(category_group, name, arg1_name, arg1_val) \
445 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \
446 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
447 #define TRACE_EVENT_COPY_END2(category_group, name, arg1_name, arg1_val, \
448 arg2_name, arg2_val) \
449 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \
450 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \
451 arg2_name, arg2_val)
452
453 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided.
454 // - |id| is used to match the _BEGIN event with the _END event.
455 // Events are considered to match if their category_group, name and id values
456 // all match. |id| must either be a pointer or an integer value up to 64 bits.
457 // If it's a pointer, the bits will be xored with a hash of the process ID so
458 // that the same pointer on two different processes will not collide.
459 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category_group, \
460 name, id, thread_id, timestamp) \
461 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
462 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \
463 timestamp, TRACE_EVENT_FLAG_NONE)
464 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \
465 category_group, name, id, thread_id, timestamp) \
466 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
467 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \
468 timestamp, TRACE_EVENT_FLAG_COPY)
469 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP1( \
470 category_group, name, id, thread_id, timestamp, arg1_name, arg1_val) \
471 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
472 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \
473 timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val)
474 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP2( \
475 category_group, name, id, thread_id, timestamp, arg1_name, arg1_val, \
476 arg2_name, arg2_val) \
477 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
478 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \
479 timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, \
480 arg2_val)
481
482 // Records the value of a counter called "name" immediately. Value
483 // must be representable as a 32 bit integer.
484 // - category and name strings must have application lifetime (statics or
485 // literals). They may not include " chars.
486 #define TRACE_COUNTER1(category_group, name, value) \
487 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \
488 category_group, name, TRACE_EVENT_FLAG_NONE, \
489 "value", static_cast<int>(value))
490 #define TRACE_COPY_COUNTER1(category_group, name, value) \
491 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \
492 category_group, name, TRACE_EVENT_FLAG_COPY, \
493 "value", static_cast<int>(value))
494
495 // Records the values of a multi-parted counter called "name" immediately.
496 // The UI will treat value1 and value2 as parts of a whole, displaying their
497 // values as a stacked-bar chart.
498 // - category and name strings must have application lifetime (statics or
499 // literals). They may not include " chars.
500 #define TRACE_COUNTER2(category_group, name, value1_name, value1_val, \
501 value2_name, value2_val) \
502 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \
503 category_group, name, TRACE_EVENT_FLAG_NONE, \
504 value1_name, static_cast<int>(value1_val), \
505 value2_name, static_cast<int>(value2_val))
506 #define TRACE_COPY_COUNTER2(category_group, name, value1_name, value1_val, \
507 value2_name, value2_val) \
508 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \
509 category_group, name, TRACE_EVENT_FLAG_COPY, \
510 value1_name, static_cast<int>(value1_val), \
511 value2_name, static_cast<int>(value2_val))
512
513 // Records the value of a counter called "name" immediately. Value
514 // must be representable as a 32 bit integer.
515 // - category and name strings must have application lifetime (statics or
516 // literals). They may not include " chars.
517 // - |id| is used to disambiguate counters with the same name. It must either
518 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
519 // will be xored with a hash of the process ID so that the same pointer on
520 // two different processes will not collide.
521 #define TRACE_COUNTER_ID1(category_group, name, id, value) \
522 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \
523 category_group, name, id, TRACE_EVENT_FLAG_NONE, \
524 "value", static_cast<int>(value))
525 #define TRACE_COPY_COUNTER_ID1(category_group, name, id, value) \
526 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \
527 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
528 "value", static_cast<int>(value))
529
530 // Records the values of a multi-parted counter called "name" immediately.
531 // The UI will treat value1 and value2 as parts of a whole, displaying their
532 // values as a stacked-bar chart.
533 // - category and name strings must have application lifetime (statics or
534 // literals). They may not include " chars.
535 // - |id| is used to disambiguate counters with the same name. It must either
536 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits
537 // will be xored with a hash of the process ID so that the same pointer on
538 // two different processes will not collide.
539 #define TRACE_COUNTER_ID2(category_group, name, id, value1_name, value1_val, \
540 value2_name, value2_val) \
541 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \
542 category_group, name, id, TRACE_EVENT_FLAG_NONE, \
543 value1_name, static_cast<int>(value1_val), \
544 value2_name, static_cast<int>(value2_val))
545 #define TRACE_COPY_COUNTER_ID2(category_group, name, id, value1_name, \
546 value1_val, value2_name, value2_val) \
547 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \
548 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
549 value1_name, static_cast<int>(value1_val), \
550 value2_name, static_cast<int>(value2_val))
551
552 // TRACE_EVENT_SAMPLE_* events are injected by the sampling profiler.
553 #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP0(category_group, name, \
554 thread_id, timestamp) \
555 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
556 TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \
557 TRACE_EVENT_FLAG_NONE)
558
559 #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP1( \
560 category_group, name, thread_id, timestamp, arg1_name, arg1_val) \
561 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
562 TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \
563 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
564
565 #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP2(category_group, name, \
566 thread_id, timestamp, \
567 arg1_name, arg1_val, \
568 arg2_name, arg2_val) \
569 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
570 TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \
571 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val)
572
573 // ASYNC_STEP_* APIs should be only used by legacy code. New code should
574 // consider using NESTABLE_ASYNC_* APIs to describe substeps within an async
575 // event.
576 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2
577 // associated arguments. If the category is not enabled, then this
578 // does nothing.
579 // - category and name strings must have application lifetime (statics or
580 // literals). They may not include " chars.
581 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC
582 // events are considered to match if their category_group, name and id values
583 // all match. |id| must either be a pointer or an integer value up to 64 bits.
584 // If it's a pointer, the bits will be xored with a hash of the process ID so
585 // that the same pointer on two different processes will not collide.
586 //
587 // An asynchronous operation can consist of multiple phases. The first phase is
588 // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the
589 // ASYNC_STEP_INTO or ASYNC_STEP_PAST macros. The ASYNC_STEP_INTO macro will
590 // annotate the block following the call. The ASYNC_STEP_PAST macro will
591 // annotate the block prior to the call. Note that any particular event must use
592 // only STEP_INTO or STEP_PAST macros; they can not mix and match. When the
593 // operation completes, call ASYNC_END.
594 //
595 // An ASYNC trace typically occurs on a single thread (if not, they will only be
596 // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that
597 // operation must use the same |name| and |id|. Each step can have its own
598 // args.
599 #define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \
600 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
601 category_group, name, id, TRACE_EVENT_FLAG_NONE)
602 #define TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
603 arg1_val) \
604 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
605 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
606 #define TRACE_EVENT_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
607 arg1_val, arg2_name, arg2_val) \
608 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
609 category_group, name, id, TRACE_EVENT_FLAG_NONE, \
610 arg1_name, arg1_val, arg2_name, arg2_val)
611 #define TRACE_EVENT_COPY_ASYNC_BEGIN0(category_group, name, id) \
612 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
613 category_group, name, id, TRACE_EVENT_FLAG_COPY)
614 #define TRACE_EVENT_COPY_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
615 arg1_val) \
616 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
617 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
618 arg1_name, arg1_val)
619 #define TRACE_EVENT_COPY_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
620 arg1_val, arg2_name, arg2_val) \
621 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \
622 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
623 arg1_name, arg1_val, arg2_name, arg2_val)
624
625 // Similar to TRACE_EVENT_ASYNC_BEGINx but with a custom |at| timestamp
626 // provided.
627 #define TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, \
628 name, id, timestamp) \
629 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
630 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \
631 static_cast<int>(base::PlatformThread::CurrentId()), \
632 timestamp, TRACE_EVENT_FLAG_NONE)
633 #define TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, \
634 name, id, timestamp) \
635 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
636 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \
637 static_cast<int>(base::PlatformThread::CurrentId()), \
638 timestamp, TRACE_EVENT_FLAG_COPY)
639
640 // Records a single ASYNC_STEP_INTO event for |step| immediately. If the
641 // category is not enabled, then this does nothing. The |name| and |id| must
642 // match the ASYNC_BEGIN event above. The |step| param identifies this step
643 // within the async event. This should be called at the beginning of the next
644 // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
645 // ASYNC_STEP_PAST events.
646 #define TRACE_EVENT_ASYNC_STEP_INTO0(category_group, name, id, step) \
647 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \
648 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step)
649 #define TRACE_EVENT_ASYNC_STEP_INTO1(category_group, name, id, step, \
650 arg1_name, arg1_val) \
651 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \
652 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \
653 arg1_name, arg1_val)
654
655 // Similar to TRACE_EVENT_ASYNC_STEP_INTOx but with a custom |at| timestamp
656 // provided.
657 #define TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0(category_group, name, \
658 id, step, timestamp) \
659 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
660 TRACE_EVENT_PHASE_ASYNC_STEP_INTO, category_group, name, id, \
661 static_cast<int>(base::PlatformThread::CurrentId()), \
662 timestamp, TRACE_EVENT_FLAG_NONE, "step", step)
663
664 // Records a single ASYNC_STEP_PAST event for |step| immediately. If the
665 // category is not enabled, then this does nothing. The |name| and |id| must
666 // match the ASYNC_BEGIN event above. The |step| param identifies this step
667 // within the async event. This should be called at the beginning of the next
668 // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any
669 // ASYNC_STEP_INTO events.
670 #define TRACE_EVENT_ASYNC_STEP_PAST0(category_group, name, id, step) \
671 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, \
672 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step)
673 #define TRACE_EVENT_ASYNC_STEP_PAST1(category_group, name, id, step, \
674 arg1_name, arg1_val) \
675 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, \
676 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \
677 arg1_name, arg1_val)
678
679 // Records a single ASYNC_END event for "name" immediately. If the category
680 // is not enabled, then this does nothing.
681 #define TRACE_EVENT_ASYNC_END0(category_group, name, id) \
682 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
683 category_group, name, id, TRACE_EVENT_FLAG_NONE)
684 #define TRACE_EVENT_ASYNC_END1(category_group, name, id, arg1_name, arg1_val) \
685 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
686 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
687 #define TRACE_EVENT_ASYNC_END2(category_group, name, id, arg1_name, arg1_val, \
688 arg2_name, arg2_val) \
689 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
690 category_group, name, id, TRACE_EVENT_FLAG_NONE, \
691 arg1_name, arg1_val, arg2_name, arg2_val)
692 #define TRACE_EVENT_COPY_ASYNC_END0(category_group, name, id) \
693 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
694 category_group, name, id, TRACE_EVENT_FLAG_COPY)
695 #define TRACE_EVENT_COPY_ASYNC_END1(category_group, name, id, arg1_name, \
696 arg1_val) \
697 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
698 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
699 arg1_name, arg1_val)
700 #define TRACE_EVENT_COPY_ASYNC_END2(category_group, name, id, arg1_name, \
701 arg1_val, arg2_name, arg2_val) \
702 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \
703 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
704 arg1_name, arg1_val, arg2_name, arg2_val)
705
706 // Similar to TRACE_EVENT_ASYNC_ENDx but with a custom |at| timestamp provided.
707 #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(category_group, \
708 name, id, timestamp) \
709 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
710 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \
711 static_cast<int>(base::PlatformThread::CurrentId()), \
712 timestamp, TRACE_EVENT_FLAG_NONE)
713
714 // NESTABLE_ASYNC_* APIs are used to describe an async operation, which can
715 // be nested within a NESTABLE_ASYNC event and/or have inner NESTABLE_ASYNC
716 // events.
717 // - category and name strings must have application lifetime (statics or
718 // literals). They may not include " chars.
719 // - A pair of NESTABLE_ASYNC_BEGIN event and NESTABLE_ASYNC_END event is
720 // considered as a match if their category_group, name and id all match.
721 // - |id| must either be a pointer or an integer value up to 64 bits.
722 // If it's a pointer, the bits will be xored with a hash of the process ID so
723 // that the same pointer on two different processes will not collide.
724 // - |id| is used to match a child NESTABLE_ASYNC event with its parent
725 // NESTABLE_ASYNC event. Therefore, events in the same nested event tree must
726 // be logged using the same id and category_group.
727 //
728 // Unmatched NESTABLE_ASYNC_END event will be parsed as an event that starts
729 // at the first NESTABLE_ASYNC event of that id, and unmatched
730 // NESTABLE_ASYNC_BEGIN event will be parsed as an event that ends at the last
731 // NESTABLE_ASYNC event of that id. Corresponding warning messages for
732 // unmatched events will be shown in the analysis view.
733
734 // Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with
735 // 0, 1 or 2 associated arguments. If the category is not enabled, then this
736 // does nothing.
737 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_group, name, id) \
738 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
739 category_group, name, id, TRACE_EVENT_FLAG_NONE)
740 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(category_group, name, id, arg1_name, \
741 arg1_val) \
742 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
743 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
744 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \
745 arg1_val, arg2_name, arg2_val) \
746 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
747 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
748 arg2_name, arg2_val)
749 // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 0
750 // or 2 associated arguments. If the category is not enabled, then this does
751 // nothing.
752 #define TRACE_EVENT_NESTABLE_ASYNC_END0(category_group, name, id) \
753 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
754 category_group, name, id, TRACE_EVENT_FLAG_NONE)
755 #define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \
756 arg1_val, arg2_name, arg2_val) \
757 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
758 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
759 arg2_name, arg2_val)
760
761 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TTS2(category_group, name, \
762 id, arg1_name, arg1_val, arg2_name, arg2_val) \
763 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \
764 category_group, name, id, \
765 TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, \
766 arg1_name, arg1_val, arg2_name, arg2_val)
767 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TTS2(category_group, name, \
768 id, arg1_name, arg1_val, arg2_name, arg2_val) \
769 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \
770 category_group, name, id, \
771 TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, \
772 arg1_name, arg1_val, arg2_name, arg2_val)
773
774 // Similar to TRACE_EVENT_NESTABLE_ASYNC_{BEGIN,END}x but with a custom
775 // |timestamp| provided.
776 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, name, \
777 id, timestamp) \
778 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
779 TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \
780 static_cast<int>(base::PlatformThread::CurrentId()), timestamp, \
781 TRACE_EVENT_FLAG_NONE)
782
783 #define TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(category_group, name, \
784 id, timestamp) \
785 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
786 TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \
787 static_cast<int>(base::PlatformThread::CurrentId()), timestamp, \
788 TRACE_EVENT_FLAG_NONE)
789
790 // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately,
791 // with 2 associated arguments. If the category is not enabled, then this
792 // does nothing.
793 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2(category_group, name, id, \
794 arg1_name, arg1_val, arg2_name, arg2_val) \
795 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \
796 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \
797 arg2_name, arg2_val)
798
799 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2
800 // associated arguments. If the category is not enabled, then this
801 // does nothing.
802 // - category and name strings must have application lifetime (statics or
803 // literals). They may not include " chars.
804 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW
805 // events are considered to match if their category_group, name and id values
806 // all match. |id| must either be a pointer or an integer value up to 64 bits.
807 // If it's a pointer, the bits will be xored with a hash of the process ID so
808 // that the same pointer on two different processes will not collide.
809 // FLOW events are different from ASYNC events in how they are drawn by the
810 // tracing UI. A FLOW defines asynchronous data flow, such as posting a task
811 // (FLOW_BEGIN) and later executing that task (FLOW_END). Expect FLOWs to be
812 // drawn as lines or arrows from FLOW_BEGIN scopes to FLOW_END scopes. Similar
813 // to ASYNC, a FLOW can consist of multiple phases. The first phase is defined
814 // by the FLOW_BEGIN calls. Additional phases can be defined using the FLOW_STEP
815 // macros. When the operation completes, call FLOW_END. An async operation can
816 // span threads and processes, but all events in that operation must use the
817 // same |name| and |id|. Each event can have its own args.
818 #define TRACE_EVENT_FLOW_BEGIN0(category_group, name, id) \
819 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
820 category_group, name, id, TRACE_EVENT_FLAG_NONE)
821 #define TRACE_EVENT_FLOW_BEGIN1(category_group, name, id, arg1_name, arg1_val) \
822 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
823 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
824 #define TRACE_EVENT_FLOW_BEGIN2(category_group, name, id, arg1_name, arg1_val, \
825 arg2_name, arg2_val) \
826 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
827 category_group, name, id, TRACE_EVENT_FLAG_NONE, \
828 arg1_name, arg1_val, arg2_name, arg2_val)
829 #define TRACE_EVENT_COPY_FLOW_BEGIN0(category_group, name, id) \
830 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
831 category_group, name, id, TRACE_EVENT_FLAG_COPY)
832 #define TRACE_EVENT_COPY_FLOW_BEGIN1(category_group, name, id, arg1_name, \
833 arg1_val) \
834 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
835 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
836 arg1_name, arg1_val)
837 #define TRACE_EVENT_COPY_FLOW_BEGIN2(category_group, name, id, arg1_name, \
838 arg1_val, arg2_name, arg2_val) \
839 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \
840 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
841 arg1_name, arg1_val, arg2_name, arg2_val)
842
843 // Records a single FLOW_STEP event for |step| immediately. If the category
844 // is not enabled, then this does nothing. The |name| and |id| must match the
845 // FLOW_BEGIN event above. The |step| param identifies this step within the
846 // async event. This should be called at the beginning of the next phase of an
847 // asynchronous operation.
848 #define TRACE_EVENT_FLOW_STEP0(category_group, name, id, step) \
849 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
850 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step)
851 #define TRACE_EVENT_FLOW_STEP1(category_group, name, id, step, \
852 arg1_name, arg1_val) \
853 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
854 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \
855 arg1_name, arg1_val)
856 #define TRACE_EVENT_COPY_FLOW_STEP0(category_group, name, id, step) \
857 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
858 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step)
859 #define TRACE_EVENT_COPY_FLOW_STEP1(category_group, name, id, step, \
860 arg1_name, arg1_val) \
861 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \
862 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \
863 arg1_name, arg1_val)
864
865 // Records a single FLOW_END event for "name" immediately. If the category
866 // is not enabled, then this does nothing.
867 #define TRACE_EVENT_FLOW_END0(category_group, name, id) \
868 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
869 category_group, name, id, TRACE_EVENT_FLAG_NONE)
870 #define TRACE_EVENT_FLOW_END_BIND_TO_ENCLOSING0(category_group, name, id) \
871 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
872 category_group, name, id, TRACE_EVENT_FLAG_BIND_TO_ENCLOSING)
873 #define TRACE_EVENT_FLOW_END1(category_group, name, id, arg1_name, arg1_val) \
874 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
875 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val)
876 #define TRACE_EVENT_FLOW_END2(category_group, name, id, arg1_name, arg1_val, \
877 arg2_name, arg2_val) \
878 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
879 category_group, name, id, TRACE_EVENT_FLAG_NONE, \
880 arg1_name, arg1_val, arg2_name, arg2_val)
881 #define TRACE_EVENT_COPY_FLOW_END0(category_group, name, id) \
882 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
883 category_group, name, id, TRACE_EVENT_FLAG_COPY)
884 #define TRACE_EVENT_COPY_FLOW_END1(category_group, name, id, arg1_name, \
885 arg1_val) \
886 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
887 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
888 arg1_name, arg1_val)
889 #define TRACE_EVENT_COPY_FLOW_END2(category_group, name, id, arg1_name, \
890 arg1_val, arg2_name, arg2_val) \
891 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \
892 category_group, name, id, TRACE_EVENT_FLAG_COPY, \
893 arg1_name, arg1_val, arg2_name, arg2_val)
894
895 // Macros to track the life time and value of arbitrary client objects.
896 // See also TraceTrackableObject.
897 #define TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group, name, id) \
898 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_CREATE_OBJECT, \
899 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE)
900
901 #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, snapshot) \
902 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \
903 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\
904 "snapshot", snapshot)
905
906 #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID_AND_TIMESTAMP( \
907 category_group, name, id, timestamp, snapshot) \
908 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \
909 TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, category_group, name, \
910 TRACE_ID_DONT_MANGLE(id), \
911 static_cast<int>(base::PlatformThread::CurrentId()), timestamp, \
912 TRACE_EVENT_FLAG_NONE, "snapshot", snapshot)
913
914 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \
915 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \
916 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE)
917 65
918 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ 66 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \
919 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ 67 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \
920 (base::trace_event::TraceLog::ENABLED_FOR_RECORDING | \ 68 (base::trace_event::TraceLog::ENABLED_FOR_RECORDING | \
921 base::trace_event::TraceLog::ENABLED_FOR_EVENT_CALLBACK | \ 69 base::trace_event::TraceLog::ENABLED_FOR_EVENT_CALLBACK | \
922 base::trace_event::TraceLog::ENABLED_FOR_ETW_EXPORT)) 70 base::trace_event::TraceLog::ENABLED_FOR_ETW_EXPORT))
923 71
924 // Macro to efficiently determine if a given category group is enabled.
925 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \
926 do { \
927 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
928 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
929 *ret = true; \
930 } else { \
931 *ret = false; \
932 } \
933 } while (0)
934
935 // Macro to explicitly warm up a given category group. This could be useful in
936 // cases where we want to initialize a category group before any trace events
937 // for that category group is reported. For example, to have a category group
938 // always show up in the "record categories" list for manually selecting
939 // settings in about://tracing.
940 #define TRACE_EVENT_WARMUP_CATEGORY(category_group) \
941 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group)
942
943 // Macro to efficiently determine, through polling, if a new trace has begun.
944 #define TRACE_EVENT_IS_NEW_TRACE(ret) \
945 do { \
946 static int INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = 0; \
947 int num_traces_recorded = TRACE_EVENT_API_GET_NUM_TRACES_RECORDED(); \
948 if (num_traces_recorded != -1 && \
949 num_traces_recorded != \
950 INTERNAL_TRACE_EVENT_UID(lastRecordingNumber)) { \
951 INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = \
952 num_traces_recorded; \
953 *ret = true; \
954 } else { \
955 *ret = false; \
956 } \
957 } while (0)
958
959 //////////////////////////////////////////////////////////////////////////////// 72 ////////////////////////////////////////////////////////////////////////////////
960 // Implementation specific tracing API definitions. 73 // Implementation specific tracing API definitions.
961 74
962 // Get a pointer to the enabled state of the given trace category. Only 75 // Get a pointer to the enabled state of the given trace category. Only
963 // long-lived literal strings should be given as the category group. The 76 // long-lived literal strings should be given as the category group. The
964 // returned pointer can be held permanently in a local static for example. If 77 // returned pointer can be held permanently in a local static for example. If
965 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled, 78 // the unsigned char is non-zero, tracing is enabled. If tracing is enabled,
966 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled 79 // TRACE_EVENT_API_ADD_TRACE_EVENT can be called. It's OK if tracing is disabled
967 // between the load of the tracing state and the call to 80 // between the load of the tracing state and the call to
968 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out 81 // TRACE_EVENT_API_ADD_TRACE_EVENT, because this flag only provides an early out
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1165 id, &trace_event_flags); \ 278 id, &trace_event_flags); \
1166 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ 279 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \
1167 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ 280 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
1168 name, trace_event_trace_id.data(), trace_event_internal::kNoId, \ 281 name, trace_event_trace_id.data(), trace_event_internal::kNoId, \
1169 thread_id, base::TraceTicks::FromInternalValue(timestamp), \ 282 thread_id, base::TraceTicks::FromInternalValue(timestamp), \
1170 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ 283 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \
1171 trace_event_internal::kNoId, ##__VA_ARGS__); \ 284 trace_event_internal::kNoId, ##__VA_ARGS__); \
1172 } \ 285 } \
1173 } while (0) 286 } while (0)
1174 287
1175 // Notes regarding the following definitions:
1176 // New values can be added and propagated to third party libraries, but existing
1177 // definitions must never be changed, because third party libraries may use old
1178 // definitions.
1179
1180 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair.
1181 #define TRACE_EVENT_PHASE_BEGIN ('B')
1182 #define TRACE_EVENT_PHASE_END ('E')
1183 #define TRACE_EVENT_PHASE_COMPLETE ('X')
1184 #define TRACE_EVENT_PHASE_INSTANT ('I')
1185 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S')
1186 #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T')
1187 #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p')
1188 #define TRACE_EVENT_PHASE_ASYNC_END ('F')
1189 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN ('b')
1190 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_END ('e')
1191 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT ('n')
1192 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s')
1193 #define TRACE_EVENT_PHASE_FLOW_STEP ('t')
1194 #define TRACE_EVENT_PHASE_FLOW_END ('f')
1195 #define TRACE_EVENT_PHASE_METADATA ('M')
1196 #define TRACE_EVENT_PHASE_COUNTER ('C')
1197 #define TRACE_EVENT_PHASE_SAMPLE ('P')
1198 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N')
1199 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O')
1200 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D')
1201 #define TRACE_EVENT_PHASE_MEMORY_DUMP ('v')
1202
1203 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT.
1204 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned int>(0))
1205 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned int>(1 << 0))
1206 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned int>(1 << 1))
1207 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned int>(1 << 2))
1208 #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned int>(1 << 3))
1209 #define TRACE_EVENT_FLAG_SCOPE_EXTRA (static_cast<unsigned int>(1 << 4))
1210 #define TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP (static_cast<unsigned int>(1 << 5))
1211 #define TRACE_EVENT_FLAG_ASYNC_TTS (static_cast<unsigned int>(1 << 6))
1212 #define TRACE_EVENT_FLAG_BIND_TO_ENCLOSING (static_cast<unsigned int>(1 << 7))
1213 #define TRACE_EVENT_FLAG_FLOW_IN (static_cast<unsigned int>(1 << 8))
1214 #define TRACE_EVENT_FLAG_FLOW_OUT (static_cast<unsigned int>(1 << 9))
1215 #define TRACE_EVENT_FLAG_HAS_CONTEXT_ID (static_cast<unsigned int>(1 << 10))
1216
1217 #define TRACE_EVENT_FLAG_SCOPE_MASK (static_cast<unsigned int>( \
1218 TRACE_EVENT_FLAG_SCOPE_OFFSET | TRACE_EVENT_FLAG_SCOPE_EXTRA))
1219
1220 // Type values for identifying types in the TraceValue union.
1221 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1))
1222 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2))
1223 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3))
1224 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4))
1225 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5))
1226 #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6))
1227 #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7))
1228 #define TRACE_VALUE_TYPE_CONVERTABLE (static_cast<unsigned char>(8))
1229
1230 // Enum reflecting the scope of an INSTANT event. Must fit within
1231 // TRACE_EVENT_FLAG_SCOPE_MASK.
1232 #define TRACE_EVENT_SCOPE_GLOBAL (static_cast<unsigned char>(0 << 3))
1233 #define TRACE_EVENT_SCOPE_PROCESS (static_cast<unsigned char>(1 << 3))
1234 #define TRACE_EVENT_SCOPE_THREAD (static_cast<unsigned char>(2 << 3))
1235
1236 #define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g')
1237 #define TRACE_EVENT_SCOPE_NAME_PROCESS ('p')
1238 #define TRACE_EVENT_SCOPE_NAME_THREAD ('t')
1239 288
1240 namespace trace_event_internal { 289 namespace trace_event_internal {
1241 290
1242 // Specify these values when the corresponding argument of AddTraceEvent is not 291 // Specify these values when the corresponding argument of AddTraceEvent is not
1243 // used. 292 // used.
1244 const int kZeroNumArgs = 0; 293 const int kZeroNumArgs = 0;
1245 const unsigned long long kNoId = 0; 294 const unsigned long long kNoId = 0;
1246 295
1247 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers 296 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers
1248 // are by default mangled with the Process ID so that they are unlikely to 297 // are by default mangled with the Process ID so that they are unlikely to
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
1802 const char* name_; 851 const char* name_;
1803 IDType id_; 852 IDType id_;
1804 853
1805 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 854 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1806 }; 855 };
1807 856
1808 } // namespace trace_event 857 } // namespace trace_event
1809 } // namespace base 858 } // namespace base
1810 859
1811 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 860 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « base/trace_event/BUILD.gn ('k') | base/trace_event/trace_event.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698