Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Side by Side Diff: base/trace_event/trace_event.h

Issue 2504753002: tracing: Introduce API for composite IDs (Closed)
Patch Set: comments Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.
(...skipping 25 matching lines...) Expand all
36 #define TRACE_ID_MANGLE(id) \ 36 #define TRACE_ID_MANGLE(id) \
37 trace_event_internal::TraceID::ForceMangle(id) 37 trace_event_internal::TraceID::ForceMangle(id)
38 38
39 // DEPRECATED: do not use: Consider using TRACE_ID_{GLOBAL, LOCAL} macros, 39 // DEPRECATED: do not use: Consider using TRACE_ID_{GLOBAL, LOCAL} macros,
40 // instead. By default, pointers are mangled with the Process ID in 40 // instead. By default, pointers are mangled with the Process ID in
41 // TRACE_EVENT_ASYNC macros. Use this macro to prevent Process ID mangling. 41 // TRACE_EVENT_ASYNC macros. Use this macro to prevent Process ID mangling.
42 #define TRACE_ID_DONT_MANGLE(id) \ 42 #define TRACE_ID_DONT_MANGLE(id) \
43 trace_event_internal::TraceID::DontMangle(id) 43 trace_event_internal::TraceID::DontMangle(id)
44 44
45 // By default, trace IDs are eventually converted to a single 64-bit number. Use 45 // By default, trace IDs are eventually converted to a single 64-bit number. Use
46 // this macro to add a scope string. 46 // this macro to add a scope string.
Primiano Tucci (use gerrit) 2017/01/17 12:25:47 can you just add some examples in the comment to s
chiniforooshan1 2017/01/17 16:44:08 Done.
47 #define TRACE_ID_WITH_SCOPE(scope, id) \ 47 #define TRACE_ID_WITH_SCOPE(scope, ...) \
48 trace_event_internal::TraceID::WithScope(scope, id) 48 trace_event_internal::TraceID::WithScope(scope, ##__VA_ARGS__)
49 49
50 #define TRACE_ID_GLOBAL(id) trace_event_internal::TraceID::GlobalId(id) 50 #define TRACE_ID_GLOBAL(id) trace_event_internal::TraceID::GlobalId(id)
51 #define TRACE_ID_LOCAL(id) trace_event_internal::TraceID::LocalId(id) 51 #define TRACE_ID_LOCAL(id) trace_event_internal::TraceID::LocalId(id)
52 52
53 #define TRACE_EVENT_API_CURRENT_THREAD_ID \ 53 #define TRACE_EVENT_API_CURRENT_THREAD_ID \
54 static_cast<int>(base::PlatformThread::CurrentId()) 54 static_cast<int>(base::PlatformThread::CurrentId())
55 55
56 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ 56 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \
57 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ 57 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \
58 (base::trace_event::TraceCategory::ENABLED_FOR_RECORDING | \ 58 (base::trace_event::TraceCategory::ENABLED_FOR_RECORDING | \
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 WithScope(const char* scope, unsigned long long raw_id) 423 WithScope(const char* scope, unsigned long long raw_id)
424 : scope_(scope), raw_id_(raw_id) {} 424 : scope_(scope), raw_id_(raw_id) {}
425 WithScope(const char* scope, LocalId local_id) 425 WithScope(const char* scope, LocalId local_id)
426 : scope_(scope), raw_id_(local_id.raw_id()) { 426 : scope_(scope), raw_id_(local_id.raw_id()) {
427 id_flags_ = TRACE_EVENT_FLAG_HAS_LOCAL_ID; 427 id_flags_ = TRACE_EVENT_FLAG_HAS_LOCAL_ID;
428 } 428 }
429 WithScope(const char* scope, GlobalId global_id) 429 WithScope(const char* scope, GlobalId global_id)
430 : scope_(scope), raw_id_(global_id.raw_id()) { 430 : scope_(scope), raw_id_(global_id.raw_id()) {
431 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID; 431 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID;
432 } 432 }
433 WithScope(const char* scope,
434 unsigned long long prefix,
435 unsigned long long raw_id)
436 : scope_(scope), has_prefix_(true), prefix_(prefix), raw_id_(raw_id) {}
437 WithScope(const char* scope, unsigned long long prefix, GlobalId global_id)
438 : scope_(scope),
439 has_prefix_(true),
440 prefix_(prefix),
441 raw_id_(global_id.raw_id()) {
442 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID;
443 }
433 unsigned long long raw_id() const { return raw_id_; } 444 unsigned long long raw_id() const { return raw_id_; }
434 const char* scope() const { return scope_; } 445 const char* scope() const { return scope_; }
446 bool has_prefix() const { return has_prefix_; }
447 unsigned long long prefix() const { return prefix_; }
435 unsigned int id_flags() const { return id_flags_; } 448 unsigned int id_flags() const { return id_flags_; }
449
436 private: 450 private:
437 const char* scope_ = nullptr; 451 const char* scope_ = nullptr;
452 bool has_prefix_ = false;
453 unsigned long long prefix_;
438 unsigned long long raw_id_; 454 unsigned long long raw_id_;
439 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID; 455 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID;
440 }; 456 };
441 457
442 // DEPRECATED: consider using LocalId or GlobalId, instead. 458 // DEPRECATED: consider using LocalId or GlobalId, instead.
443 class DontMangle { 459 class DontMangle {
444 public: 460 public:
445 explicit DontMangle(const void* raw_id) 461 explicit DontMangle(const void* raw_id)
446 : raw_id_(static_cast<unsigned long long>( 462 : raw_id_(static_cast<unsigned long long>(
447 reinterpret_cast<uintptr_t>(raw_id))) {} 463 reinterpret_cast<uintptr_t>(raw_id))) {}
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 TraceID(short raw_id) 526 TraceID(short raw_id)
511 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 527 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
512 TraceID(signed char raw_id) 528 TraceID(signed char raw_id)
513 : raw_id_(static_cast<unsigned long long>(raw_id)) {} 529 : raw_id_(static_cast<unsigned long long>(raw_id)) {}
514 TraceID(LocalId raw_id) : raw_id_(raw_id.raw_id()) { 530 TraceID(LocalId raw_id) : raw_id_(raw_id.raw_id()) {
515 id_flags_ = TRACE_EVENT_FLAG_HAS_LOCAL_ID; 531 id_flags_ = TRACE_EVENT_FLAG_HAS_LOCAL_ID;
516 } 532 }
517 TraceID(GlobalId raw_id) : raw_id_(raw_id.raw_id()) { 533 TraceID(GlobalId raw_id) : raw_id_(raw_id.raw_id()) {
518 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID; 534 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID;
519 } 535 }
520 TraceID(WithScope scoped_id) : scope_(scoped_id.scope()), 536 TraceID(WithScope scoped_id)
521 raw_id_(scoped_id.raw_id()), id_flags_(scoped_id.id_flags()) {} 537 : scope_(scoped_id.scope()),
538 has_prefix_(scoped_id.has_prefix()),
539 prefix_(scoped_id.prefix()),
540 raw_id_(scoped_id.raw_id()),
541 id_flags_(scoped_id.id_flags()) {}
522 542
523 unsigned long long raw_id() const { return raw_id_; } 543 unsigned long long raw_id() const { return raw_id_; }
524 const char* scope() const { return scope_; } 544 const char* scope() const { return scope_; }
545 bool has_prefix() const { return has_prefix_; }
546 unsigned long long prefix() const { return prefix_; }
525 unsigned int id_flags() const { return id_flags_; } 547 unsigned int id_flags() const { return id_flags_; }
526 548
527 std::unique_ptr<base::trace_event::ConvertableToTraceFormat> 549 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
528 AsConvertableToTraceFormat() const; 550 AsConvertableToTraceFormat() const;
529 551
530 private: 552 private:
531 const char* scope_ = nullptr; 553 const char* scope_ = nullptr;
554 bool has_prefix_ = false;
555 unsigned long long prefix_;
532 unsigned long long raw_id_; 556 unsigned long long raw_id_;
533 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID; 557 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID;
534 }; 558 };
535 559
536 // Simple union to store various types as unsigned long long. 560 // Simple union to store various types as unsigned long long.
537 union TraceValueUnion { 561 union TraceValueUnion {
538 bool as_bool; 562 bool as_bool;
539 unsigned long long as_uint; 563 unsigned long long as_uint;
540 long long as_int; 564 long long as_int;
541 double as_double; 565 double as_double;
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 const char* name_; 1097 const char* name_;
1074 IDType id_; 1098 IDType id_;
1075 1099
1076 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1100 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1077 }; 1101 };
1078 1102
1079 } // namespace trace_event 1103 } // namespace trace_event
1080 } // namespace base 1104 } // namespace base
1081 1105
1082 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1106 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « no previous file | base/trace_event/trace_event_impl.cc » ('j') | base/trace_event/trace_event_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698