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

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

Issue 2381083003: The TRACE_LINK_IDS macro (Closed)
Patch Set: TracedValue -> CTTF Created 4 years, 2 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
« no previous file with comments | « base/trace_event/common/trace_event_common.h ('k') | base/trace_event/trace_event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 trace_event_trace_id.id_flags(); \ 369 trace_event_trace_id.id_flags(); \
370 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ 370 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \
371 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ 371 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \
372 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ 372 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \
373 thread_id, timestamp, \ 373 thread_id, timestamp, \
374 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ 374 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \
375 trace_event_internal::kNoId, ##__VA_ARGS__); \ 375 trace_event_internal::kNoId, ##__VA_ARGS__); \
376 } \ 376 } \
377 } while (0) 377 } while (0)
378 378
379 // This macro ignores whether the bind_id is local, global, or mangled. 379 // The linked ID will not be mangled.
380 #define INTERNAL_TRACE_EVENT_ADD_BIND_IDS(category_group, name, id, bind_id, \ 380 #define INTERNAL_TRACE_EVENT_ADD_LINK_IDS(category_group, name, id1, id2) \
381 ...) \
382 do { \ 381 do { \
383 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 382 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
384 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 383 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
385 trace_event_internal::TraceID source_id((id)); \ 384 trace_event_internal::TraceID source_id((id1)); \
386 unsigned int source_flags = source_id.id_flags(); \ 385 unsigned int source_flags = source_id.id_flags(); \
387 trace_event_internal::TraceID target_id((bind_id)); \ 386 trace_event_internal::TraceID target_id((id2)); \
388 if (target_id.scope() == trace_event_internal::kGlobalScope) { \ 387 trace_event_internal::AddTraceEvent( \
389 trace_event_internal::AddTraceEvent( \ 388 TRACE_EVENT_PHASE_LINK_IDS, \
390 TRACE_EVENT_PHASE_BIND_IDS, \ 389 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
391 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ 390 name, source_id.scope(), source_id.raw_id(), source_flags, \
392 name, source_id.scope(), source_id.raw_id(), \ 391 trace_event_internal::kNoId, \
393 source_flags, target_id.raw_id(), ##__VA_ARGS__); \ 392 "linked_id", target_id.dict_value()); \
394 } else { \
395 trace_event_internal::AddTraceEvent( \
396 TRACE_EVENT_PHASE_BIND_IDS, \
397 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \
398 name, source_id.scope(), source_id.raw_id(), \
399 source_flags, target_id.raw_id(), \
400 "bind_scope", target_id.scope(), ##__VA_ARGS__); \
401 } \
402 } \ 393 } \
403 } while (0) 394 } while (0)
404 395
405 // Implementation detail: internal macro to create static category and add 396 // Implementation detail: internal macro to create static category and add
406 // metadata event if the category is enabled. 397 // metadata event if the category is enabled.
407 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ 398 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \
408 do { \ 399 do { \
409 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ 400 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \
410 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ 401 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \
411 TRACE_EVENT_API_ADD_METADATA_EVENT( \ 402 TRACE_EVENT_API_ADD_METADATA_EVENT( \
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 TraceID(GlobalId raw_id) : raw_id_(raw_id.raw_id()) { 566 TraceID(GlobalId raw_id) : raw_id_(raw_id.raw_id()) {
576 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID; 567 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID;
577 } 568 }
578 TraceID(WithScope scoped_id) : scope_(scoped_id.scope()), 569 TraceID(WithScope scoped_id) : scope_(scoped_id.scope()),
579 raw_id_(scoped_id.raw_id()), id_flags_(scoped_id.id_flags()) {} 570 raw_id_(scoped_id.raw_id()), id_flags_(scoped_id.id_flags()) {}
580 571
581 unsigned long long raw_id() const { return raw_id_; } 572 unsigned long long raw_id() const { return raw_id_; }
582 const char* scope() const { return scope_; } 573 const char* scope() const { return scope_; }
583 unsigned int id_flags() const { return id_flags_; } 574 unsigned int id_flags() const { return id_flags_; }
584 575
576 std::unique_ptr<base::trace_event::ConvertableToTraceFormat>
577 dict_value() const;
Primiano Tucci (use gerrit) 2016/10/06 16:28:27 lowe_case is only for inline methods. s/dict_value
chiniforooshan 2016/10/06 20:20:03 Done.
578
585 private: 579 private:
586 const char* scope_ = nullptr; 580 const char* scope_ = nullptr;
587 unsigned long long raw_id_; 581 unsigned long long raw_id_;
588 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID; 582 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID;
589 }; 583 };
590 584
591 // Simple union to store various types as unsigned long long. 585 // Simple union to store various types as unsigned long long.
592 union TraceValueUnion { 586 union TraceValueUnion {
593 bool as_bool; 587 bool as_bool;
594 unsigned long long as_uint; 588 unsigned long long as_uint;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 1123
1130 private: 1124 private:
1131 const char* previous_state_; 1125 const char* previous_state_;
1132 }; 1126 };
1133 1127
1134 } // namespace trace_event_internal 1128 } // namespace trace_event_internal
1135 1129
1136 namespace base { 1130 namespace base {
1137 namespace trace_event { 1131 namespace trace_event {
1138 1132
1133 class ConvertableToTraceFormat;
Primiano Tucci (use gerrit) 2016/10/06 16:28:26 shouldn't this fwd declaration be *before* you use
chiniforooshan 2016/10/06 20:20:03 Done.
1134
1139 template<typename IDType> class TraceScopedTrackableObject { 1135 template<typename IDType> class TraceScopedTrackableObject {
1140 public: 1136 public:
1141 TraceScopedTrackableObject(const char* category_group, const char* name, 1137 TraceScopedTrackableObject(const char* category_group, const char* name,
1142 IDType id) 1138 IDType id)
1143 : category_group_(category_group), 1139 : category_group_(category_group),
1144 name_(name), 1140 name_(name),
1145 id_(id) { 1141 id_(id) {
1146 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_); 1142 TRACE_EVENT_OBJECT_CREATED_WITH_ID(category_group_, name_, id_);
1147 } 1143 }
1148 1144
(...skipping 10 matching lines...) Expand all
1159 const char* name_; 1155 const char* name_;
1160 IDType id_; 1156 IDType id_;
1161 1157
1162 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); 1158 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject);
1163 }; 1159 };
1164 1160
1165 } // namespace trace_event 1161 } // namespace trace_event
1166 } // namespace base 1162 } // namespace base
1167 1163
1168 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ 1164 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_
OLDNEW
« no previous file with comments | « base/trace_event/common/trace_event_common.h ('k') | base/trace_event/trace_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698