Chromium Code Reviews| 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" | |
|
Primiano Tucci (use gerrit)
2016/10/01 01:50:00
remember to remove the unnecessary .h once you mov
chiniforooshan
2016/10/03 18:12:19
Done.
| |
| 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" | |
|
Primiano Tucci (use gerrit)
2016/10/01 01:50:00
Yeah please don't pull extra includes in this file
chiniforooshan
2016/10/03 18:12:19
Done.
| |
| 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 // DEPRECATED: do not use: Consider using TRACE_ID_{GLOBAL, LOCAL} macros, | 34 // DEPRECATED: do not use: Consider using TRACE_ID_{GLOBAL, LOCAL} macros, |
| (...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 trace_event_trace_id.id_flags(); \ | 372 trace_event_trace_id.id_flags(); \ |
| 370 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ | 373 trace_event_internal::AddTraceEventWithThreadIdAndTimestamp( \ |
| 371 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ | 374 phase, INTERNAL_TRACE_EVENT_UID(category_group_enabled), name, \ |
| 372 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ | 375 trace_event_trace_id.scope(), trace_event_trace_id.raw_id(), \ |
| 373 thread_id, timestamp, \ | 376 thread_id, timestamp, \ |
| 374 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ | 377 trace_event_flags | TRACE_EVENT_FLAG_EXPLICIT_TIMESTAMP, \ |
| 375 trace_event_internal::kNoId, ##__VA_ARGS__); \ | 378 trace_event_internal::kNoId, ##__VA_ARGS__); \ |
| 376 } \ | 379 } \ |
| 377 } while (0) | 380 } while (0) |
| 378 | 381 |
| 379 // This macro ignores whether the bind_id is local, global, or mangled. | 382 // The linked ID will not be mangled. |
| 380 #define INTERNAL_TRACE_EVENT_ADD_BIND_IDS(category_group, name, id, bind_id, \ | 383 #define INTERNAL_TRACE_EVENT_ADD_LINK_IDS(category_group, name, id1, id2) \ |
| 381 ...) \ | |
| 382 do { \ | 384 do { \ |
| 383 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 385 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| 384 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 386 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| 385 trace_event_internal::TraceID source_id((id)); \ | 387 trace_event_internal::TraceID source_id((id1)); \ |
| 386 unsigned int source_flags = source_id.id_flags(); \ | 388 unsigned int source_flags = source_id.id_flags(); \ |
| 387 trace_event_internal::TraceID target_id((bind_id)); \ | 389 trace_event_internal::TraceID target_id((id2)); \ |
| 388 if (target_id.scope() == trace_event_internal::kGlobalScope) { \ | 390 trace_event_internal::AddTraceEvent( \ |
| 389 trace_event_internal::AddTraceEvent( \ | 391 TRACE_EVENT_PHASE_LINK_IDS, \ |
| 390 TRACE_EVENT_PHASE_BIND_IDS, \ | 392 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ |
| 391 INTERNAL_TRACE_EVENT_UID(category_group_enabled), \ | 393 name, source_id.scope(), source_id.raw_id(), source_flags, \ |
| 392 name, source_id.scope(), source_id.raw_id(), \ | 394 trace_event_internal::kNoId, \ |
| 393 source_flags, target_id.raw_id(), ##__VA_ARGS__); \ | 395 "linked_id", target_id.dict_value()); \ |
|
Primiano Tucci (use gerrit)
2016/10/01 01:50:00
don't you need a std::move here?
chiniforooshan
2016/10/03 18:12:19
It's a return value. If I actually do std::move he
| |
| 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 } \ | 396 } \ |
| 403 } while (0) | 397 } while (0) |
| 404 | 398 |
| 405 // Implementation detail: internal macro to create static category and add | 399 // Implementation detail: internal macro to create static category and add |
| 406 // metadata event if the category is enabled. | 400 // metadata event if the category is enabled. |
| 407 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ | 401 #define INTERNAL_TRACE_EVENT_METADATA_ADD(category_group, name, ...) \ |
| 408 do { \ | 402 do { \ |
| 409 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 403 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
| 410 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 404 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
| 411 TRACE_EVENT_API_ADD_METADATA_EVENT( \ | 405 TRACE_EVENT_API_ADD_METADATA_EVENT( \ |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 TraceID(GlobalId raw_id) : raw_id_(raw_id.raw_id()) { | 569 TraceID(GlobalId raw_id) : raw_id_(raw_id.raw_id()) { |
| 576 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID; | 570 id_flags_ = TRACE_EVENT_FLAG_HAS_GLOBAL_ID; |
| 577 } | 571 } |
| 578 TraceID(WithScope scoped_id) : scope_(scoped_id.scope()), | 572 TraceID(WithScope scoped_id) : scope_(scoped_id.scope()), |
| 579 raw_id_(scoped_id.raw_id()), id_flags_(scoped_id.id_flags()) {} | 573 raw_id_(scoped_id.raw_id()), id_flags_(scoped_id.id_flags()) {} |
| 580 | 574 |
| 581 unsigned long long raw_id() const { return raw_id_; } | 575 unsigned long long raw_id() const { return raw_id_; } |
| 582 const char* scope() const { return scope_; } | 576 const char* scope() const { return scope_; } |
| 583 unsigned int id_flags() const { return id_flags_; } | 577 unsigned int id_flags() const { return id_flags_; } |
| 584 | 578 |
| 579 std::unique_ptr<base::trace_event::TracedValue> dict_value() const { | |
|
caseq
2016/10/01 01:33:53
Let's move it out-of-line, it's too big.
Primiano Tucci (use gerrit)
2016/10/01 01:50:00
+1 this is definitely beyon the limits for an inli
chiniforooshan
2016/10/03 18:12:19
Done.
| |
| 580 std::unique_ptr<base::trace_event::TracedValue> value( | |
| 581 new base::trace_event::TracedValue()); | |
|
Primiano Tucci (use gerrit)
2016/10/01 01:50:00
makeunique
chiniforooshan
2016/10/03 18:12:19
Done.
| |
| 582 | |
| 583 if (scope_ != kGlobalScope) | |
| 584 value->SetString("scope", scope_); | |
| 585 switch (id_flags_) { | |
| 586 case TRACE_EVENT_FLAG_HAS_ID: | |
| 587 value->SetString( | |
| 588 "id", | |
| 589 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); | |
| 590 break; | |
| 591 case TRACE_EVENT_FLAG_HAS_GLOBAL_ID: | |
| 592 value->BeginDictionary("id2"); | |
| 593 value->SetString( | |
| 594 "global", | |
| 595 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); | |
| 596 value->EndDictionary(); | |
| 597 break; | |
| 598 case TRACE_EVENT_FLAG_HAS_LOCAL_ID: | |
| 599 value->BeginDictionary("id2"); | |
| 600 value->SetString( | |
| 601 "local", | |
| 602 base::StringPrintf("0x%" PRIx64, static_cast<uint64_t>(raw_id_))); | |
| 603 value->EndDictionary(); | |
| 604 break; | |
| 605 default: | |
| 606 NOTREACHED() << "Unrecognized ID flag"; | |
| 607 } | |
| 608 | |
| 609 return value; | |
| 610 } | |
| 611 | |
| 585 private: | 612 private: |
| 586 const char* scope_ = nullptr; | 613 const char* scope_ = nullptr; |
| 587 unsigned long long raw_id_; | 614 unsigned long long raw_id_; |
| 588 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID; | 615 unsigned int id_flags_ = TRACE_EVENT_FLAG_HAS_ID; |
| 589 }; | 616 }; |
| 590 | 617 |
| 591 // Simple union to store various types as unsigned long long. | 618 // Simple union to store various types as unsigned long long. |
| 592 union TraceValueUnion { | 619 union TraceValueUnion { |
| 593 bool as_bool; | 620 bool as_bool; |
| 594 unsigned long long as_uint; | 621 unsigned long long as_uint; |
| (...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1159 const char* name_; | 1186 const char* name_; |
| 1160 IDType id_; | 1187 IDType id_; |
| 1161 | 1188 |
| 1162 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1189 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 1163 }; | 1190 }; |
| 1164 | 1191 |
| 1165 } // namespace trace_event | 1192 } // namespace trace_event |
| 1166 } // namespace base | 1193 } // namespace base |
| 1167 | 1194 |
| 1168 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 1195 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
| OLD | NEW |