1 // Copyright 2015 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 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 // IMPORTANT: To avoid conflicts, if you need to modify this file for a library, 13 // land your change in base/ first, and then copy-and-paste it. 14 15 // Trace events are for tracking application performance and resource usage. 16 // Macros are provided to track: 17 // Begin and end of function calls 18 // Counters 19 // 20 // Events are issued against categories. Whereas LOG's 21 // categories are statically defined, TRACE categories are created 22 // implicitly with a string. For example: 23 // TRACE_EVENT_INSTANT0("MY_SUBSYSTEM", "SomeImportantEvent", 24 // TRACE_EVENT_SCOPE_THREAD) 25 // 26 // It is often the case that one trace may belong in multiple categories at the 27 // same time. The first argument to the trace can be a comma-separated list of 28 // categories, forming a category group, like: 29 // 30 // TRACE_EVENT_INSTANT0("input,views", "OnMouseOver", TRACE_EVENT_SCOPE_THREAD) 31 // 32 // We can enable/disable tracing of OnMouseOver by enabling/disabling either 33 // category. 34 // 35 // Events can be INSTANT, or can be pairs of BEGIN and END in the same scope: 36 // TRACE_EVENT_BEGIN0("MY_SUBSYSTEM", "SomethingCostly") 37 // doSomethingCostly() 38 // TRACE_EVENT_END0("MY_SUBSYSTEM", "SomethingCostly") 39 // Note: our tools can't always determine the correct BEGIN/END pairs unless 40 // these are used in the same scope. Use ASYNC_BEGIN/ASYNC_END macros if you 41 // need them to be in separate scopes. 42 // 43 // A common use case is to trace entire function scopes. This 44 // issues a trace BEGIN and END automatically: 45 // void doSomethingCostly() { 46 // TRACE_EVENT0("MY_SUBSYSTEM", "doSomethingCostly"); 47 // ... 48 // } 49 // 50 // Additional parameters can be associated with an event: 51 // void doSomethingCostly2(int howMuch) { 52 // TRACE_EVENT1("MY_SUBSYSTEM", "doSomethingCostly", 53 // "howMuch", howMuch); 54 // ... 55 // } 56 // 57 // The trace system will automatically add to this information the 58 // current process id, thread id, and a timestamp in microseconds. 59 // 60 // To trace an asynchronous procedure such as an IPC send/receive, use 61 // ASYNC_BEGIN and ASYNC_END: 62 // [single threaded sender code] 63 // static int send_count = 0; 64 // ++send_count; 65 // TRACE_EVENT_ASYNC_BEGIN0("ipc", "message", send_count); 66 // Send(new MyMessage(send_count)); 67 // [receive code] 68 // void OnMyMessage(send_count) { 69 // TRACE_EVENT_ASYNC_END0("ipc", "message", send_count); 70 // } 71 // The third parameter is a unique ID to match ASYNC_BEGIN/ASYNC_END pairs. 72 // ASYNC_BEGIN and ASYNC_END can occur on any thread of any traced process. 73 // Pointers can be used for the ID parameter, and they will be mangled 74 // internally so that the same pointer on two different processes will not 75 // match. For example: 76 // class MyTracedClass { 77 // public: 78 // MyTracedClass() { 79 // TRACE_EVENT_ASYNC_BEGIN0("category", "MyTracedClass", this); 80 // } 81 // ~MyTracedClass() { 82 // TRACE_EVENT_ASYNC_END0("category", "MyTracedClass", this); 83 // } 84 // } 85 // 86 // Trace event also supports counters, which is a way to track a quantity 87 // as it varies over time. Counters are created with the following macro: 88 // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter", g_myCounterValue); 89 // 90 // Counters are process-specific. The macro itself can be issued from any 91 // thread, however. 92 // 93 // Sometimes, you want to track two counters at once. You can do this with two 94 // counter macros: 95 // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter0", g_myCounterValue[0]); 96 // TRACE_COUNTER1("MY_SUBSYSTEM", "myCounter1", g_myCounterValue[1]); 97 // Or you can do it with a combined macro: 98 // TRACE_COUNTER2("MY_SUBSYSTEM", "myCounter", 99 // "bytesPinned", g_myCounterValue[0], 100 // "bytesAllocated", g_myCounterValue[1]); 101 // This indicates to the tracing UI that these counters should be displayed 102 // in a single graph, as a summed area chart. 103 // 104 // Since counters are in a global namespace, you may want to disambiguate with a 105 // unique ID, by using the TRACE_COUNTER_ID* variations. 106 // 107 // By default, trace collection is compiled in, but turned off at runtime. 108 // Collecting trace data is the responsibility of the embedding 109 // application. In Chrome's case, navigating to about:tracing will turn on 110 // tracing and display data collected across all active processes. 111 // 112 // 113 // Memory scoping note: 114 // Tracing copies the pointers, not the string content, of the strings passed 115 // in for category_group, name, and arg_names. Thus, the following code will 116 // cause problems: 117 // char* str = strdup("importantName"); 118 // TRACE_EVENT_INSTANT0("SUBSYSTEM", str); // BAD! 119 // free(str); // Trace system now has dangling pointer 120 // 121 // To avoid this issue with the |name| and |arg_name| parameters, use the 122 // TRACE_EVENT_COPY_XXX overloads of the macros at additional runtime overhead. 123 // Notes: The category must always be in a long-lived char* (i.e. static const). 124 // The |arg_values|, when used, are always deep copied with the _COPY 125 // macros. 126 // 127 // When are string argument values copied: 128 // const char* arg_values are only referenced by default: 129 // TRACE_EVENT1("category", "name", 130 // "arg1", "literal string is only referenced"); 131 // Use TRACE_STR_COPY to force copying of a const char*: 132 // TRACE_EVENT1("category", "name", 133 // "arg1", TRACE_STR_COPY("string will be copied")); 134 // std::string arg_values are always copied: 135 // TRACE_EVENT1("category", "name", 136 // "arg1", std::string("string will be copied")); 137 // 138 // 139 // Convertable notes: 140 // Converting a large data type to a string can be costly. To help with this, 141 // the trace framework provides an interface ConvertableToTraceFormat. If you 142 // inherit from it and implement the AppendAsTraceFormat method the trace 143 // framework will call back to your object to convert a trace output time. This 144 // means, if the category for the event is disabled, the conversion will not 145 // happen. 146 // 147 // class MyData : public base::trace_event::ConvertableToTraceFormat { 148 // public: 149 // MyData() {} 150 // void AppendAsTraceFormat(std::string* out) const override { 151 // out->append("{\"foo\":1}"); 152 // } 153 // private: 154 // ~MyData() override {} 155 // DISALLOW_COPY_AND_ASSIGN(MyData); 156 // }; 157 // 158 // TRACE_EVENT1("foo", "bar", "data", 159 // std::unique_ptr<ConvertableToTraceFormat>(new MyData())); 160 // 161 // The trace framework will take ownership if the passed pointer and it will 162 // be free'd when the trace buffer is flushed. 163 // 164 // Note, we only do the conversion when the buffer is flushed, so the provided 165 // data object should not be modified after it's passed to the trace framework. 166 // 167 // 168 // Thread Safety: 169 // A thread safe singleton and mutex are used for thread safety. Category 170 // enabled flags are used to limit the performance impact when the system 171 // is not enabled. 172 // 173 // TRACE_EVENT macros first cache a pointer to a category. The categories are 174 // statically allocated and safe at all times, even after exit. Fetching a 175 // category is protected by the TraceLog::lock_. Multiple threads initializing 176 // the static variable is safe, as they will be serialized by the lock and 177 // multiple calls will return the same pointer to the category. 178 // 179 // Then the category_group_enabled flag is checked. This is a unsigned char, and 180 // not intended to be multithread safe. It optimizes access to AddTraceEvent 181 // which is threadsafe internally via TraceLog::lock_. The enabled flag may 182 // cause some threads to incorrectly call or skip calling AddTraceEvent near 183 // the time of the system being enabled or disabled. This is acceptable as 184 // we tolerate some data loss while the system is being enabled/disabled and 185 // because AddTraceEvent is threadsafe internally and checks the enabled state 186 // again under lock. 187 // 188 // Without the use of these static category pointers and enabled flags all 189 // trace points would carry a significant performance cost of acquiring a lock 190 // and resolving the category. 191 192 #if defined(TRACE_EVENT0) 193 #error "Another copy of this file has already been included." 194 #endif 195 196 // This will mark the trace event as disabled by default. The user will need 197 // to explicitly enable the event. 198 #define TRACE_DISABLED_BY_DEFAULT(name) "disabled-by-default-" name 199 200 // Records a pair of begin and end events called "name" for the current 201 // scope, with 0, 1 or 2 associated arguments. If the category is not 202 // enabled, then this does nothing. 203 // - category and name strings must have application lifetime (statics or 204 // literals). They may not include " chars. 205 #define TRACE_EVENT0(category_group, name) \ 206 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name) 207 #define TRACE_EVENT_WITH_FLOW0(category_group, name, bind_id, flow_flags) \ 208 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \ 209 flow_flags) 210 #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ 211 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val) 212 #define TRACE_EVENT_WITH_FLOW1(category_group, name, bind_id, flow_flags, \ 213 arg1_name, arg1_val) \ 214 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \ 215 flow_flags, arg1_name, arg1_val) 216 #define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \ 217 arg2_val) \ 218 INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name, arg1_name, arg1_val, \ 219 arg2_name, arg2_val) 220 #define TRACE_EVENT_WITH_FLOW2(category_group, name, bind_id, flow_flags, \ 221 arg1_name, arg1_val, arg2_name, arg2_val) \ 222 INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \ 223 flow_flags, arg1_name, arg1_val, \ 224 arg2_name, arg2_val) 225 226 // UNSHIPPED_TRACE_EVENT* are like TRACE_EVENT* except that they are not 227 // included in official builds. 228 229 #if OFFICIAL_BUILD 230 #undef TRACING_IS_OFFICIAL_BUILD 231 #define TRACING_IS_OFFICIAL_BUILD 1 232 #elif !defined(TRACING_IS_OFFICIAL_BUILD) 233 #define TRACING_IS_OFFICIAL_BUILD 0 234 #endif 235 236 #if TRACING_IS_OFFICIAL_BUILD 237 #define UNSHIPPED_TRACE_EVENT0(category_group, name) (void)0 238 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ 239 (void)0 240 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \ 241 arg2_name, arg2_val) \ 242 (void)0 243 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name, scope) (void)0 244 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, \ 245 arg1_val) \ 246 (void)0 247 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, \ 248 arg1_val, arg2_name, arg2_val) \ 249 (void)0 250 #else 251 #define UNSHIPPED_TRACE_EVENT0(category_group, name) \ 252 TRACE_EVENT0(category_group, name) 253 #define UNSHIPPED_TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ 254 TRACE_EVENT1(category_group, name, arg1_name, arg1_val) 255 #define UNSHIPPED_TRACE_EVENT2(category_group, name, arg1_name, arg1_val, \ 256 arg2_name, arg2_val) \ 257 TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) 258 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category_group, name, scope) \ 259 TRACE_EVENT_INSTANT0(category_group, name, scope) 260 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, \ 261 arg1_val) \ 262 TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) 263 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, \ 264 arg1_val, arg2_name, arg2_val) \ 265 TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \ 266 arg2_name, arg2_val) 267 #endif 268 269 // Records a single event called "name" immediately, with 0, 1 or 2 270 // associated arguments. If the category is not enabled, then this 271 // does nothing. 272 // - category and name strings must have application lifetime (statics or 273 // literals). They may not include " chars. 274 #define TRACE_EVENT_INSTANT0(category_group, name, scope) \ 275 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \ 276 TRACE_EVENT_FLAG_NONE | scope) 277 #define TRACE_EVENT_INSTANT1(category_group, name, scope, arg1_name, arg1_val) \ 278 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \ 279 TRACE_EVENT_FLAG_NONE | scope, arg1_name, arg1_val) 280 #define TRACE_EVENT_INSTANT2(category_group, name, scope, arg1_name, arg1_val, \ 281 arg2_name, arg2_val) \ 282 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \ 283 TRACE_EVENT_FLAG_NONE | scope, arg1_name, arg1_val, \ 284 arg2_name, arg2_val) 285 #define TRACE_EVENT_COPY_INSTANT0(category_group, name, scope) \ 286 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \ 287 TRACE_EVENT_FLAG_COPY | scope) 288 #define TRACE_EVENT_COPY_INSTANT1(category_group, name, scope, arg1_name, \ 289 arg1_val) \ 290 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \ 291 TRACE_EVENT_FLAG_COPY | scope, arg1_name, arg1_val) 292 #define TRACE_EVENT_COPY_INSTANT2(category_group, name, scope, arg1_name, \ 293 arg1_val, arg2_name, arg2_val) \ 294 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, category_group, name, \ 295 TRACE_EVENT_FLAG_COPY | scope, arg1_name, arg1_val, \ 296 arg2_name, arg2_val) 297 298 #define TRACE_EVENT_INSTANT_WITH_TIMESTAMP0(category_group, name, scope, \ 299 timestamp) \ 300 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 301 TRACE_EVENT_PHASE_INSTANT, category_group, name, 0, 0, timestamp, \ 302 TRACE_EVENT_FLAG_NONE | scope) 303 304 // Syntactic sugars for the sampling tracing in the main thread. 305 #define TRACE_EVENT_SCOPED_SAMPLING_STATE(category, name) \ 306 TRACE_EVENT_SCOPED_SAMPLING_STATE_FOR_BUCKET(0, category, name) 307 #define TRACE_EVENT_GET_SAMPLING_STATE() \ 308 TRACE_EVENT_GET_SAMPLING_STATE_FOR_BUCKET(0) 309 #define TRACE_EVENT_SET_SAMPLING_STATE(category, name) \ 310 TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET(0, category, name) 311 #define TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(categoryAndName) \ 312 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE_FOR_BUCKET(0, categoryAndName) 313 314 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 315 // associated arguments. If the category is not enabled, then this 316 // does nothing. 317 // - category and name strings must have application lifetime (statics or 318 // literals). They may not include " chars. 319 #define TRACE_EVENT_BEGIN0(category_group, name) \ 320 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \ 321 TRACE_EVENT_FLAG_NONE) 322 #define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val) \ 323 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \ 324 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 325 #define TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_val, \ 326 arg2_name, arg2_val) \ 327 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \ 328 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ 329 arg2_name, arg2_val) 330 #define TRACE_EVENT_COPY_BEGIN0(category_group, name) \ 331 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \ 332 TRACE_EVENT_FLAG_COPY) 333 #define TRACE_EVENT_COPY_BEGIN1(category_group, name, arg1_name, arg1_val) \ 334 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \ 335 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) 336 #define TRACE_EVENT_COPY_BEGIN2(category_group, name, arg1_name, arg1_val, \ 337 arg2_name, arg2_val) \ 338 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \ 339 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ 340 arg2_name, arg2_val) 341 342 // Similar to TRACE_EVENT_BEGINx but with a custom |at| timestamp provided. 343 // - |id| is used to match the _BEGIN event with the _END event. 344 // Events are considered to match if their category_group, name and id values 345 // all match. |id| must either be a pointer or an integer value up to 64 bits. 346 // If it's a pointer, the bits will be xored with a hash of the process ID so 347 // that the same pointer on two different processes will not collide. 348 #define TRACE_EVENT_BEGIN_WITH_ID_TID_AND_TIMESTAMP0(category_group, name, id, \ 349 thread_id, timestamp) \ 350 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 351 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ 352 timestamp, TRACE_EVENT_FLAG_NONE) 353 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP0( \ 354 category_group, name, id, thread_id, timestamp) \ 355 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 356 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ 357 timestamp, TRACE_EVENT_FLAG_COPY) 358 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP1( \ 359 category_group, name, id, thread_id, timestamp, arg1_name, arg1_val) \ 360 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 361 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ 362 timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) 363 #define TRACE_EVENT_COPY_BEGIN_WITH_ID_TID_AND_TIMESTAMP2( \ 364 category_group, name, id, thread_id, timestamp, arg1_name, arg1_val, \ 365 arg2_name, arg2_val) \ 366 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 367 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, thread_id, \ 368 timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, \ 369 arg2_val) 370 371 // Records a single END event for "name" immediately. If the category 372 // is not enabled, then this does nothing. 373 // - category and name strings must have application lifetime (statics or 374 // literals). They may not include " chars. 375 #define TRACE_EVENT_END0(category_group, name) \ 376 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \ 377 TRACE_EVENT_FLAG_NONE) 378 #define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val) \ 379 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \ 380 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 381 #define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, arg2_name, \ 382 arg2_val) \ 383 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \ 384 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ 385 arg2_name, arg2_val) 386 #define TRACE_EVENT_COPY_END0(category_group, name) \ 387 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \ 388 TRACE_EVENT_FLAG_COPY) 389 #define TRACE_EVENT_COPY_END1(category_group, name, arg1_name, arg1_val) \ 390 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \ 391 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) 392 #define TRACE_EVENT_COPY_END2(category_group, name, arg1_name, arg1_val, \ 393 arg2_name, arg2_val) \ 394 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \ 395 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ 396 arg2_name, arg2_val) 397 398 #define TRACE_EVENT_MARK_WITH_TIMESTAMP1(category_group, name, timestamp, \ 399 arg1_name, arg1_val) \ 400 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 401 TRACE_EVENT_PHASE_MARK, category_group, name, 0, 0, timestamp, \ 402 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 403 404 #define TRACE_EVENT_COPY_MARK(category_group, name) \ 405 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_MARK, category_group, name, \ 406 TRACE_EVENT_FLAG_COPY) 407 408 #define TRACE_EVENT_COPY_MARK_WITH_TIMESTAMP(category_group, name, timestamp) \ 409 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 410 TRACE_EVENT_PHASE_MARK, category_group, name, 0, 0, timestamp, \ 411 TRACE_EVENT_FLAG_COPY) 412 413 // Similar to TRACE_EVENT_ENDx but with a custom |at| timestamp provided. 414 // - |id| is used to match the _BEGIN event with the _END event. 415 // Events are considered to match if their category_group, name and id values 416 // all match. |id| must either be a pointer or an integer value up to 64 bits. 417 // If it's a pointer, the bits will be xored with a hash of the process ID so 418 // that the same pointer on two different processes will not collide. 419 #define TRACE_EVENT_END_WITH_ID_TID_AND_TIMESTAMP0(category_group, name, id, \ 420 thread_id, timestamp) \ 421 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 422 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ 423 timestamp, TRACE_EVENT_FLAG_NONE) 424 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP0( \ 425 category_group, name, id, thread_id, timestamp) \ 426 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 427 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ 428 timestamp, TRACE_EVENT_FLAG_COPY) 429 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP1( \ 430 category_group, name, id, thread_id, timestamp, arg1_name, arg1_val) \ 431 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 432 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ 433 timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) 434 #define TRACE_EVENT_COPY_END_WITH_ID_TID_AND_TIMESTAMP2( \ 435 category_group, name, id, thread_id, timestamp, arg1_name, arg1_val, \ 436 arg2_name, arg2_val) \ 437 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 438 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, thread_id, \ 439 timestamp, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, \ 440 arg2_val) 441 442 // Records the value of a counter called "name" immediately. Value 443 // must be representable as a 32 bit integer. 444 // - category and name strings must have application lifetime (statics or 445 // literals). They may not include " chars. 446 #define TRACE_COUNTER1(category_group, name, value) \ 447 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \ 448 TRACE_EVENT_FLAG_NONE, "value", \ 449 static_cast<int>(value)) 450 #define TRACE_COPY_COUNTER1(category_group, name, value) \ 451 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \ 452 TRACE_EVENT_FLAG_COPY, "value", \ 453 static_cast<int>(value)) 454 455 // Records the values of a multi-parted counter called "name" immediately. 456 // The UI will treat value1 and value2 as parts of a whole, displaying their 457 // values as a stacked-bar chart. 458 // - category and name strings must have application lifetime (statics or 459 // literals). They may not include " chars. 460 #define TRACE_COUNTER2(category_group, name, value1_name, value1_val, \ 461 value2_name, value2_val) \ 462 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \ 463 TRACE_EVENT_FLAG_NONE, value1_name, \ 464 static_cast<int>(value1_val), value2_name, \ 465 static_cast<int>(value2_val)) 466 #define TRACE_COPY_COUNTER2(category_group, name, value1_name, value1_val, \ 467 value2_name, value2_val) \ 468 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \ 469 TRACE_EVENT_FLAG_COPY, value1_name, \ 470 static_cast<int>(value1_val), value2_name, \ 471 static_cast<int>(value2_val)) 472 473 // Similar to TRACE_COUNTERx, but with a custom |timestamp| provided. 474 #define TRACE_COUNTER_WITH_TIMESTAMP1(category_group, name, timestamp, value) \ 475 INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \ 476 TRACE_EVENT_PHASE_COUNTER, category_group, name, timestamp, \ 477 TRACE_EVENT_FLAG_NONE, "value", static_cast<int>(value)) 478 479 #define TRACE_COUNTER_WITH_TIMESTAMP2(category_group, name, timestamp, \ 480 value1_name, value1_val, value2_name, \ 481 value2_val) \ 482 INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \ 483 TRACE_EVENT_PHASE_COUNTER, category_group, name, timestamp, \ 484 TRACE_EVENT_FLAG_NONE, value1_name, static_cast<int>(value1_val), \ 485 value2_name, static_cast<int>(value2_val)) 486 487 // Records the value of a counter called "name" immediately. Value 488 // must be representable as a 32 bit integer. 489 // - category and name strings must have application lifetime (statics or 490 // literals). They may not include " chars. 491 // - |id| is used to disambiguate counters with the same name. It must either 492 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits 493 // will be xored with a hash of the process ID so that the same pointer on 494 // two different processes will not collide. 495 #define TRACE_COUNTER_ID1(category_group, name, id, value) \ 496 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category_group, \ 497 name, id, TRACE_EVENT_FLAG_NONE, "value", \ 498 static_cast<int>(value)) 499 #define TRACE_COPY_COUNTER_ID1(category_group, name, id, value) \ 500 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category_group, \ 501 name, id, TRACE_EVENT_FLAG_COPY, "value", \ 502 static_cast<int>(value)) 503 504 // Records the values of a multi-parted counter called "name" immediately. 505 // The UI will treat value1 and value2 as parts of a whole, displaying their 506 // values as a stacked-bar chart. 507 // - category and name strings must have application lifetime (statics or 508 // literals). They may not include " chars. 509 // - |id| is used to disambiguate counters with the same name. It must either 510 // be a pointer or an integer value up to 64 bits. If it's a pointer, the bits 511 // will be xored with a hash of the process ID so that the same pointer on 512 // two different processes will not collide. 513 #define TRACE_COUNTER_ID2(category_group, name, id, value1_name, value1_val, \ 514 value2_name, value2_val) \ 515 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category_group, \ 516 name, id, TRACE_EVENT_FLAG_NONE, \ 517 value1_name, static_cast<int>(value1_val), \ 518 value2_name, static_cast<int>(value2_val)) 519 #define TRACE_COPY_COUNTER_ID2(category_group, name, id, value1_name, \ 520 value1_val, value2_name, value2_val) \ 521 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_COUNTER, category_group, \ 522 name, id, TRACE_EVENT_FLAG_COPY, \ 523 value1_name, static_cast<int>(value1_val), \ 524 value2_name, static_cast<int>(value2_val)) 525 526 // TRACE_EVENT_SAMPLE_* events are injected by the sampling profiler. 527 #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP0(category_group, name, \ 528 thread_id, timestamp) \ 529 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 530 TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \ 531 TRACE_EVENT_FLAG_NONE) 532 533 #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP1( \ 534 category_group, name, thread_id, timestamp, arg1_name, arg1_val) \ 535 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 536 TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \ 537 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 538 539 #define TRACE_EVENT_SAMPLE_WITH_TID_AND_TIMESTAMP2(category_group, name, \ 540 thread_id, timestamp, \ 541 arg1_name, arg1_val, \ 542 arg2_name, arg2_val) \ 543 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 544 TRACE_EVENT_PHASE_SAMPLE, category_group, name, 0, thread_id, timestamp, \ 545 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) 546 547 // ASYNC_STEP_* APIs should be only used by legacy code. New code should 548 // consider using NESTABLE_ASYNC_* APIs to describe substeps within an async 549 // event. 550 // Records a single ASYNC_BEGIN event called "name" immediately, with 0, 1 or 2 551 // associated arguments. If the category is not enabled, then this 552 // does nothing. 553 // - category and name strings must have application lifetime (statics or 554 // literals). They may not include " chars. 555 // - |id| is used to match the ASYNC_BEGIN event with the ASYNC_END event. ASYNC 556 // events are considered to match if their category_group, name and id values 557 // all match. |id| must either be a pointer or an integer value up to 64 bits. 558 // If it's a pointer, the bits will be xored with a hash of the process ID so 559 // that the same pointer on two different processes will not collide. 560 // 561 // An asynchronous operation can consist of multiple phases. The first phase is 562 // defined by the ASYNC_BEGIN calls. Additional phases can be defined using the 563 // ASYNC_STEP_INTO or ASYNC_STEP_PAST macros. The ASYNC_STEP_INTO macro will 564 // annotate the block following the call. The ASYNC_STEP_PAST macro will 565 // annotate the block prior to the call. Note that any particular event must use 566 // only STEP_INTO or STEP_PAST macros; they can not mix and match. When the 567 // operation completes, call ASYNC_END. 568 // 569 // An ASYNC trace typically occurs on a single thread (if not, they will only be 570 // drawn on the thread defined in the ASYNC_BEGIN event), but all events in that 571 // operation must use the same |name| and |id|. Each step can have its own 572 // args. 573 #define TRACE_EVENT_ASYNC_BEGIN0(category_group, name, id) \ 574 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ 575 category_group, name, id, \ 576 TRACE_EVENT_FLAG_NONE) 577 #define TRACE_EVENT_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ 578 arg1_val) \ 579 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ 580 category_group, name, id, \ 581 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 582 #define TRACE_EVENT_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ 583 arg1_val, arg2_name, arg2_val) \ 584 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 585 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \ 586 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) 587 #define TRACE_EVENT_COPY_ASYNC_BEGIN0(category_group, name, id) \ 588 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ 589 category_group, name, id, \ 590 TRACE_EVENT_FLAG_COPY) 591 #define TRACE_EVENT_COPY_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ 592 arg1_val) \ 593 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_BEGIN, \ 594 category_group, name, id, \ 595 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) 596 #define TRACE_EVENT_COPY_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ 597 arg1_val, arg2_name, arg2_val) \ 598 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 599 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \ 600 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, arg2_val) 601 602 // Similar to TRACE_EVENT_ASYNC_BEGINx but with a custom |at| timestamp 603 // provided. 604 #define TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, name, id, \ 605 timestamp) \ 606 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 607 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \ 608 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE) 609 #define TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP1( \ 610 category_group, name, id, timestamp, arg1_name, arg1_val) \ 611 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 612 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \ 613 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \ 614 arg1_name, arg1_val) 615 #define TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, name, id, \ 616 timestamp) \ 617 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 618 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \ 619 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_COPY) 620 621 // Records a single ASYNC_STEP_INTO event for |step| immediately. If the 622 // category is not enabled, then this does nothing. The |name| and |id| must 623 // match the ASYNC_BEGIN event above. The |step| param identifies this step 624 // within the async event. This should be called at the beginning of the next 625 // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any 626 // ASYNC_STEP_PAST events. 627 #define TRACE_EVENT_ASYNC_STEP_INTO0(category_group, name, id, step) \ 628 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \ 629 category_group, name, id, \ 630 TRACE_EVENT_FLAG_NONE, "step", step) 631 #define TRACE_EVENT_ASYNC_STEP_INTO1(category_group, name, id, step, \ 632 arg1_name, arg1_val) \ 633 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 634 TRACE_EVENT_PHASE_ASYNC_STEP_INTO, category_group, name, id, \ 635 TRACE_EVENT_FLAG_NONE, "step", step, arg1_name, arg1_val) 636 637 // Similar to TRACE_EVENT_ASYNC_STEP_INTOx but with a custom |at| timestamp 638 // provided. 639 #define TRACE_EVENT_ASYNC_STEP_INTO_WITH_TIMESTAMP0(category_group, name, id, \ 640 step, timestamp) \ 641 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 642 TRACE_EVENT_PHASE_ASYNC_STEP_INTO, category_group, name, id, \ 643 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \ 644 "step", step) 645 646 // Records a single ASYNC_STEP_PAST event for |step| immediately. If the 647 // category is not enabled, then this does nothing. The |name| and |id| must 648 // match the ASYNC_BEGIN event above. The |step| param identifies this step 649 // within the async event. This should be called at the beginning of the next 650 // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any 651 // ASYNC_STEP_INTO events. 652 #define TRACE_EVENT_ASYNC_STEP_PAST0(category_group, name, id, step) \ 653 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_PAST, \ 654 category_group, name, id, \ 655 TRACE_EVENT_FLAG_NONE, "step", step) 656 #define TRACE_EVENT_ASYNC_STEP_PAST1(category_group, name, id, step, \ 657 arg1_name, arg1_val) \ 658 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 659 TRACE_EVENT_PHASE_ASYNC_STEP_PAST, category_group, name, id, \ 660 TRACE_EVENT_FLAG_NONE, "step", step, arg1_name, arg1_val) 661 662 // Records a single ASYNC_END event for "name" immediately. If the category 663 // is not enabled, then this does nothing. 664 #define TRACE_EVENT_ASYNC_END0(category_group, name, id) \ 665 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ 666 category_group, name, id, \ 667 TRACE_EVENT_FLAG_NONE) 668 #define TRACE_EVENT_ASYNC_END1(category_group, name, id, arg1_name, arg1_val) \ 669 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ 670 category_group, name, id, \ 671 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 672 #define TRACE_EVENT_ASYNC_END2(category_group, name, id, arg1_name, arg1_val, \ 673 arg2_name, arg2_val) \ 674 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 675 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \ 676 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) 677 #define TRACE_EVENT_COPY_ASYNC_END0(category_group, name, id) \ 678 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ 679 category_group, name, id, \ 680 TRACE_EVENT_FLAG_COPY) 681 #define TRACE_EVENT_COPY_ASYNC_END1(category_group, name, id, arg1_name, \ 682 arg1_val) \ 683 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_END, \ 684 category_group, name, id, \ 685 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) 686 #define TRACE_EVENT_COPY_ASYNC_END2(category_group, name, id, arg1_name, \ 687 arg1_val, arg2_name, arg2_val) \ 688 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 689 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \ 690 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, arg2_val) 691 692 // Similar to TRACE_EVENT_ASYNC_ENDx but with a custom |at| timestamp provided. 693 #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(category_group, name, id, \ 694 timestamp) \ 695 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 696 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \ 697 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE) 698 #define TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP1(category_group, name, id, \ 699 timestamp, arg1_name, arg1_val) \ 700 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 701 TRACE_EVENT_PHASE_ASYNC_END, category_group, name, id, \ 702 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE, \ 703 arg1_name, arg1_val) 704 705 // NESTABLE_ASYNC_* APIs are used to describe an async operation, which can 706 // be nested within a NESTABLE_ASYNC event and/or have inner NESTABLE_ASYNC 707 // events. 708 // - category and name strings must have application lifetime (statics or 709 // literals). They may not include " chars. 710 // - A pair of NESTABLE_ASYNC_BEGIN event and NESTABLE_ASYNC_END event is 711 // considered as a match if their category_group, name and id all match. 712 // - |id| must either be a pointer or an integer value up to 64 bits. 713 // If it's a pointer, the bits will be xored with a hash of the process ID so 714 // that the same pointer on two different processes will not collide. 715 // - |id| is used to match a child NESTABLE_ASYNC event with its parent 716 // NESTABLE_ASYNC event. Therefore, events in the same nested event tree must 717 // be logged using the same id and category_group. 718 // 719 // Unmatched NESTABLE_ASYNC_END event will be parsed as an event that starts 720 // at the first NESTABLE_ASYNC event of that id, and unmatched 721 // NESTABLE_ASYNC_BEGIN event will be parsed as an event that ends at the last 722 // NESTABLE_ASYNC event of that id. Corresponding warning messages for 723 // unmatched events will be shown in the analysis view. 724 725 // Records a single NESTABLE_ASYNC_BEGIN event called "name" immediately, with 726 // 0, 1 or 2 associated arguments. If the category is not enabled, then this 727 // does nothing. 728 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN0(category_group, name, id) \ 729 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ 730 category_group, name, id, \ 731 TRACE_EVENT_FLAG_NONE) 732 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN1(category_group, name, id, arg1_name, \ 733 arg1_val) \ 734 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, \ 735 category_group, name, id, \ 736 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 737 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN2(category_group, name, id, arg1_name, \ 738 arg1_val, arg2_name, arg2_val) \ 739 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 740 TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \ 741 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) 742 // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 0 743 // or 2 associated arguments. If the category is not enabled, then this does 744 // nothing. 745 #define TRACE_EVENT_NESTABLE_ASYNC_END0(category_group, name, id) \ 746 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ 747 category_group, name, id, \ 748 TRACE_EVENT_FLAG_NONE) 749 // Records a single NESTABLE_ASYNC_END event called "name" immediately, with 1 750 // associated argument. If the category is not enabled, then this does nothing. 751 #define TRACE_EVENT_NESTABLE_ASYNC_END1(category_group, name, id, arg1_name, \ 752 arg1_val) \ 753 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, \ 754 category_group, name, id, \ 755 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 756 #define TRACE_EVENT_NESTABLE_ASYNC_END2(category_group, name, id, arg1_name, \ 757 arg1_val, arg2_name, arg2_val) \ 758 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 759 TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \ 760 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) 761 762 // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately, 763 // with one associated argument. If the category is not enabled, then this 764 // does nothing. 765 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT1(category_group, name, id, \ 766 arg1_name, arg1_val) \ 767 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, \ 768 category_group, name, id, \ 769 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 770 // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately, 771 // with 2 associated arguments. If the category is not enabled, then this 772 // does nothing. 773 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2( \ 774 category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \ 775 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 776 TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, category_group, name, id, \ 777 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) 778 779 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TTS2( \ 780 category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \ 781 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 782 TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \ 783 TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ 784 arg2_name, arg2_val) 785 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TTS2( \ 786 category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \ 787 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 788 TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \ 789 TRACE_EVENT_FLAG_ASYNC_TTS | TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ 790 arg2_name, arg2_val) 791 792 // Similar to TRACE_EVENT_NESTABLE_ASYNC_{BEGIN,END}x but with a custom 793 // |timestamp| provided. 794 #define TRACE_EVENT_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, name, \ 795 id, timestamp) \ 796 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 797 TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \ 798 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE) 799 800 #define TRACE_EVENT_NESTABLE_ASYNC_END_WITH_TIMESTAMP0(category_group, name, \ 801 id, timestamp) \ 802 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 803 TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \ 804 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_NONE) 805 806 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_BEGIN_WITH_TIMESTAMP0( \ 807 category_group, name, id, timestamp) \ 808 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 809 TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN, category_group, name, id, \ 810 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_COPY) 811 #define TRACE_EVENT_COPY_NESTABLE_ASYNC_END_WITH_TIMESTAMP0( \ 812 category_group, name, id, timestamp) \ 813 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 814 TRACE_EVENT_PHASE_NESTABLE_ASYNC_END, category_group, name, id, \ 815 TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, TRACE_EVENT_FLAG_COPY) 816 817 // Records a single NESTABLE_ASYNC_INSTANT event called "name" immediately, 818 // with 2 associated arguments. If the category is not enabled, then this 819 // does nothing. 820 #define TRACE_EVENT_NESTABLE_ASYNC_INSTANT2( \ 821 category_group, name, id, arg1_name, arg1_val, arg2_name, arg2_val) \ 822 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 823 TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT, category_group, name, id, \ 824 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) 825 826 // Records a single FLOW_BEGIN event called "name" immediately, with 0, 1 or 2 827 // associated arguments. If the category is not enabled, then this 828 // does nothing. 829 // - category and name strings must have application lifetime (statics or 830 // literals). They may not include " chars. 831 // - |id| is used to match the FLOW_BEGIN event with the FLOW_END event. FLOW 832 // events are considered to match if their category_group, name and id values 833 // all match. |id| must either be a pointer or an integer value up to 64 bits. 834 // If it's a pointer, the bits will be xored with a hash of the process ID so 835 // that the same pointer on two different processes will not collide. 836 // FLOW events are different from ASYNC events in how they are drawn by the 837 // tracing UI. A FLOW defines asynchronous data flow, such as posting a task 838 // (FLOW_BEGIN) and later executing that task (FLOW_END). Expect FLOWs to be 839 // drawn as lines or arrows from FLOW_BEGIN scopes to FLOW_END scopes. Similar 840 // to ASYNC, a FLOW can consist of multiple phases. The first phase is defined 841 // by the FLOW_BEGIN calls. Additional phases can be defined using the FLOW_STEP 842 // macros. When the operation completes, call FLOW_END. An async operation can 843 // span threads and processes, but all events in that operation must use the 844 // same |name| and |id|. Each event can have its own args. 845 #define TRACE_EVENT_FLOW_BEGIN0(category_group, name, id) \ 846 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ 847 category_group, name, id, \ 848 TRACE_EVENT_FLAG_NONE) 849 #define TRACE_EVENT_FLOW_BEGIN1(category_group, name, id, arg1_name, arg1_val) \ 850 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ 851 category_group, name, id, \ 852 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) 853 #define TRACE_EVENT_FLOW_BEGIN2(category_group, name, id, arg1_name, arg1_val, \ 854 arg2_name, arg2_val) \ 855 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 856 TRACE_EVENT_PHASE_FLOW_BEGIN, category_group, name, id, \ 857 TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, arg2_name, arg2_val) 858 #define TRACE_EVENT_COPY_FLOW_BEGIN0(category_group, name, id) \ 859 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ 860 category_group, name, id, \ 861 TRACE_EVENT_FLAG_COPY) 862 #define TRACE_EVENT_COPY_FLOW_BEGIN1(category_group, name, id, arg1_name, \ 863 arg1_val) \ 864 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_BEGIN, \ 865 category_group, name, id, \ 866 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) 867 #define TRACE_EVENT_COPY_FLOW_BEGIN2(category_group, name, id, arg1_name, \ 868 arg1_val, arg2_name, arg2_val) \ 869 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 870 TRACE_EVENT_PHASE_FLOW_BEGIN, category_group, name, id, \ 871 TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, arg2_name, arg2_val) 872 873 // Records a single FLOW_STEP event for |step| immediately. If the category 874 // is not enabled, then this does nothing. The |name| and |id| must match the 875 // FLOW_BEGIN event above. The |step| param identifies this step within the 876 // async event. This should be called at the beginning of the next phase of an 877 // asynchronous operation. 878 #define TRACE_EVENT_FLOW_STEP0(category_group, name, id, step) \ 879 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ 880 category_group, name, id, \ 881 TRACE_EVENT_FLAG_NONE, "step", step) 882 #define TRACE_EVENT_FLOW_STEP1(category_group, name, id, step, arg1_name, \ 883 arg1_val) \ 884 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 885 TRACE_EVENT_PHASE_FLOW_STEP, category_group, name, id, \ 886 TRACE_EVENT_FLAG_NONE, "step", step, arg1_name, arg1_val) 887 #define TRACE_EVENT_COPY_FLOW_STEP0(category_group, name, id, step) \ 888 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_STEP, \ 889 category_group, name, id, \ 890 TRACE_EVENT_FLAG_COPY, "step", step) 891 #define TRACE_EVENT_COPY_FLOW_STEP1(category_group, name, id, step, arg1_name, \ 892 arg1_val) \ 893 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 894 TRACE_EVENT_PHASE_FLOW_STEP, category_group, name, id, \ 895 TRACE_EVENT_FLAG_COPY, "step", step, arg1_name, arg1_val) 896 897 // Records a single FLOW_END event for "name" immediately. If the category 898 // is not enabled, then this does nothing. 899 #define TRACE_EVENT_FLOW_END0(category_group, name, id) \ 900 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \ 901 name, id, TRACE_EVENT_FLAG_NONE) 902 #define TRACE_EVENT_FLOW_END_BIND_TO_ENCLOSING0(category_group, name, id) \ 903 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \ 904 name, id, \ 905 TRACE_EVENT_FLAG_BIND_TO_ENCLOSING) 906 #define TRACE_EVENT_FLOW_END1(category_group, name, id, arg1_name, arg1_val) \ 907 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \ 908 name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \ 909 arg1_val) 910 #define TRACE_EVENT_FLOW_END2(category_group, name, id, arg1_name, arg1_val, \ 911 arg2_name, arg2_val) \ 912 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \ 913 name, id, TRACE_EVENT_FLAG_NONE, arg1_name, \ 914 arg1_val, arg2_name, arg2_val) 915 #define TRACE_EVENT_COPY_FLOW_END0(category_group, name, id) \ 916 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \ 917 name, id, TRACE_EVENT_FLAG_COPY) 918 #define TRACE_EVENT_COPY_FLOW_END1(category_group, name, id, arg1_name, \ 919 arg1_val) \ 920 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \ 921 name, id, TRACE_EVENT_FLAG_COPY, arg1_name, \ 922 arg1_val) 923 #define TRACE_EVENT_COPY_FLOW_END2(category_group, name, id, arg1_name, \ 924 arg1_val, arg2_name, arg2_val) \ 925 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_FLOW_END, category_group, \ 926 name, id, TRACE_EVENT_FLAG_COPY, arg1_name, \ 927 arg1_val, arg2_name, arg2_val) 928 929 // Special trace event macro to trace task execution with the location where it 930 // was posted from. 931 #define TRACE_TASK_EXECUTION(run_function, task) \ 932 TRACE_EVENT2("toplevel", run_function, "src_file", \ 933 (task).posted_from.file_name(), "src_func", \ 934 (task).posted_from.function_name()); \ 935 TRACE_EVENT_API_SCOPED_TASK_EXECUTION_EVENT INTERNAL_TRACE_EVENT_UID( \ 936 task_event)((task).posted_from.file_name()); 937 938 // TRACE_EVENT_METADATA* events are information related to other 939 // injected events, not events in their own right. 940 #define TRACE_EVENT_METADATA1(category_group, name, arg1_name, arg1_val) \ 941 INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, arg1_name, arg1_val) 942 943 // Records a clock sync event. 944 #define TRACE_EVENT_CLOCK_SYNC_RECEIVER(sync_id) \ 945 INTERNAL_TRACE_EVENT_ADD( \ 946 TRACE_EVENT_PHASE_CLOCK_SYNC, "__metadata", "clock_sync", \ 947 TRACE_EVENT_FLAG_NONE, "sync_id", sync_id) 948 #define TRACE_EVENT_CLOCK_SYNC_ISSUER(sync_id, issue_ts, issue_end_ts) \ 949 INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \ 950 TRACE_EVENT_PHASE_CLOCK_SYNC, "__metadata", "clock_sync", \ 951 issue_end_ts.ToInternalValue(), TRACE_EVENT_FLAG_NONE, \ 952 "sync_id", sync_id, "issue_ts", issue_ts.ToInternalValue()) 953 954 // Macros to track the life time and value of arbitrary client objects. 955 // See also TraceTrackableObject. 956 #define TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group, name, id) \ 957 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 958 TRACE_EVENT_PHASE_CREATE_OBJECT, category_group, name, \ 959 TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) 960 961 #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, \ 962 snapshot) \ 963 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 964 TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, category_group, name, \ 965 TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE, "snapshot", snapshot) 966 967 #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID_AND_TIMESTAMP( \ 968 category_group, name, id, timestamp, snapshot) \ 969 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ 970 TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, category_group, name, \ 971 TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_API_CURRENT_THREAD_ID, timestamp, \ 972 TRACE_EVENT_FLAG_NONE, "snapshot", snapshot) 973 974 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ 975 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 976 TRACE_EVENT_PHASE_DELETE_OBJECT, category_group, name, \ 977 TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) 978 979 // Records entering and leaving trace event contexts. |category_group| and 980 // |name| specify the context category and type. |context| is a 981 // snapshotted context object id. 982 #define TRACE_EVENT_ENTER_CONTEXT(category_group, name, context) \ 983 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 984 TRACE_EVENT_PHASE_ENTER_CONTEXT, category_group, name, \ 985 TRACE_ID_DONT_MANGLE(context), TRACE_EVENT_FLAG_NONE) 986 #define TRACE_EVENT_LEAVE_CONTEXT(category_group, name, context) \ 987 INTERNAL_TRACE_EVENT_ADD_WITH_ID( \ 988 TRACE_EVENT_PHASE_LEAVE_CONTEXT, category_group, name, \ 989 TRACE_ID_DONT_MANGLE(context), TRACE_EVENT_FLAG_NONE) 990 #define TRACE_EVENT_SCOPED_CONTEXT(category_group, name, context) \ 991 INTERNAL_TRACE_EVENT_SCOPED_CONTEXT(category_group, name, \ 992 TRACE_ID_DONT_MANGLE(context)) 993 994 // Macro to efficiently determine if a given category group is enabled. 995 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ 996 do { \ 997 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 998 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 999 *ret = true; \ 1000 } else { \ 1001 *ret = false; \ 1002 } \ 1003 } while (0) 1004 1005 // Macro to explicitly warm up a given category group. This could be useful in 1006 // cases where we want to initialize a category group before any trace events 1007 // for that category group is reported. For example, to have a category group 1008 // always show up in the "record categories" list for manually selecting 1009 // settings in about://tracing. 1010 #define TRACE_EVENT_WARMUP_CATEGORY(category_group) \ 1011 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group) 1012 1013 // Macro to efficiently determine, through polling, if a new trace has begun. 1014 #define TRACE_EVENT_IS_NEW_TRACE(ret) \ 1015 do { \ 1016 static int INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = 0; \ 1017 int num_traces_recorded = TRACE_EVENT_API_GET_NUM_TRACES_RECORDED(); \ 1018 if (num_traces_recorded != -1 && \ 1019 num_traces_recorded != \ 1020 INTERNAL_TRACE_EVENT_UID(lastRecordingNumber)) { \ 1021 INTERNAL_TRACE_EVENT_UID(lastRecordingNumber) = num_traces_recorded; \ 1022 *ret = true; \ 1023 } else { \ 1024 *ret = false; \ 1025 } \ 1026 } while (0) 1027 1028 // Notes regarding the following definitions: 1029 // New values can be added and propagated to third party libraries, but existing 1030 // definitions must never be changed, because third party libraries may use old 1031 // definitions. 1032 1033 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. 1034 #define TRACE_EVENT_PHASE_BEGIN ('B') 1035 #define TRACE_EVENT_PHASE_END ('E') 1036 #define TRACE_EVENT_PHASE_COMPLETE ('X') 1037 #define TRACE_EVENT_PHASE_INSTANT ('I') 1038 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') 1039 #define TRACE_EVENT_PHASE_ASYNC_STEP_INTO ('T') 1040 #define TRACE_EVENT_PHASE_ASYNC_STEP_PAST ('p') 1041 #define TRACE_EVENT_PHASE_ASYNC_END ('F') 1042 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN ('b') 1043 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_END ('e') 1044 #define TRACE_EVENT_PHASE_NESTABLE_ASYNC_INSTANT ('n') 1045 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') 1046 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') 1047 #define TRACE_EVENT_PHASE_FLOW_END ('f') 1048 #define TRACE_EVENT_PHASE_METADATA ('M') 1049 #define TRACE_EVENT_PHASE_COUNTER ('C') 1050 #define TRACE_EVENT_PHASE_SAMPLE ('P') 1051 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') 1052 #define TRACE_EVENT_PHASE_SNAPSHOT_OBJECT ('O') 1053 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') 1054 #define TRACE_EVENT_PHASE_MEMORY_DUMP ('v') 1055 #define TRACE_EVENT_PHASE_MARK ('R') 1056 #define TRACE_EVENT_PHASE_CLOCK_SYNC ('c') 1057 #define TRACE_EVENT_PHASE_ENTER_CONTEXT ('(') 1058 #define TRACE_EVENT_PHASE_LEAVE_CONTEXT (')') 1059 1060 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. 1061 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned int>(0)) 1062 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned int>(1 << 0)) 1063 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned int>(1 << 1)) 1064 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned int>(1 << 2)) 1065 #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned int>(1 << 3)) 1066 #define TRACE_EVENT_FLAG_SCOPE_EXTRA (static_cast<unsigned int>(1 << 4)) 1067 #define TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP (static_cast<unsigned int>(1 << 5)) 1068 #define TRACE_EVENT_FLAG_ASYNC_TTS (static_cast<unsigned int>(1 << 6)) 1069 #define TRACE_EVENT_FLAG_BIND_TO_ENCLOSING (static_cast<unsigned int>(1 << 7)) 1070 #define TRACE_EVENT_FLAG_FLOW_IN (static_cast<unsigned int>(1 << 8)) 1071 #define TRACE_EVENT_FLAG_FLOW_OUT (static_cast<unsigned int>(1 << 9)) 1072 #define TRACE_EVENT_FLAG_HAS_CONTEXT_ID (static_cast<unsigned int>(1 << 10)) 1073 #define TRACE_EVENT_FLAG_HAS_PROCESS_ID (static_cast<unsigned int>(1 << 11)) 1074 1075 #define TRACE_EVENT_FLAG_SCOPE_MASK \ 1076 (static_cast<unsigned int>(TRACE_EVENT_FLAG_SCOPE_OFFSET | \ 1077 TRACE_EVENT_FLAG_SCOPE_EXTRA)) 1078 1079 // Type values for identifying types in the TraceValue union. 1080 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) 1081 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) 1082 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3)) 1083 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4)) 1084 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5)) 1085 #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6)) 1086 #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7)) 1087 #define TRACE_VALUE_TYPE_CONVERTABLE (static_cast<unsigned char>(8)) 1088 1089 // Enum reflecting the scope of an INSTANT event. Must fit within 1090 // TRACE_EVENT_FLAG_SCOPE_MASK. 1091 #define TRACE_EVENT_SCOPE_GLOBAL (static_cast<unsigned char>(0 << 3)) 1092 #define TRACE_EVENT_SCOPE_PROCESS (static_cast<unsigned char>(1 << 3)) 1093 #define TRACE_EVENT_SCOPE_THREAD (static_cast<unsigned char>(2 << 3)) 1094 1095 #define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g') 1096 #define TRACE_EVENT_SCOPE_NAME_PROCESS ('p') 1097 #define TRACE_EVENT_SCOPE_NAME_THREAD ('t') 1098