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