OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ | 5 #ifndef BASE_TRACE_EVENT_TRACE_EVENT_H_ |
6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ | 6 #define BASE_TRACE_EVENT_TRACE_EVENT_H_ |
7 | 7 |
8 // This header file defines implementation details of how the trace macros in | 8 // This header file defines implementation details of how the trace macros in |
9 // trace_event_common.h collect and store trace events. Anything not | 9 // trace_event_common.h collect and store trace events. Anything not |
10 // implementation-specific should go in trace_event_common.h instead of here. | 10 // implementation-specific should go in trace_event_common.h instead of here. |
11 | 11 |
12 #include <stddef.h> | 12 #include <stddef.h> |
13 #include <stdint.h> | 13 #include <stdint.h> |
14 | 14 |
15 #include <string> | 15 #include <string> |
16 | 16 |
17 #include "base/atomicops.h" | 17 #include "base/atomicops.h" |
18 #include "base/format_macros.h" | |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/strings/stringprintf.h" | |
19 #include "base/time/time.h" | 21 #include "base/time/time.h" |
20 #include "base/trace_event/common/trace_event_common.h" | 22 #include "base/trace_event/common/trace_event_common.h" |
21 #include "base/trace_event/heap_profiler.h" | 23 #include "base/trace_event/heap_profiler.h" |
24 #include "base/trace_event/trace_event_argument.h" | |
22 #include "base/trace_event/trace_event_system_stats_monitor.h" | 25 #include "base/trace_event/trace_event_system_stats_monitor.h" |
23 #include "base/trace_event/trace_log.h" | 26 #include "base/trace_event/trace_log.h" |
24 #include "build/build_config.h" | 27 #include "build/build_config.h" |
25 | 28 |
26 // By default, const char* argument values are assumed to have long-lived scope | 29 // By default, const char* argument values are assumed to have long-lived scope |
27 // and will not be copied. Use this macro to force a const char* to be copied. | 30 // and will not be copied. Use this macro to force a const char* to be copied. |
28 #define TRACE_STR_COPY(str) \ | 31 #define TRACE_STR_COPY(str) \ |
29 trace_event_internal::TraceStringWithCopy(str) | 32 trace_event_internal::TraceStringWithCopy(str) |
30 | 33 |
31 // By default, uint64_t ID argument values are not mangled with the Process ID | 34 // DEPRECATED: do not use. Consider using (GLOBAL_)TRACE_ID(_WITH_SCOPE) macros, |
32 // in TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. | 35 // instead. By default, uint64_t ID argument values are not mangled with the |
36 // Process ID in TRACE_EVENT_ASYNC macros. Use this macro to force Process ID | |
37 // mangling. | |
33 #define TRACE_ID_MANGLE(id) \ | 38 #define TRACE_ID_MANGLE(id) \ |
34 trace_event_internal::TraceID::ForceMangle(id) | 39 trace_event_internal::TraceID::ForceMangle(id) |
35 | 40 |
36 // By default, pointers are mangled with the Process ID in TRACE_EVENT_ASYNC | 41 // DEPRECATED: do not use. Consider using (GLOBAL_)TRACE_ID(_WITH_SCOPE) macros, |
Primiano Tucci (use gerrit)
2016/08/05 14:20:07
so the doubt that I have when I see that both thes
| |
37 // macros. Use this macro to prevent Process ID mangling. | 42 // instead. By default, pointers are mangled with the Process ID in |
43 // TRACE_EVENT_ASYNC macros. Use this macro to prevent Process ID mangling. | |
38 #define TRACE_ID_DONT_MANGLE(id) \ | 44 #define TRACE_ID_DONT_MANGLE(id) \ |
39 trace_event_internal::TraceID::DontMangle(id) | 45 trace_event_internal::TraceID::DontMangle(id) |
40 | 46 |
47 // Sets a flag to indicate that the ID is global across all processes. | |
48 #define GLOBAL_TRACE_ID(...) \ | |
Primiano Tucci (use gerrit)
2016/08/05 14:20:07
I thought that the ID is already global, reason fo
| |
49 trace_event_internal::TraceID::WithScope( \ | |
50 trace_event_internal::kGlobalScope, true, __VA_ARGS__) | |
51 | |
41 // By default, trace IDs are eventually converted to a single 64-bit number. Use | 52 // By default, trace IDs are eventually converted to a single 64-bit number. Use |
42 // this macro to add a scope string. | 53 // this macro to add a scope string. |
43 #define TRACE_ID_WITH_SCOPE(scope, id) \ | 54 #define TRACE_ID_WITH_SCOPE(scope, ...) \ |
44 trace_event_internal::TraceID::WithScope(scope, id) | 55 trace_event_internal::TraceID::WithScope(scope, false, __VA_ARGS__) |
56 #define GLOBAL_TRACE_ID_WITH_SCOPE(scope, ...) \ | |
57 trace_event_internal::TraceID::WithScope(scope, true, __VA_ARGS__) | |
45 | 58 |
46 // Sets the current sample state to the given category and name (both must be | 59 // Sets the current sample state to the given category and name (both must be |
47 // constant strings). These states are intended for a sampling profiler. | 60 // constant strings). These states are intended for a sampling profiler. |
48 // Implementation note: we store category and name together because we don't | 61 // Implementation note: we store category and name together because we don't |
49 // want the inconsistency/expense of storing two pointers. | 62 // want the inconsistency/expense of storing two pointers. |
50 // |thread_bucket| is [0..2] and is used to statically isolate samples in one | 63 // |thread_bucket| is [0..2] and is used to statically isolate samples in one |
51 // thread from others. | 64 // thread from others. |
52 #define TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET( \ | 65 #define TRACE_EVENT_SET_SAMPLING_STATE_FOR_BUCKET( \ |
53 bucket_number, category, name) \ | 66 bucket_number, category, name) \ |
54 trace_event_internal:: \ | 67 trace_event_internal:: \ |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 &trace_event_flags); \ | 355 &trace_event_flags); \ |
343 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 356 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
344 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ | 357 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
345 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ | 358 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ |
346 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ | 359 thread_id, base::TimeTicks::FromInternalValue(timestamp), \ |
347 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ | 360 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ |
348 trace_event_internal::kNoId, ##__VA_ARGS__); \ | 361 trace_event_internal::kNoId, ##__VA_ARGS__); \ |
349 } \ | 362 } \ |
350 } while (0) | 363 } while (0) |
351 | 364 |
352 // The trace ID and bind ID will never be mangled by this macro. | 365 // The linked ID will not be mangled. |
353 #define INTERNAL_TRACE_EVENT_ADD_BIND_IDS(category_group, name, id, bind_id, \ | 366 #define INTERNAL_TRACE_EVENT_ADD_LINK_IDS(category_group, name, id1, id2) \ |
354 ...) \ | 367 do { \ |
355 do { \ | 368 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
356 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 369 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
357 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 370 unsigned int flags = TRACE_EVENT_FLAG_HAS_ID; \ |
358 trace_event_internal::TraceID::DontMangle source_id(id); \ | 371 trace_event_internal::TraceID id(id1, &flags); \ |
359 trace_event_internal::TraceID::DontMangle target_id(bind_id); \ | 372 unsigned int args_id_flags = TRACE_EVENT_FLAG_NONE; \ |
360 if (target_id.scope() == trace_event_internal::kGlobalScope) { \ | 373 trace_event_internal::TraceID args_id(id2, &args_id_flags); \ |
361 trace_event_internal::AddTraceEvent( \ | 374 std::unique_ptr<TracedValue> value(new TracedValue()); \ |
Primiano Tucci (use gerrit)
2016/08/05 14:20:07
I don't see any precedent of using TracedValue dir
| |
362 TRACE_EVENT_PHASE_BIND_IDS, \ | 375 if (args_id.has_prefix()) { \ |
363 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 376 value->BeginArray("id"); \ |
364 name, source_id.scope(), source_id.raw_id(), \ | 377 value->AppendString( \ |
365 TRACE_EVENT_FLAG_HAS_ID, target_id.raw_id(), ##__VA_ARGS__); \ | 378 StringPrintf("0x%" PRIx64, \ |
366 } else { \ | 379 static_cast<uint64_t>(args_id.prefix()))); \ |
367 trace_event_internal::AddTraceEvent( \ | 380 value->AppendString( \ |
368 TRACE_EVENT_PHASE_BIND_IDS, \ | 381 StringPrintf("0x%" PRIx64, \ |
369 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 382 static_cast<uint64_t>(args_id.raw_id()))); \ |
370 name, source_id.scope(), source_id.raw_id(), \ | 383 value->EndArray(); \ |
371 TRACE_EVENT_FLAG_HAS_ID, target_id.raw_id(), \ | 384 } else { \ |
372 "bind_scope", target_id.scope(), ##__VA_ARGS__); \ | 385 value->SetString( \ |
373 } \ | 386 "id", \ |
374 } \ | 387 StringPrintf("0x%" PRIx64, \ |
388 static_cast<uint64_t>(args_id.raw_id()))); \ | |
389 } \ | |
390 if (args_id_flags & TRACE_EVENT_FLAG_ID_IS_GLOBAL) \ | |
391 value->SetBoolean("id_is_global", true); \ | |
392 if (args_id.scope() != trace_event_internal::kGlobalScope) \ | |
393 value->SetString("scope", args_id.scope()); \ | |
394 trace_event_internal::AddTraceEvent( \ | |
395 TRACE_EVENT_PHASE_BIND_IDS, \ | |
396 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | |
397 name, id.scope(), id.raw_id(), flags, trace_event_internal::kNoId, \ | |
398 "linked_id", std::move(value)); \ | |
399 } \ | |
375 } while (0) | 400 } while (0) |
376 | 401 |
377 // Implementation detail: internal macro to create static category and add | 402 // Implementation detail: internal macro to create static category and add |
378 // metadata event if the category is enabled. | 403 // metadata event if the category is enabled |
379 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ | 404 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ |
380 do { \ | 405 do { \ |
381 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 406 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
382 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 407 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
383 TRACE_EVENT_API_ADD_METADATA_EVENT( \ | 408 TRACE_EVENT_API_ADD_METADATA_EVENT( \ |
384 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ | 409 INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
385 ##__VA_ARGS__); \ | 410 ##__VA_ARGS__); \ |
386 } \ | 411 } \ |
387 } while (0) | 412 } while (0) |
388 | 413 |
(...skipping 10 matching lines...) Expand all Loading... | |
399 } \ | 424 } \ |
400 \ | 425 \ |
401 private: \ | 426 private: \ |
402 uint64_t cid_; \ | 427 uint64_t cid_; \ |
403 /* Local class friendly DISALLOW_COPY_AND_ASSIGN */ \ | 428 /* Local class friendly DISALLOW_COPY_AND_ASSIGN */ \ |
404 INTERNAL_TRACE_EVENT_UID(ScopedContext) \ | 429 INTERNAL_TRACE_EVENT_UID(ScopedContext) \ |
405 (const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {}; \ | 430 (const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {}; \ |
406 void operator=(const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {}; \ | 431 void operator=(const INTERNAL_TRACE_EVENT_UID(ScopedContext)&) {}; \ |
407 }; \ | 432 }; \ |
408 INTERNAL_TRACE_EVENT_UID(ScopedContext) \ | 433 INTERNAL_TRACE_EVENT_UID(ScopedContext) \ |
409 INTERNAL_TRACE_EVENT_UID(scoped_context)(context.raw_id()); | 434 INTERNAL_TRACE_EVENT_UID(scoped_context)(context); |
410 | 435 |
411 // Implementation detail: internal macro to trace a task execution with the | 436 // Implementation detail: internal macro to trace a task execution with the |
412 // location where it was posted from. | 437 // location where it was posted from. |
413 #define INTERNAL_TRACE_TASK_EXECUTION(run_function, task) \ | 438 #define INTERNAL_TRACE_TASK_EXECUTION(run_function, task) \ |
414 TRACE_EVENT2("toplevel", run_function, "src_file", \ | 439 TRACE_EVENT2("toplevel", run_function, "src_file", \ |
415 (task).posted_from.file_name(), "src_func", \ | 440 (task).posted_from.file_name(), "src_func", \ |
416 (task).posted_from.function_name()); \ | 441 (task).posted_from.function_name()); \ |
417 TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION INTERNAL_TRACE_EVENT_UID( \ | 442 TRACE_HEAP_PROFILER_API_SCOPED_TASK_EXECUTION INTERNAL_TRACE_EVENT_UID( \ |
418 task_event)((task).posted_from.file_name()); | 443 task_event)((task).posted_from.file_name()); |
419 | 444 |
420 namespace trace_event_internal { | 445 namespace trace_event_internal { |
421 | 446 |
422 // Specify these values when the corresponding argument of AddTraceEvent is not | 447 // Specify these values when the corresponding argument of AddTraceEvent is not |
423 // used. | 448 // used. |
424 const int kZeroNumArgs = 0; | 449 const int kZeroNumArgs = 0; |
425 const std::nullptr_t kGlobalScope = nullptr; | 450 const std::nullptr_t kGlobalScope = nullptr; |
426 const unsigned long long kNoId = 0; | 451 const unsigned long long kNoId = 0; |
427 | 452 |
428 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers | 453 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers |
429 // are by default mangled with the Process ID so that they are unlikely to | 454 // are by default mangled with the Process ID so that they are unlikely to |
430 // collide when the same pointer is used on different processes. | 455 // collide when the same pointer is used on different processes. |
431 class TraceID { | 456 class TraceID { |
432 public: | 457 public: |
433 class WithScope { | 458 class WithScope { |
434 public: | 459 public: |
435 WithScope(const char* scope, unsigned long long raw_id) | 460 WithScope(const char* scope, bool is_global, unsigned long long raw_id) |
436 : scope_(scope), raw_id_(raw_id) {} | 461 : scope_(scope), is_global_(is_global), raw_id_(raw_id) {} |
462 WithScope(const char* scope, bool is_global, unsigned long long prefix, | |
Primiano Tucci (use gerrit)
2016/08/05 14:20:07
what is this prefix? I don't see documented this a
| |
463 unsigned long long raw_id) | |
464 : scope_(scope), is_global_(is_global), has_prefix_(true), | |
465 prefix_(prefix), raw_id_(raw_id) {} | |
466 const char* scope() const { return scope_; } | |
437 unsigned long long raw_id() const { return raw_id_; } | 467 unsigned long long raw_id() const { return raw_id_; } |
438 const char* scope() const { return scope_; } | 468 bool has_prefix() const { return has_prefix_; } |
469 unsigned long long prefix() const { return prefix_; } | |
470 bool is_global() const { return is_global_; } | |
439 private: | 471 private: |
440 const char* scope_ = nullptr; | 472 const char* scope_ = nullptr; |
473 bool is_global_ = false; | |
474 bool has_prefix_ = false; | |
475 unsigned long long prefix_; | |
441 unsigned long long raw_id_; | 476 unsigned long long raw_id_; |
442 }; | 477 }; |
443 | 478 |
444 class DontMangle { | 479 class DontMangle { |
445 public: | 480 public: |
446 explicit DontMangle(const void* raw_id) | 481 explicit DontMangle(const void* raw_id) |
447 : raw_id_(static_cast<unsigned long long>( | 482 : raw_id_(static_cast<unsigned long long>( |
448 reinterpret_cast<uintptr_t>(raw_id))) {} | 483 reinterpret_cast<uintptr_t>(raw_id))) {} |
449 explicit DontMangle(unsigned long long raw_id) : raw_id_(raw_id) {} | 484 explicit DontMangle(unsigned long long raw_id) : raw_id_(raw_id) {} |
450 explicit DontMangle(unsigned long raw_id) : raw_id_(raw_id) {} | 485 explicit DontMangle(unsigned long raw_id) : raw_id_(raw_id) {} |
451 explicit DontMangle(unsigned int raw_id) : raw_id_(raw_id) {} | 486 explicit DontMangle(unsigned int raw_id) : raw_id_(raw_id) {} |
452 explicit DontMangle(unsigned short raw_id) : raw_id_(raw_id) {} | 487 explicit DontMangle(unsigned short raw_id) : raw_id_(raw_id) {} |
453 explicit DontMangle(unsigned char raw_id) : raw_id_(raw_id) {} | 488 explicit DontMangle(unsigned char raw_id) : raw_id_(raw_id) {} |
454 explicit DontMangle(long long raw_id) | 489 explicit DontMangle(long long raw_id) |
455 : raw_id_(static_cast<unsigned long long>(raw_id)) {} | 490 : raw_id_(static_cast<unsigned long long>(raw_id)) {} |
456 explicit DontMangle(long raw_id) | 491 explicit DontMangle(long raw_id) |
457 : raw_id_(static_cast<unsigned long long>(raw_id)) {} | 492 : raw_id_(static_cast<unsigned long long>(raw_id)) {} |
458 explicit DontMangle(int raw_id) | 493 explicit DontMangle(int raw_id) |
459 : raw_id_(static_cast<unsigned long long>(raw_id)) {} | 494 : raw_id_(static_cast<unsigned long long>(raw_id)) {} |
460 explicit DontMangle(short raw_id) | 495 explicit DontMangle(short raw_id) |
461 : raw_id_(static_cast<unsigned long long>(raw_id)) {} | 496 : raw_id_(static_cast<unsigned long long>(raw_id)) {} |
462 explicit DontMangle(signed char raw_id) | 497 explicit DontMangle(signed char raw_id) |
463 : raw_id_(static_cast<unsigned long long>(raw_id)) {} | 498 : raw_id_(static_cast<unsigned long long>(raw_id)) {} |
464 explicit DontMangle(WithScope scoped_id) | |
465 : scope_(scoped_id.scope()), raw_id_(scoped_id.raw_id()) {} | |
466 const char* scope() const { return scope_; } | |
467 unsigned long long raw_id() const { return raw_id_; } | 499 unsigned long long raw_id() const { return raw_id_; } |
468 private: | 500 private: |
469 const char* scope_ = nullptr; | |
470 unsigned long long raw_id_; | 501 unsigned long long raw_id_; |
471 }; | 502 }; |
472 | 503 |
473 class ForceMangle { | 504 class ForceMangle { |
474 public: | 505 public: |
475 explicit ForceMangle(unsigned long long raw_id) : raw_id_(raw_id) {} | 506 explicit ForceMangle(unsigned long long raw_id) : raw_id_(raw_id) {} |
476 explicit ForceMangle(unsigned long raw_id) : raw_id_(raw_id) {} | 507 explicit ForceMangle(unsigned long raw_id) : raw_id_(raw_id) {} |
477 explicit ForceMangle(unsigned int raw_id) : raw_id_(raw_id) {} | 508 explicit ForceMangle(unsigned int raw_id) : raw_id_(raw_id) {} |
478 explicit ForceMangle(unsigned short raw_id) : raw_id_(raw_id) {} | 509 explicit ForceMangle(unsigned short raw_id) : raw_id_(raw_id) {} |
479 explicit ForceMangle(unsigned char raw_id) : raw_id_(raw_id) {} | 510 explicit ForceMangle(unsigned char raw_id) : raw_id_(raw_id) {} |
(...skipping 13 matching lines...) Expand all Loading... | |
493 }; | 524 }; |
494 TraceID(const void* raw_id, unsigned int* flags) | 525 TraceID(const void* raw_id, unsigned int* flags) |
495 : raw_id_(static_cast<unsigned long long>( | 526 : raw_id_(static_cast<unsigned long long>( |
496 reinterpret_cast<uintptr_t>(raw_id))) { | 527 reinterpret_cast<uintptr_t>(raw_id))) { |
497 *flags |= TRACE_EVENT_FLAG_MANGLE_ID; | 528 *flags |= TRACE_EVENT_FLAG_MANGLE_ID; |
498 } | 529 } |
499 TraceID(ForceMangle raw_id, unsigned int* flags) : raw_id_(raw_id.raw_id()) { | 530 TraceID(ForceMangle raw_id, unsigned int* flags) : raw_id_(raw_id.raw_id()) { |
500 *flags |= TRACE_EVENT_FLAG_MANGLE_ID; | 531 *flags |= TRACE_EVENT_FLAG_MANGLE_ID; |
501 } | 532 } |
502 TraceID(DontMangle maybe_scoped_id, unsigned int* flags) | 533 TraceID(DontMangle maybe_scoped_id, unsigned int* flags) |
503 : scope_(maybe_scoped_id.scope()), raw_id_(maybe_scoped_id.raw_id()) { | 534 : raw_id_(maybe_scoped_id.raw_id()) { |
535 *flags |= TRACE_EVENT_FLAG_ID_IS_GLOBAL; | |
504 } | 536 } |
505 TraceID(unsigned long long raw_id, unsigned int* flags) : raw_id_(raw_id) { | 537 TraceID(unsigned long long raw_id, unsigned int* flags) : raw_id_(raw_id) { |
506 (void)flags; | 538 (void)flags; |
507 } | 539 } |
508 TraceID(unsigned long raw_id, unsigned int* flags) : raw_id_(raw_id) { | 540 TraceID(unsigned long raw_id, unsigned int* flags) : raw_id_(raw_id) { |
509 (void)flags; | 541 (void)flags; |
510 } | 542 } |
511 TraceID(unsigned int raw_id, unsigned int* flags) : raw_id_(raw_id) { | 543 TraceID(unsigned int raw_id, unsigned int* flags) : raw_id_(raw_id) { |
512 (void)flags; | 544 (void)flags; |
513 } | 545 } |
514 TraceID(unsigned short raw_id, unsigned int* flags) : raw_id_(raw_id) { | 546 TraceID(unsigned short raw_id, unsigned int* flags) : raw_id_(raw_id) { |
515 (void)flags; | 547 (void)flags; |
516 } | 548 } |
517 TraceID(unsigned char raw_id, unsigned int* flags) : raw_id_(raw_id) { | 549 TraceID(unsigned char raw_id, unsigned int* flags) : raw_id_(raw_id) { |
518 (void)flags; | 550 (void)flags; |
519 } | 551 } |
520 TraceID(long long raw_id, unsigned int* flags) | 552 TraceID(long long raw_id, unsigned int* flags) |
521 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } | 553 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } |
522 TraceID(long raw_id, unsigned int* flags) | 554 TraceID(long raw_id, unsigned int* flags) |
523 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } | 555 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } |
524 TraceID(int raw_id, unsigned int* flags) | 556 TraceID(int raw_id, unsigned int* flags) |
525 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } | 557 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } |
526 TraceID(short raw_id, unsigned int* flags) | 558 TraceID(short raw_id, unsigned int* flags) |
527 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } | 559 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } |
528 TraceID(signed char raw_id, unsigned int* flags) | 560 TraceID(signed char raw_id, unsigned int* flags) |
529 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } | 561 : raw_id_(static_cast<unsigned long long>(raw_id)) { (void)flags; } |
530 TraceID(WithScope scoped_id, unsigned int* flags) | 562 TraceID(WithScope scoped_id, unsigned int* flags) |
531 : scope_(scoped_id.scope()), raw_id_(scoped_id.raw_id()) {} | 563 : scope_(scoped_id.scope()), has_prefix_(scoped_id.has_prefix()), |
564 prefix_(scoped_id.prefix()), raw_id_(scoped_id.raw_id()) { | |
565 if (scoped_id.is_global()) | |
566 *flags |= TRACE_EVENT_FLAG_ID_IS_GLOBAL; | |
567 } | |
532 | 568 |
533 unsigned long long raw_id() const { return raw_id_; } | 569 unsigned long long raw_id() const { return raw_id_; } |
534 const char* scope() const { return scope_; } | 570 const char* scope() const { return scope_; } |
571 bool has_prefix() const { return has_prefix_; } | |
572 unsigned long long prefix() const { return prefix_; } | |
535 | 573 |
536 private: | 574 private: |
537 const char* scope_ = nullptr; | 575 const char* scope_ = nullptr; |
576 bool has_prefix_ = false; | |
577 unsigned long long prefix_; | |
538 unsigned long long raw_id_; | 578 unsigned long long raw_id_; |
539 }; | 579 }; |
540 | 580 |
541 // Simple union to store various types as unsigned long long. | 581 // Simple union to store various types as unsigned long long. |
542 union TraceValueUnion { | 582 union TraceValueUnion { |
543 bool as_bool; | 583 bool as_bool; |
544 unsigned long long as_uint; | 584 unsigned long long as_uint; |
545 long long as_int; | 585 long long as_int; |
546 double as_double; | 586 double as_double; |
547 const void* as_pointer; | 587 const void* as_pointer; |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1108 const char* name_; | 1148 const char* name_; |
1109 IDType id_; | 1149 IDType id_; |
1110 | 1150 |
1111 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1151 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
1112 }; | 1152 }; |
1113 | 1153 |
1114 } // namespace trace_event | 1154 } // namespace trace_event |
1115 } // namespace base | 1155 } // namespace base |
1116 | 1156 |
1117 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 1157 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
OLD | NEW |