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