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