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 header file defines the set of trace_event macros without specifying | 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 | 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 | 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 | 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 | 9 // target platform. The end result is that multiple libraries can funnel events |
10 // through to a shared trace event collector. | 10 // through to a shared trace event collector. |
11 | 11 |
12 // Trace events are for tracking application performance and resource usage. | 12 // Trace events are for tracking application performance and resource usage. |
13 // Macros are provided to track: | 13 // Macros are provided to track: |
14 // Begin and end of function calls | 14 // Begin and end of function calls |
15 // Counters | 15 // Counters |
16 // | 16 // |
17 // Events are issued against categories. Whereas LOG's | 17 // Events are issued against categories. Whereas LOG's |
18 // categories are statically defined, TRACE categories are created | 18 // categories are statically defined, TRACE categories are created |
19 // implicitly with a string. For example: | 19 // implicitly with a string. For example: |
20 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") | 20 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent") |
21 // | 21 // |
22 // It is often the case that one trace may belong in multiple categories at the | |
23 // same time. The first argument to the trace can be a comma-separated list of | |
24 // categories, forming a category group, like: | |
25 // | |
26 // TRACE_EVENT_INSTANT0("input,views", "OnMouseOver") | |
27 // | |
28 // We can enable/disable tracing of ImportantEvent by enabling/disabling either | |
nduca
2013/02/21 06:02:36
ImportantEvent -> OnMouseOver?
rterrazas
2013/02/25 05:55:02
Done.
| |
29 // category. | |
30 // | |
22 // Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: | 31 // Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: |
23 // TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") | 32 // TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") |
24 // doSomethingCostly() | 33 // doSomethingCostly() |
25 // TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") | 34 // TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") |
26 // Note: our tools can't always determine the correct BEGIN/END pairs unless | 35 // Note: our tools can't always determine the correct BEGIN/END pairs unless |
27 // these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you | 36 // these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you |
28 // need them to be in separate scopes. | 37 // need them to be in separate scopes. |
29 // | 38 // |
30 // A common use case is to trace entire function scopes. This | 39 // A common use case is to trace entire function scopes. This |
31 // issues a trace BEGIN and END automatically: | 40 // issues a trace BEGIN and END automatically: |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 // unique ID, by using the TRACE_COUNTER_ID* variations. | 101 // unique ID, by using the TRACE_COUNTER_ID* variations. |
93 // | 102 // |
94 // By default, trace collection is compiled in, but turned off at runtime. | 103 // By default, trace collection is compiled in, but turned off at runtime. |
95 // Collecting trace data is the responsibility of the embedding | 104 // Collecting trace data is the responsibility of the embedding |
96 // application. In Chrome's case, navigating to about:tracing will turn on | 105 // application. In Chrome's case, navigating to about:tracing will turn on |
97 // tracing and display data collected across all active processes. | 106 // tracing and display data collected across all active processes. |
98 // | 107 // |
99 // | 108 // |
100 // Memory scoping note: | 109 // Memory scoping note: |
101 // Tracing copies the pointers, not the string content, of the strings passed | 110 // Tracing copies the pointers, not the string content, of the strings passed |
102 // in for category, name, and arg_names. Thus, the following code will | 111 // in for category_group, name, and arg_names. Thus, the following code will |
103 // cause problems: | 112 // cause problems: |
104 // char* str = strdup("impprtantName"); | 113 // char* str = strdup("importantName"); |
105 // TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! | 114 // TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! |
106 // free(str); // Trace system now has dangling pointer | 115 // free(str); // Trace system now has dangling pointer |
107 // | 116 // |
108 // To avoid this issue with the |name| and |arg_name| parameters, use the | 117 // To avoid this issue with the |name| and |arg_name| parameters, use the |
109 // TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime overhead. | 118 // TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime overhead. |
110 // Notes: The category must always be in a long-lived char* (i.e. static const). | 119 // Notes: The category must always be in a long-lived char* (i.e. static const). |
111 // The |arg_values|, when used, are always deep copied with the _COPY | 120 // The |arg_values|, when used, are always deep copied with the _COPY |
112 // macros. | 121 // macros. |
113 // | 122 // |
114 // When are string argument values copied: | 123 // When are string argument values copied: |
(...skipping 12 matching lines...) Expand all Loading... | |
127 // A thread safe singleton and mutex are used for thread safety. Category | 136 // A thread safe singleton and mutex are used for thread safety. Category |
128 // enabled flags are used to limit the performance impact when the system | 137 // enabled flags are used to limit the performance impact when the system |
129 // is not enabled. | 138 // is not enabled. |
130 // | 139 // |
131 // TRACE_EVENT macros first cache a pointer to a category. The categories are | 140 // TRACE_EVENT macros first cache a pointer to a category. The categories are |
132 // statically allocated and safe at all times, even after exit. Fetching a | 141 // statically allocated and safe at all times, even after exit. Fetching a |
133 // category is protected by the TraceLog::lock_. Multiple threads initializing | 142 // category is protected by the TraceLog::lock_. Multiple threads initializing |
134 // the static variable is safe, as they will be serialized by the lock and | 143 // the static variable is safe, as they will be serialized by the lock and |
135 // multiple calls will return the same pointer to the category. | 144 // multiple calls will return the same pointer to the category. |
136 // | 145 // |
137 // Then the category_enabled flag is checked. This is a unsigned char, and | 146 // Then the category_group_enabled flag is checked. This is a unsigned char, and |
138 // not intended to be multithread safe. It optimizes access to AddTraceEvent | 147 // not intended to be multithread safe. It optimizes access to AddTraceEvent |
139 // which is threadsafe internally via TraceLog::lock_. The enabled flag may | 148 // which is threadsafe internally via TraceLog::lock_. The enabled flag may |
140 // cause some threads to incorrectly call or skip calling AddTraceEvent near | 149 // cause some threads to incorrectly call or skip calling AddTraceEvent near |
141 // the time of the system being enabled or disabled. This is acceptable as | 150 // the time of the system being enabled or disabled. This is acceptable as |
142 // we tolerate some data loss while the system is being enabled/disabled and | 151 // we tolerate some data loss while the system is being enabled/disabled and |
143 // because AddTraceEvent is threadsafe internally and checks the enabled state | 152 // because AddTraceEvent is threadsafe internally and checks the enabled state |
144 // again under lock. | 153 // again under lock. |
145 // | 154 // |
146 // Without the use of these static category pointers and enabled flags all | 155 // Without the use of these static category pointers and enabled flags all |
147 // trace points would carry a significant performance cost of aquiring a lock | 156 // trace points would carry a significant performance cost of aquiring a lock |
(...skipping 13 matching lines...) Expand all Loading... | |
161 // By default, uint64 ID argument values are not mangled with the Process ID in | 170 // By default, uint64 ID argument values are not mangled with the Process ID in |
162 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. | 171 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. |
163 #define TRACE_ID_MANGLE(id) \ | 172 #define TRACE_ID_MANGLE(id) \ |
164 trace_event_internal::TraceID::ForceMangle(id) | 173 trace_event_internal::TraceID::ForceMangle(id) |
165 | 174 |
166 // Records a pair of begin and end events called "name" for the current | 175 // Records a pair of begin and end events called "name" for the current |
167 // scope, with 0, 1 or 2 associated arguments. If the category is not | 176 // scope, with 0, 1 or 2 associated arguments. If the category is not |
168 // enabled, then this does nothing. | 177 // enabled, then this does nothing. |
169 // - category and name strings must have application lifetime (statics or | 178 // - category and name strings must have application lifetime (statics or |
170 // literals). They may not include " chars. | 179 // literals). They may not include " chars. |
171 #define TRACE_EVENT0(category, name) \ | 180 #define TRACE_EVENT0(category_group, name) \ |
172 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name) | 181 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name) |
173 #define TRACE_EVENT1(category, name, arg1_name, arg1_val) \ | 182 #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ |
174 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val) | 183 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val) |
175 #define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ | 184 #define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \ |
176 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \ | 185 arg2_val) \ |
186 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val, \ | |
177 arg2_name, arg2_val) | 187 arg2_name, arg2_val) |
178 | 188 |
179 // Same as TRACE_EVENT except that they are not included in official builds. | 189 // Same as TRACE_EVENT except that they are not included in official builds. |
180 #ifdef OFFICIAL_BUILD | 190 #ifdef OFFICIAL_BUILD |
181 #define UNSHIPPED_TRACE_EVENT0(category, name) (void)0 | 191 #define UNSHIPPED_TRACE_EVENT0(category_group, name) (void)0 |
182 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) (void)0 | 192 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) (void) 0 |
183 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \ | 193 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \ |
184 arg2_name, arg2_val) (void)0 | 194 arg2_name, arg2_val) (void)0 |
185 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name) (void)0 | 195 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name) (void)0 |
186 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ | 196 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, arg1_name, \ |
197 arg1_val) \ | |
187 (void)0 | 198 (void)0 |
188 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ | 199 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category_group, name, arg1_name, \ |
189 arg2_name, arg2_val) (void)0 | 200 arg1_val, arg2_name, arg2_val) (void)0 |
190 #else | 201 #else |
191 #define UNSHIPPED_TRACE_EVENT0(category, name) \ | 202 #define UNSHIPPED_TRACE_EVENT0(category_group, name) \ |
192 TRACE_EVENT0(category, name) | 203 TRACE_EVENT0(category_group, name) |
193 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) \ | 204 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ |
194 TRACE_EVENT1(category, name, arg1_name, arg1_val) | 205 TRACE_EVENT1(category_group, name, arg1_name, arg1_val) |
195 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \ | 206 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \ |
196 arg2_name, arg2_val) \ | 207 arg2_name, arg2_val) \ |
197 TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) | 208 TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) |
198 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name) \ | 209 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name) \ |
199 TRACE_EVENT_INSTANT0(category, name) | 210 TRACE_EVENT_INSTANT0(category_group, name) |
200 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ | 211 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, arg1_name, \ |
201 TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) | 212 arg1_val) \ |
202 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ | 213 TRACE_EVENT_INSTANT1(category_group, name, arg1_name, arg1_val) |
203 arg2_name, arg2_val) \ | 214 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category_group, name, arg1_name, \ |
204 TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ | 215 arg1_val, arg2_name, arg2_val) \ |
216 TRACE_EVENT_INSTANT2(category_group, name, arg1_name, arg1_val, \ | |
205 arg2_name, arg2_val) | 217 arg2_name, arg2_val) |
206 #endif | 218 #endif |
207 | 219 |
208 // Records a single event called "name" immediately, with 0, 1 or 2 | 220 // Records a single event called "name" immediately, with 0, 1 or 2 |
209 // associated arguments. If the category is not enabled, then this | 221 // associated arguments. If the category is not enabled, then this |
210 // does nothing. | 222 // does nothing. |
211 // - category and name strings must have application lifetime (statics or | 223 // - category and name strings must have application lifetime (statics or |
212 // literals). They may not include " chars. | 224 // literals). They may not include " chars. |
213 #define TRACE_EVENT_INSTANT0(category, name) \ | 225 #define TRACE_EVENT_INSTANT0(category_group, name) \ |
214 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 226 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
215 category, name, TRACE_EVENT_FLAG_NONE) | 227 category_group, name, TRACE_EVENT_FLAG_NONE) |
216 #define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ | 228 #define TRACE_EVENT_INSTANT1(category_group, name, arg1_name, arg1_val) \ |
217 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 229 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
218 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 230 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
219 #define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ | 231 #define TRACE_EVENT_INSTANT2(category_group, name, arg1_name, arg1_val, \ |
220 arg2_name, arg2_val) \ | 232 arg2_name, arg2_val) \ |
221 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 233 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
222 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 234 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
223 arg2_name, arg2_val) | 235 arg2_name, arg2_val) |
224 #define TRACE_EVENT_COPY_INSTANT0(category, name) \ | 236 #define TRACE_EVENT_COPY_INSTANT0(category_group, name) \ |
225 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 237 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
226 category, name, TRACE_EVENT_FLAG_COPY) | 238 category_group, name, TRACE_EVENT_FLAG_COPY) |
227 #define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ | 239 #define TRACE_EVENT_COPY_INSTANT1(category_group, name, arg1_name, arg1_val) \ |
228 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 240 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
229 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 241 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
230 #define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ | 242 #define TRACE_EVENT_COPY_INSTANT2(category_group, name, arg1_name, arg1_val, \ |
231 arg2_name, arg2_val) \ | 243 arg2_name, arg2_val) \ |
232 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 244 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
233 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 245 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
234 arg2_name, arg2_val) | 246 arg2_name, arg2_val) |
235 | 247 |
236 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 | 248 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 |
237 // associated arguments. If the category is not enabled, then this | 249 // associated arguments. If the category is not enabled, then this |
238 // does nothing. | 250 // does nothing. |
239 // - category and name strings must have application lifetime (statics or | 251 // - category and name strings must have application lifetime (statics or |
240 // literals). They may not include " chars. | 252 // literals). They may not include " chars. |
241 #define TRACE_EVENT_BEGIN0(category, name) \ | 253 #define TRACE_EVENT_BEGIN0(category_group, name) \ |
242 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 254 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
243 category, name, TRACE_EVENT_FLAG_NONE) | 255 category_group, name, TRACE_EVENT_FLAG_NONE) |
244 #define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ | 256 #define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val) \ |
245 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 257 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
246 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 258 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
247 #define TRACE_EVENT_BEGIN2(category, name, arg1_name, arg1_val, \ | 259 #define TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_val, \ |
248 arg2_name, arg2_val) \ | 260 arg2_name, arg2_val) \ |
249 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 261 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
250 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 262 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
251 arg2_name, arg2_val) | 263 arg2_name, arg2_val) |
252 #define TRACE_EVENT_COPY_BEGIN0(category, name) \ | 264 #define TRACE_EVENT_COPY_BEGIN0(category_group, name) \ |
253 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 265 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
254 category, name, TRACE_EVENT_FLAG_COPY) | 266 category_group, name, TRACE_EVENT_FLAG_COPY) |
255 #define TRACE_EVENT_COPY_BEGIN1(category, name, arg1_name, arg1_val) \ | 267 #define TRACE_EVENT_COPY_BEGIN1(category_group, name, arg1_name, arg1_val) \ |
256 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 268 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
257 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 269 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
258 #define TRACE_EVENT_COPY_BEGIN2(category, name, arg1_name, arg1_val, \ | 270 #define TRACE_EVENT_COPY_BEGIN2(category_group, name, arg1_name, arg1_val, \ |
259 arg2_name, arg2_val) \ | 271 arg2_name, arg2_val) \ |
260 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 272 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
261 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 273 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
262 arg2_name, arg2_val) | 274 arg2_name, arg2_val) |
263 | 275 |
264 // Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided. | 276 // Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided. |
265 // - |id| is used to match the _BEGIN event with the _END event. | 277 // - |id| is used to match the _BEGIN event with the _END event. |
266 // Events are considered to match if their category, name and id values all | 278 // Events are considered to match if their category_group, name and id values |
267 // match. |id| must either be a pointer or an integer value up to 64 bits. If | 279 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
268 // it's a pointer, the bits will be xored with a hash of the process ID so | 280 // If it's a pointer, the bits will be xored with a hash of the process ID so |
269 // that the same pointer on two different processes will not collide. | 281 // that the same pointer on two different processes will not collide. |
270 #define TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(category, \ | 282 #define TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(category_group, \ |
271 name, id, thread_id, timestamp) \ | 283 name, id, thread_id, timestamp) \ |
272 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 284 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
273 TRACE_EVENT_PHASE_ASYNC_BEGIN, category, name, id, thread_id, \ | 285 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ |
274 timestamp, TRACE_EVENT_FLAG_NONE) | 286 timestamp, TRACE_EVENT_FLAG_NONE) |
275 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \ | 287 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \ |
276 category, name, id, thread_id, timestamp) \ | 288 category_group, name, id, thread_id, timestamp) \ |
277 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 289 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
278 TRACE_EVENT_PHASE_ASYNC_BEGIN, category, name, id, thread_id, \ | 290 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ |
279 timestamp, TRACE_EVENT_FLAG_COPY) | 291 timestamp, TRACE_EVENT_FLAG_COPY) |
280 | 292 |
281 // Records a single END event for "name" immediately. If the category | 293 // Records a single END event for "name" immediately. If the category |
282 // is not enabled, then this does nothing. | 294 // is not enabled, then this does nothing. |
283 // - category and name strings must have application lifetime (statics or | 295 // - category and name strings must have application lifetime (statics or |
284 // literals). They may not include " chars. | 296 // literals). They may not include " chars. |
285 #define TRACE_EVENT_END0(category, name) \ | 297 #define TRACE_EVENT_END0(category_group, name) \ |
286 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 298 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
287 category, name, TRACE_EVENT_FLAG_NONE) | 299 category_group, name, TRACE_EVENT_FLAG_NONE) |
288 #define TRACE_EVENT_END1(category, name, arg1_name, arg1_val) \ | 300 #define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val) \ |
289 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 301 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
290 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 302 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
291 #define TRACE_EVENT_END2(category, name, arg1_name, arg1_val, \ | 303 #define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, \ |
292 arg2_name, arg2_val) \ | 304 arg2_name, arg2_val) \ |
293 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 305 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
294 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 306 category_group, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ |
295 arg2_name, arg2_val) | 307 arg2_name, arg2_val) |
296 #define TRACE_EVENT_COPY_END0(category, name) \ | 308 #define TRACE_EVENT_COPY_END0(category_group, name) \ |
297 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 309 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
298 category, name, TRACE_EVENT_FLAG_COPY) | 310 category_group, name, TRACE_EVENT_FLAG_COPY) |
299 #define TRACE_EVENT_COPY_END1(category, name, arg1_name, arg1_val) \ | 311 #define TRACE_EVENT_COPY_END1(category_group, name, arg1_name, arg1_val) \ |
300 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 312 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
301 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 313 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) |
302 #define TRACE_EVENT_COPY_END2(category, name, arg1_name, arg1_val, \ | 314 #define TRACE_EVENT_COPY_END2(category_group, name, arg1_name, arg1_val, \ |
303 arg2_name, arg2_val) \ | 315 arg2_name, arg2_val) \ |
304 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ | 316 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, \ |
305 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 317 category_group, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ |
306 arg2_name, arg2_val) | 318 arg2_name, arg2_val) |
307 | 319 |
308 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided. | 320 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided. |
309 // - |id| is used to match the _BEGIN event with the _END event. | 321 // - |id| is used to match the _BEGIN event with the _END event. |
310 // Events are considered to match if their category, name and id values all | 322 // Events are considered to match if their category_group, name and id values |
311 // match. |id| must either be a pointer or an integer value up to 64 bits. If | 323 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
312 // it's a pointer, the bits will be xored with a hash of the process ID so | 324 // If it's a pointer, the bits will be xored with a hash of the process ID so |
313 // that the same pointer on two different processes will not collide. | 325 // that the same pointer on two different processes will not collide. |
314 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category, \ | 326 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category_group, \ |
315 name, id, thread_id, timestamp) \ | 327 name, id, thread_id, timestamp) \ |
316 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 328 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
317 TRACE_EVENT_PHASE_ASYNC_END, category, name, id, thread_id, timestamp, \ | 329 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ |
318 TRACE_EVENT_FLAG_NONE) | 330 timestamp, TRACE_EVENT_FLAG_NONE) |
319 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \ | 331 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \ |
320 category, name, id, thread_id, timestamp) \ | 332 category_group, name, id, thread_id, timestamp) \ |
321 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 333 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
322 TRACE_EVENT_PHASE_ASYNC_END, category, name, id, thread_id, timestamp, \ | 334 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ |
323 TRACE_EVENT_FLAG_COPY) | 335 timestamp, TRACE_EVENT_FLAG_COPY) |
324 | 336 |
325 // Records the value of a counter called "name" immediately. Value | 337 // Records the value of a counter called "name" immediately. Value |
326 // must be representable as a 32 bit integer. | 338 // must be representable as a 32 bit integer. |
327 // - category and name strings must have application lifetime (statics or | 339 // - category and name strings must have application lifetime (statics or |
328 // literals). They may not include " chars. | 340 // literals). They may not include " chars. |
329 #define TRACE_COUNTER1(category, name, value) \ | 341 #define TRACE_COUNTER1(category_group, name, value) \ |
330 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 342 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
331 category, name, TRACE_EVENT_FLAG_NONE, \ | 343 category_group, name, TRACE_EVENT_FLAG_NONE, \ |
332 "value", static_cast<int>(value)) | 344 "value", static_cast<int>(value)) |
333 #define TRACE_COPY_COUNTER1(category, name, value) \ | 345 #define TRACE_COPY_COUNTER1(category_group, name, value) \ |
334 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 346 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
335 category, name, TRACE_EVENT_FLAG_COPY, \ | 347 category_group, name, TRACE_EVENT_FLAG_COPY, \ |
336 "value", static_cast<int>(value)) | 348 "value", static_cast<int>(value)) |
337 | 349 |
338 // Records the values of a multi-parted counter called "name" immediately. | 350 // Records the values of a multi-parted counter called "name" immediately. |
339 // The UI will treat value1 and value2 as parts of a whole, displaying their | 351 // The UI will treat value1 and value2 as parts of a whole, displaying their |
340 // values as a stacked-bar chart. | 352 // values as a stacked-bar chart. |
341 // - category and name strings must have application lifetime (statics or | 353 // - category and name strings must have application lifetime (statics or |
342 // literals). They may not include " chars. | 354 // literals). They may not include " chars. |
343 #define TRACE_COUNTER2(category, name, value1_name, value1_val, \ | 355 #define TRACE_COUNTER2(category_group, name, value1_name, value1_val, \ |
344 value2_name, value2_val) \ | 356 value2_name, value2_val) \ |
345 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 357 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
346 category, name, TRACE_EVENT_FLAG_NONE, \ | 358 category_group, name, TRACE_EVENT_FLAG_NONE, \ |
347 value1_name, static_cast<int>(value1_val), \ | 359 value1_name, static_cast<int>(value1_val), \ |
348 value2_name, static_cast<int>(value2_val)) | 360 value2_name, static_cast<int>(value2_val)) |
349 #define TRACE_COPY_COUNTER2(category, name, value1_name, value1_val, \ | 361 #define TRACE_COPY_COUNTER2(category_group, name, value1_name, value1_val, \ |
350 value2_name, value2_val) \ | 362 value2_name, value2_val) \ |
351 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ | 363 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, \ |
352 category, name, TRACE_EVENT_FLAG_COPY, \ | 364 category_group, name, TRACE_EVENT_FLAG_COPY, \ |
353 value1_name, static_cast<int>(value1_val), \ | 365 value1_name, static_cast<int>(value1_val), \ |
354 value2_name, static_cast<int>(value2_val)) | 366 value2_name, static_cast<int>(value2_val)) |
355 | 367 |
356 // Records the value of a counter called "name" immediately. Value | 368 // Records the value of a counter called "name" immediately. Value |
357 // must be representable as a 32 bit integer. | 369 // must be representable as a 32 bit integer. |
358 // - category and name strings must have application lifetime (statics or | 370 // - category and name strings must have application lifetime (statics or |
359 // literals). They may not include " chars. | 371 // literals). They may not include " chars. |
360 // - |id| is used to disambiguate counters with the same name. It must either | 372 // - |id| is used to disambiguate counters with the same name. It must either |
361 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits | 373 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits |
362 // will be xored with a hash of the process ID so that the same pointer on | 374 // will be xored with a hash of the process ID so that the same pointer on |
363 // two different processes will not collide. | 375 // two different processes will not collide. |
364 #define TRACE_COUNTER_ID1(category, name, id, value) \ | 376 #define TRACE_COUNTER_ID1(category_group, name, id, value) \ |
365 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 377 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
366 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 378 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
367 "value", static_cast<int>(value)) | 379 "value", static_cast<int>(value)) |
368 #define TRACE_COPY_COUNTER_ID1(category, name, id, value) \ | 380 #define TRACE_COPY_COUNTER_ID1(category_group, name, id, value) \ |
369 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 381 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
370 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 382 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
371 "value", static_cast<int>(value)) | 383 "value", static_cast<int>(value)) |
372 | 384 |
373 // Records the values of a multi-parted counter called "name" immediately. | 385 // Records the values of a multi-parted counter called "name" immediately. |
374 // The UI will treat value1 and value2 as parts of a whole, displaying their | 386 // The UI will treat value1 and value2 as parts of a whole, displaying their |
375 // values as a stacked-bar chart. | 387 // values as a stacked-bar chart. |
376 // - category and name strings must have application lifetime (statics or | 388 // - category and name strings must have application lifetime (statics or |
377 // literals). They may not include " chars. | 389 // literals). They may not include " chars. |
378 // - |id| is used to disambiguate counters with the same name. It must either | 390 // - |id| is used to disambiguate counters with the same name. It must either |
379 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits | 391 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits |
380 // will be xored with a hash of the process ID so that the same pointer on | 392 // will be xored with a hash of the process ID so that the same pointer on |
381 // two different processes will not collide. | 393 // two different processes will not collide. |
382 #define TRACE_COUNTER_ID2(category, name, id, value1_name, value1_val, \ | 394 #define TRACE_COUNTER_ID2(category_group, name, id, value1_name, value1_val, \ |
383 value2_name, value2_val) \ | 395 value2_name, value2_val) \ |
384 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 396 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
385 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 397 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
386 value1_name, static_cast<int>(value1_val), \ | 398 value1_name, static_cast<int>(value1_val), \ |
387 value2_name, static_cast<int>(value2_val)) | 399 value2_name, static_cast<int>(value2_val)) |
388 #define TRACE_COPY_COUNTER_ID2(category, name, id, value1_name, value1_val, \ | 400 #define TRACE_COPY_COUNTER_ID2(category_group, name, id, value1_name, \ |
389 value2_name, value2_val) \ | 401 value1_val, value2_name, value2_val) \ |
390 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ | 402 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, \ |
391 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 403 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
392 value1_name, static_cast<int>(value1_val), \ | 404 value1_name, static_cast<int>(value1_val), \ |
393 value2_name, static_cast<int>(value2_val)) | 405 value2_name, static_cast<int>(value2_val)) |
394 | 406 |
395 | 407 |
396 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 | 408 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 |
397 // associated arguments. If the category is not enabled, then this | 409 // associated arguments. If the category is not enabled, then this |
398 // does nothing. | 410 // does nothing. |
399 // - category and name strings must have application lifetime (statics or | 411 // - category and name strings must have application lifetime (statics or |
400 // literals). They may not include " chars. | 412 // literals). They may not include " chars. |
401 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC | 413 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC |
402 // events are considered to match if their category, name and id values all | 414 // events are considered to match if their category_group, name and id values |
403 // match. |id| must either be a pointer or an integer value up to 64 bits. If | 415 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
404 // it's a pointer, the bits will be xored with a hash of the process ID so | 416 // If it's a pointer, the bits will be xored with a hash of the process ID so |
405 // that the same pointer on two different processes will not collide. | 417 // that the same pointer on two different processes will not collide. |
406 // An asynchronous operation can consist of multiple phases. The first phase is | 418 // An asynchronous operation can consist of multiple phases. The first phase is |
407 // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the | 419 // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the |
408 // ASYNC_STEP macros. When the operation completes, call ASYNC_END. | 420 // ASYNC_STEP macros. When the operation completes, call ASYNC_END. |
409 // An ASYNC trace typically occur on a single thread (if not, they will only be | 421 // An ASYNC trace typically occur on a single thread (if not, they will only be |
410 // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that | 422 // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that |
411 // operation must use the same |name| and |id|. Each event can have its own | 423 // operation must use the same |name| and |id|. Each event can have its own |
412 // args. | 424 // args. |
413 #define TRACE_EVENT_ASYNC_BEGIN0(category, name, id) \ | 425 #define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \ |
414 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 426 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
415 category, name, id, TRACE_EVENT_FLAG_NONE) | 427 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
416 #define TRACE_EVENT_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ | 428 #define TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ |
429 arg1_val) \ | |
417 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 430 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
418 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 431 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
419 #define TRACE_EVENT_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ | 432 #define TRACE_EVENT_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ |
420 arg2_name, arg2_val) \ | 433 arg1_val, arg2_name, arg2_val) \ |
421 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 434 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
422 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 435 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
423 arg1_name, arg1_val, arg2_name, arg2_val) | 436 arg1_name, arg1_val, arg2_name, arg2_val) |
424 #define TRACE_EVENT_COPY_ASYNC_BEGIN0(category, name, id) \ | 437 #define TRACE_EVENT_COPY_ASYNC_BEGIN0(category_group, name, id) \ |
425 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 438 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
426 category, name, id, TRACE_EVENT_FLAG_COPY) | 439 category_group, name, id, TRACE_EVENT_FLAG_COPY) |
427 #define TRACE_EVENT_COPY_ASYNC_BEGIN1(category, name, id, arg1_name, arg1_val) \ | 440 #define TRACE_EVENT_COPY_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ |
441 arg1_val) \ | |
428 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 442 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
429 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 443 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
430 arg1_name, arg1_val) | 444 arg1_name, arg1_val) |
431 #define TRACE_EVENT_COPY_ASYNC_BEGIN2(category, name, id, arg1_name, arg1_val, \ | 445 #define TRACE_EVENT_COPY_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ |
432 arg2_name, arg2_val) \ | 446 arg1_val, arg2_name, arg2_val) \ |
433 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ | 447 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ |
434 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 448 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
435 arg1_name, arg1_val, arg2_name, arg2_val) | 449 arg1_name, arg1_val, arg2_name, arg2_val) |
436 | 450 |
437 // Records a single ASYNC_STEP event for |step| immediately. If the category | 451 // Records a single ASYNC_STEP event for |step| immediately. If the category |
438 // is not enabled, then this does nothing. The |name| and |id| must match the | 452 // is not enabled, then this does nothing. The |name| and |id| must match the |
439 // ASYNC_BEGIN event above. The |step| param identifies this step within the | 453 // ASYNC_BEGIN event above. The |step| param identifies this step within the |
440 // async event. This should be called at the beginning of the next phase of an | 454 // async event. This should be called at the beginning of the next phase of an |
441 // asynchronous operation. | 455 // asynchronous operation. |
442 #define TRACE_EVENT_ASYNC_STEP0(category, name, id, step) \ | 456 #define TRACE_EVENT_ASYNC_STEP0(category_group, name, id, step) \ |
443 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ | 457 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ |
444 category, name, id, TRACE_EVENT_FLAG_NONE, "step", step) | 458 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) |
445 #define TRACE_EVENT_ASYNC_STEP1(category, name, id, step, \ | 459 #define TRACE_EVENT_ASYNC_STEP1(category_group, name, id, step, \ |
446 arg1_name, arg1_val) \ | 460 arg1_name, arg1_val) \ |
447 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ | 461 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ |
448 category, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ | 462 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ |
449 arg1_name, arg1_val) | 463 arg1_name, arg1_val) |
450 #define TRACE_EVENT_COPY_ASYNC_STEP0(category, name, id, step) \ | 464 #define TRACE_EVENT_COPY_ASYNC_STEP0(category_group, name, id, step) \ |
451 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ | 465 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ |
452 category, name, id, TRACE_EVENT_FLAG_COPY, "step", step) | 466 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step) |
453 #define TRACE_EVENT_COPY_ASYNC_STEP1(category, name, id, step, \ | 467 #define TRACE_EVENT_COPY_ASYNC_STEP1(category_group, name, id, step, \ |
454 arg1_name, arg1_val) \ | 468 arg1_name, arg1_val) \ |
455 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ | 469 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP, \ |
456 category, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \ | 470 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \ |
457 arg1_name, arg1_val) | 471 arg1_name, arg1_val) |
458 | 472 |
459 // Records a single ASYNC_END event for "name" immediately. If the category | 473 // Records a single ASYNC_END event for "name" immediately. If the category |
460 // is not enabled, then this does nothing. | 474 // is not enabled, then this does nothing. |
461 #define TRACE_EVENT_ASYNC_END0(category, name, id) \ | 475 #define TRACE_EVENT_ASYNC_END0(category_group, name, id) \ |
462 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 476 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
463 category, name, id, TRACE_EVENT_FLAG_NONE) | 477 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
464 #define TRACE_EVENT_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ | 478 #define TRACE_EVENT_ASYNC_END1(category_group, name, id, arg1_name, arg1_val) \ |
465 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 479 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
466 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 480 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
467 #define TRACE_EVENT_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ | 481 #define TRACE_EVENT_ASYNC_END2(category_group, name, id, arg1_name, arg1_val, \ |
468 arg2_name, arg2_val) \ | 482 arg2_name, arg2_val) \ |
469 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 483 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
470 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 484 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
471 arg1_name, arg1_val, arg2_name, arg2_val) | 485 arg1_name, arg1_val, arg2_name, arg2_val) |
472 #define TRACE_EVENT_COPY_ASYNC_END0(category, name, id) \ | 486 #define TRACE_EVENT_COPY_ASYNC_END0(category_group, name, id) \ |
473 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 487 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
474 category, name, id, TRACE_EVENT_FLAG_COPY) | 488 category_group, name, id, TRACE_EVENT_FLAG_COPY) |
475 #define TRACE_EVENT_COPY_ASYNC_END1(category, name, id, arg1_name, arg1_val) \ | 489 #define TRACE_EVENT_COPY_ASYNC_END1(category_group, name, id, arg1_name, \ |
490 arg1_val) \ | |
476 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 491 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
477 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 492 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
478 arg1_name, arg1_val) | 493 arg1_name, arg1_val) |
479 #define TRACE_EVENT_COPY_ASYNC_END2(category, name, id, arg1_name, arg1_val, \ | 494 #define TRACE_EVENT_COPY_ASYNC_END2(category_group, name, id, arg1_name, \ |
480 arg2_name, arg2_val) \ | 495 arg1_val, arg2_name, arg2_val) \ |
481 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ | 496 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ |
482 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 497 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
483 arg1_name, arg1_val, arg2_name, arg2_val) | 498 arg1_name, arg1_val, arg2_name, arg2_val) |
484 | 499 |
485 | 500 |
486 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 | 501 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 |
487 // associated arguments. If the category is not enabled, then this | 502 // associated arguments. If the category is not enabled, then this |
488 // does nothing. | 503 // does nothing. |
489 // - category and name strings must have application lifetime (statics or | 504 // - category and name strings must have application lifetime (statics or |
490 // literals). They may not include " chars. | 505 // literals). They may not include " chars. |
491 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW | 506 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW |
492 // events are considered to match if their category, name and id values all | 507 // events are considered to match if their category_group, name and id values |
493 // match. |id| must either be a pointer or an integer value up to 64 bits. If | 508 // all match. |id| must either be a pointer or an integer value up to 64 bits. |
494 // it's a pointer, the bits will be xored with a hash of the process ID so | 509 // If it's a pointer, the bits will be xored with a hash of the process ID so |
495 // that the same pointer on two different processes will not collide. | 510 // that the same pointer on two different processes will not collide. |
496 // FLOW events are different from ASYNC events in how they are drawn by the | 511 // FLOW events are different from ASYNC events in how they are drawn by the |
497 // tracing UI. A FLOW defines asynchronous data flow, such as posting a task | 512 // tracing UI. A FLOW defines asynchronous data flow, such as posting a task |
498 // (FLOW_BEGIN) and later executing that task (FLOW_END). Expect FLOWs to be | 513 // (FLOW_BEGIN) and later executing that task (FLOW_END). Expect FLOWs to be |
499 // drawn as lines or arrows from FLOW_BEGIN scopes to FLOW_END scopes. Similar | 514 // drawn as lines or arrows from FLOW_BEGIN scopes to FLOW_END scopes. Similar |
500 // to ASYNC, a FLOW can consist of multiple phases. The first phase is defined | 515 // to ASYNC, a FLOW can consist of multiple phases. The first phase is defined |
501 // by the FLOW_BEGIN calls. Additional phases can be defined using the FLOW_STEP | 516 // by the FLOW_BEGIN calls. Additional phases can be defined using the FLOW_STEP |
502 // macros. When the operation completes, call FLOW_END. An async operation can | 517 // macros. When the operation completes, call FLOW_END. An async operation can |
503 // span threads and processes, but all events in that operation must use the | 518 // span threads and processes, but all events in that operation must use the |
504 // same |name| and |id|. Each event can have its own args. | 519 // same |name| and |id|. Each event can have its own args. |
505 #define TRACE_EVENT_FLOW_BEGIN0(category, name, id) \ | 520 #define TRACE_EVENT_FLOW_BEGIN0(category_group, name, id) \ |
506 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 521 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
507 category, name, id, TRACE_EVENT_FLAG_NONE) | 522 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
508 #define TRACE_EVENT_FLOW_BEGIN1(category, name, id, arg1_name, arg1_val) \ | 523 #define TRACE_EVENT_FLOW_BEGIN1(category_group, name, id, arg1_name, arg1_val) \ |
509 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 524 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
510 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 525 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
511 #define TRACE_EVENT_FLOW_BEGIN2(category, name, id, arg1_name, arg1_val, \ | 526 #define TRACE_EVENT_FLOW_BEGIN2(category_group, name, id, arg1_name, arg1_val, \ |
512 arg2_name, arg2_val) \ | 527 arg2_name, arg2_val) \ |
513 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 528 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
514 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 529 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
515 arg1_name, arg1_val, arg2_name, arg2_val) | 530 arg1_name, arg1_val, arg2_name, arg2_val) |
516 #define TRACE_EVENT_COPY_FLOW_BEGIN0(category, name, id) \ | 531 #define TRACE_EVENT_COPY_FLOW_BEGIN0(category_group, name, id) \ |
517 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 532 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
518 category, name, id, TRACE_EVENT_FLAG_COPY) | 533 category_group, name, id, TRACE_EVENT_FLAG_COPY) |
519 #define TRACE_EVENT_COPY_FLOW_BEGIN1(category, name, id, arg1_name, arg1_val) \ | 534 #define TRACE_EVENT_COPY_FLOW_BEGIN1(category_group, name, id, arg1_name, \ |
535 arg1_val) \ | |
520 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 536 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
521 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 537 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
522 arg1_name, arg1_val) | 538 arg1_name, arg1_val) |
523 #define TRACE_EVENT_COPY_FLOW_BEGIN2(category, name, id, arg1_name, arg1_val, \ | 539 #define TRACE_EVENT_COPY_FLOW_BEGIN2(category_group, name, id, arg1_name, \ |
524 arg2_name, arg2_val) \ | 540 arg1_val, arg2_name, arg2_val) \ |
525 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ | 541 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ |
526 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 542 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
527 arg1_name, arg1_val, arg2_name, arg2_val) | 543 arg1_name, arg1_val, arg2_name, arg2_val) |
528 | 544 |
529 // Records a single FLOW_STEP event for |step| immediately. If the category | 545 // Records a single FLOW_STEP event for |step| immediately. If the category |
530 // is not enabled, then this does nothing. The |name| and |id| must match the | 546 // is not enabled, then this does nothing. The |name| and |id| must match the |
531 // FLOW_BEGIN event above. The |step| param identifies this step within the | 547 // FLOW_BEGIN event above. The |step| param identifies this step within the |
532 // async event. This should be called at the beginning of the next phase of an | 548 // async event. This should be called at the beginning of the next phase of an |
533 // asynchronous operation. | 549 // asynchronous operation. |
534 #define TRACE_EVENT_FLOW_STEP0(category, name, id, step) \ | 550 #define TRACE_EVENT_FLOW_STEP0(category_group, name, id, step) \ |
535 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ | 551 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ |
536 category, name, id, TRACE_EVENT_FLAG_NONE, "step", step) | 552 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) |
537 #define TRACE_EVENT_FLOW_STEP1(category, name, id, step, \ | 553 #define TRACE_EVENT_FLOW_STEP1(category_group, name, id, step, \ |
538 arg1_name, arg1_val) \ | 554 arg1_name, arg1_val) \ |
539 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ | 555 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ |
540 category, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ | 556 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step, \ |
541 arg1_name, arg1_val) | 557 arg1_name, arg1_val) |
542 #define TRACE_EVENT_COPY_FLOW_STEP0(category, name, id, step) \ | 558 #define TRACE_EVENT_COPY_FLOW_STEP0(category_group, name, id, step) \ |
543 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ | 559 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ |
544 category, name, id, TRACE_EVENT_FLAG_COPY, "step", step) | 560 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step) |
545 #define TRACE_EVENT_COPY_FLOW_STEP1(category, name, id, step, \ | 561 #define TRACE_EVENT_COPY_FLOW_STEP1(category_group, name, id, step, \ |
546 arg1_name, arg1_val) \ | 562 arg1_name, arg1_val) \ |
547 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ | 563 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ |
548 category, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \ | 564 category_group, name, id, TRACE_EVENT_FLAG_COPY, "step", step, \ |
549 arg1_name, arg1_val) | 565 arg1_name, arg1_val) |
550 | 566 |
551 // Records a single FLOW_END event for "name" immediately. If the category | 567 // Records a single FLOW_END event for "name" immediately. If the category |
552 // is not enabled, then this does nothing. | 568 // is not enabled, then this does nothing. |
553 #define TRACE_EVENT_FLOW_END0(category, name, id) \ | 569 #define TRACE_EVENT_FLOW_END0(category_group, name, id) \ |
554 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 570 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
555 category, name, id, TRACE_EVENT_FLAG_NONE) | 571 category_group, name, id, TRACE_EVENT_FLAG_NONE) |
556 #define TRACE_EVENT_FLOW_END1(category, name, id, arg1_name, arg1_val) \ | 572 #define TRACE_EVENT_FLOW_END1(category_group, name, id, arg1_name, arg1_val) \ |
557 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 573 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
558 category, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 574 category_group, name, id, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) |
559 #define TRACE_EVENT_FLOW_END2(category, name, id, arg1_name, arg1_val, \ | 575 #define TRACE_EVENT_FLOW_END2(category_group, name, id, arg1_name, arg1_val, \ |
560 arg2_name, arg2_val) \ | 576 arg2_name, arg2_val) \ |
561 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 577 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
562 category, name, id, TRACE_EVENT_FLAG_NONE, \ | 578 category_group, name, id, TRACE_EVENT_FLAG_NONE, \ |
563 arg1_name, arg1_val, arg2_name, arg2_val) | 579 arg1_name, arg1_val, arg2_name, arg2_val) |
564 #define TRACE_EVENT_COPY_FLOW_END0(category, name, id) \ | 580 #define TRACE_EVENT_COPY_FLOW_END0(category_group, name, id) \ |
565 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 581 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
566 category, name, id, TRACE_EVENT_FLAG_COPY) | 582 category_group, name, id, TRACE_EVENT_FLAG_COPY) |
567 #define TRACE_EVENT_COPY_FLOW_END1(category, name, id, arg1_name, arg1_val) \ | 583 #define TRACE_EVENT_COPY_FLOW_END1(category_group, name, id, arg1_name, \ |
584 arg1_val) \ | |
568 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 585 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
569 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 586 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
570 arg1_name, arg1_val) | 587 arg1_name, arg1_val) |
571 #define TRACE_EVENT_COPY_FLOW_END2(category, name, id, arg1_name, arg1_val, \ | 588 #define TRACE_EVENT_COPY_FLOW_END2(category_group, name, id, arg1_name, \ |
572 arg2_name, arg2_val) \ | 589 arg1_val, arg2_name, arg2_val) \ |
573 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ | 590 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, \ |
574 category, name, id, TRACE_EVENT_FLAG_COPY, \ | 591 category_group, name, id, TRACE_EVENT_FLAG_COPY, \ |
575 arg1_name, arg1_val, arg2_name, arg2_val) | 592 arg1_name, arg1_val, arg2_name, arg2_val) |
576 | 593 |
577 // Implementation detail: trace event macros create temporary variables | 594 // Implementation detail: trace event macros create temporary variables |
578 // to keep instrumentation overhead low. These macros give each temporary | 595 // to keep instrumentation overhead low. These macros give each temporary |
579 // variable a unique name based on the line number to prevent name collissions. | 596 // variable a unique name based on the line number to prevent name collissions. |
580 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ | 597 #define INTERNAL_TRACE_EVENT_UID3(a,b) \ |
581 trace_event_unique_##a##b | 598 trace_event_unique_##a##b |
582 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ | 599 #define INTERNAL_TRACE_EVENT_UID2(a,b) \ |
583 INTERNAL_TRACE_EVENT_UID3(a,b) | 600 INTERNAL_TRACE_EVENT_UID3(a,b) |
584 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ | 601 #define INTERNAL_TRACE_EVENT_UID(name_prefix) \ |
585 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) | 602 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) |
586 | 603 |
587 // Implementation detail: internal macro to create static category. | 604 // Implementation detail: internal macro to create static category. |
588 // No barriers are needed, because this code is designed to operate safely | 605 // No barriers are needed, because this code is designed to operate safely |
589 // even when the unsigned char* points to garbage data (which may be the case | 606 // even when the unsigned char* points to garbage data (which may be the case |
590 // on processors without cache coherency). | 607 // on processors without cache coherency). |
591 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ | 608 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group) \ |
592 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ | 609 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ |
593 const unsigned char* INTERNAL_TRACE_EVENT_UID(catstatic) = \ | 610 const unsigned char* INTERNAL_TRACE_EVENT_UID(catstatic) = \ |
594 reinterpret_cast<const unsigned char*>(TRACE_EVENT_API_ATOMIC_LOAD( \ | 611 reinterpret_cast<const unsigned char*>(TRACE_EVENT_API_ATOMIC_LOAD( \ |
595 INTERNAL_TRACE_EVENT_UID(atomic))); \ | 612 INTERNAL_TRACE_EVENT_UID(atomic))); \ |
596 if (!INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 613 if (!INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
597 INTERNAL_TRACE_EVENT_UID(catstatic) = \ | 614 INTERNAL_TRACE_EVENT_UID(catstatic) = \ |
598 TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); \ | 615 TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(category_group); \ |
599 TRACE_EVENT_API_ATOMIC_STORE(INTERNAL_TRACE_EVENT_UID(atomic), \ | 616 TRACE_EVENT_API_ATOMIC_STORE(INTERNAL_TRACE_EVENT_UID(atomic), \ |
600 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( \ | 617 reinterpret_cast<TRACE_EVENT_API_ATOMIC_WORD>( \ |
601 INTERNAL_TRACE_EVENT_UID(catstatic))); \ | 618 INTERNAL_TRACE_EVENT_UID(catstatic))); \ |
602 } | 619 } |
603 | 620 |
604 // Implementation detail: internal macro to create static category and add | 621 // Implementation detail: internal macro to create static category and add |
605 // event if the category is enabled. | 622 // event if the category is enabled. |
606 #define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \ | 623 #define INTERNAL_TRACE_EVENT_ADD(phase, category_group, name, flags, ...) \ |
607 do { \ | 624 do { \ |
608 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 625 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
609 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 626 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
610 trace_event_internal::AddTraceEvent( \ | 627 trace_event_internal::AddTraceEvent( \ |
611 phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \ | 628 phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \ |
612 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ | 629 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ |
613 } \ | 630 } \ |
614 } while (0) | 631 } while (0) |
615 | 632 |
616 // Implementation detail: internal macro to create static category and add begin | 633 // Implementation detail: internal macro to create static category and add begin |
617 // event if the category is enabled. Also adds the end event when the scope | 634 // event if the category is enabled. Also adds the end event when the scope |
618 // ends. | 635 // ends. |
619 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \ | 636 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, ...) \ |
620 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 637 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
621 trace_event_internal::TraceEndOnScopeClose \ | 638 trace_event_internal::TraceEndOnScopeClose \ |
622 INTERNAL_TRACE_EVENT_UID(profileScope); \ | 639 INTERNAL_TRACE_EVENT_UID(profileScope); \ |
623 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 640 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
624 trace_event_internal::AddTraceEvent( \ | 641 trace_event_internal::AddTraceEvent( \ |
625 TRACE_EVENT_PHASE_BEGIN, \ | 642 TRACE_EVENT_PHASE_BEGIN, \ |
626 INTERNAL_TRACE_EVENT_UID(catstatic), \ | 643 INTERNAL_TRACE_EVENT_UID(catstatic), \ |
627 name, trace_event_internal::kNoEventId, \ | 644 name, trace_event_internal::kNoEventId, \ |
628 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ | 645 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ |
629 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ | 646 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ |
630 INTERNAL_TRACE_EVENT_UID(catstatic), name); \ | 647 INTERNAL_TRACE_EVENT_UID(catstatic), name); \ |
631 } | 648 } |
632 | 649 |
633 // Implementation detail: internal macro to create static category and add | 650 // Implementation detail: internal macro to create static category and add |
634 // event if the category is enabled. | 651 // event if the category is enabled. |
635 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \ | 652 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category_group, name, id, \ |
636 ...) \ | 653 flags, ...) \ |
637 do { \ | 654 do { \ |
638 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 655 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
639 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 656 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
640 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 657 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
641 trace_event_internal::TraceID trace_event_trace_id( \ | 658 trace_event_internal::TraceID trace_event_trace_id( \ |
642 id, &trace_event_flags); \ | 659 id, &trace_event_flags); \ |
643 trace_event_internal::AddTraceEvent( \ | 660 trace_event_internal::AddTraceEvent( \ |
644 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | 661 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
645 name, trace_event_trace_id.data(), trace_event_flags, \ | 662 name, trace_event_trace_id.data(), trace_event_flags, \ |
646 ##__VA_ARGS__); \ | 663 ##__VA_ARGS__); \ |
647 } \ | 664 } \ |
648 } while (0) | 665 } while (0) |
649 | 666 |
650 // Implementation detail: internal macro to create static category and add | 667 // Implementation detail: internal macro to create static category and add |
651 // event if the category is enabled. | 668 // event if the category is enabled. |
652 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, category, \ | 669 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP(phase, \ |
653 name, id, thread_id, timestamp, flags, ...) \ | 670 category_group, name, id, thread_id, timestamp, flags, ...) \ |
654 do { \ | 671 do { \ |
655 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 672 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
656 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 673 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
657 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 674 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
658 trace_event_internal::TraceID trace_event_trace_id( \ | 675 trace_event_internal::TraceID trace_event_trace_id( \ |
659 id, &trace_event_flags); \ | 676 id, &trace_event_flags); \ |
660 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 677 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
661 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | 678 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
662 name, trace_event_trace_id.data(), \ | 679 name, trace_event_trace_id.data(), \ |
663 thread_id, TimeTicks::FromInternalValue(timestamp), \ | 680 thread_id, TimeTicks::FromInternalValue(timestamp), \ |
664 trace_event_flags, ##__VA_ARGS__); \ | 681 trace_event_flags, ##__VA_ARGS__); \ |
665 } \ | 682 } \ |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 // Used by TRACE_EVENTx macro. Do not use directly. | 967 // Used by TRACE_EVENTx macro. Do not use directly. |
951 class TRACE_EVENT_API_CLASS_EXPORT TraceEndOnScopeClose { | 968 class TRACE_EVENT_API_CLASS_EXPORT TraceEndOnScopeClose { |
952 public: | 969 public: |
953 // Note: members of data_ intentionally left uninitialized. See Initialize. | 970 // Note: members of data_ intentionally left uninitialized. See Initialize. |
954 TraceEndOnScopeClose() : p_data_(NULL) {} | 971 TraceEndOnScopeClose() : p_data_(NULL) {} |
955 ~TraceEndOnScopeClose() { | 972 ~TraceEndOnScopeClose() { |
956 if (p_data_) | 973 if (p_data_) |
957 AddEventIfEnabled(); | 974 AddEventIfEnabled(); |
958 } | 975 } |
959 | 976 |
960 void Initialize(const unsigned char* category_enabled, | 977 void Initialize(const unsigned char* category_group_enabled, |
961 const char* name) { | 978 const char* name) { |
962 data_.category_enabled = category_enabled; | 979 data_.category_group_enabled = category_group_enabled; |
963 data_.name = name; | 980 data_.name = name; |
964 p_data_ = &data_; | 981 p_data_ = &data_; |
965 } | 982 } |
966 | 983 |
967 private: | 984 private: |
968 // Add the end event if the category is still enabled. | 985 // Add the end event if the category is still enabled. |
969 void AddEventIfEnabled() { | 986 void AddEventIfEnabled() { |
970 // Only called when p_data_ is non-null. | 987 // Only called when p_data_ is non-null. |
971 if (*p_data_->category_enabled) { | 988 if (*p_data_->category_group_enabled) { |
972 TRACE_EVENT_API_ADD_TRACE_EVENT( | 989 TRACE_EVENT_API_ADD_TRACE_EVENT( |
973 TRACE_EVENT_PHASE_END, | 990 TRACE_EVENT_PHASE_END, |
974 p_data_->category_enabled, | 991 p_data_->category_group_enabled, |
975 p_data_->name, kNoEventId, | 992 p_data_->name, kNoEventId, |
976 kZeroNumArgs, NULL, NULL, NULL, | 993 kZeroNumArgs, NULL, NULL, NULL, |
977 TRACE_EVENT_FLAG_NONE); | 994 TRACE_EVENT_FLAG_NONE); |
978 } | 995 } |
979 } | 996 } |
980 | 997 |
981 // This Data struct workaround is to avoid initializing all the members | 998 // This Data struct workaround is to avoid initializing all the members |
982 // in Data during construction of this object, since this object is always | 999 // in Data during construction of this object, since this object is always |
983 // constructed, even when tracing is disabled. If the members of Data were | 1000 // constructed, even when tracing is disabled. If the members of Data were |
984 // members of this class instead, compiler warnings occur about potential | 1001 // members of this class instead, compiler warnings occur about potential |
985 // uninitialized accesses. | 1002 // uninitialized accesses. |
986 struct Data { | 1003 struct Data { |
987 const unsigned char* category_enabled; | 1004 const unsigned char* category_group_enabled; |
988 const char* name; | 1005 const char* name; |
989 }; | 1006 }; |
990 Data* p_data_; | 1007 Data* p_data_; |
991 Data data_; | 1008 Data data_; |
992 }; | 1009 }; |
993 | 1010 |
994 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. | 1011 // Used by TRACE_EVENT_BINARY_EFFICIENTx macro. Do not use directly. |
995 class TRACE_EVENT_API_CLASS_EXPORT ScopedTrace { | 1012 class TRACE_EVENT_API_CLASS_EXPORT ScopedTrace { |
996 public: | 1013 public: |
997 ScopedTrace(TRACE_EVENT_API_ATOMIC_WORD* event_uid, const char* name); | 1014 ScopedTrace(TRACE_EVENT_API_ATOMIC_WORD* event_uid, const char* name); |
998 ~ScopedTrace(); | 1015 ~ScopedTrace(); |
999 | 1016 |
1000 private: | 1017 private: |
1001 const unsigned char* category_enabled_; | 1018 const unsigned char* category_enabled_; |
1002 const char* name_; | 1019 const char* name_; |
1003 }; | 1020 }; |
1004 | 1021 |
1005 // A support macro for TRACE_EVENT_BINARY_EFFICIENTx | 1022 // A support macro for TRACE_EVENT_BINARY_EFFICIENTx |
1006 #define INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED( \ | 1023 #define INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED( \ |
1007 category, name, ...) \ | 1024 category_group, name, ...) \ |
1008 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ | 1025 static TRACE_EVENT_API_ATOMIC_WORD INTERNAL_TRACE_EVENT_UID(atomic) = 0; \ |
1009 trace_event_internal::ScopedTrace \ | 1026 trace_event_internal::ScopedTrace \ |
1010 INTERNAL_TRACE_EVENT_UID(profileScope)( \ | 1027 INTERNAL_TRACE_EVENT_UID(profileScope)( \ |
1011 &INTERNAL_TRACE_EVENT_UID(atomic), name); \ | 1028 &INTERNAL_TRACE_EVENT_UID(atomic), name); \ |
1012 | 1029 |
1013 // This macro generates less code then TRACE_EVENT0 but is also | 1030 // This macro generates less code then TRACE_EVENT0 but is also |
1014 // slower to execute when tracing is off. It should generally only be | 1031 // slower to execute when tracing is off. It should generally only be |
1015 // used with code that is seldom executed or conditionally executed | 1032 // used with code that is seldom executed or conditionally executed |
1016 // when debugging. | 1033 // when debugging. |
1017 #define TRACE_EVENT_BINARY_EFFICIENT0(category, name) \ | 1034 #define TRACE_EVENT_BINARY_EFFICIENT0(category_group, name) \ |
1018 INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED(category, name) | 1035 INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED(category_group, name) |
1019 | 1036 |
1020 } // namespace trace_event_internal | 1037 } // namespace trace_event_internal |
1021 | 1038 |
1022 #endif // BASE_DEBUG_TRACE_EVENT_INTERNAL_H_ | 1039 #endif // BASE_DEBUG_TRACE_EVENT_INTERNAL_H_ |
OLD | NEW |