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 // This header is designed to give you trace_event macros without specifying | 5 // This header is designed to give you trace_event macros without specifying |
6 // how the events actually get collected and stored. If you need to expose trace | 6 // how the events actually get collected and stored. If you need to expose trace |
7 // event to some other universe, you can copy-and-paste this file, | 7 // event to some other universe, you can copy-and-paste this file, |
8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for | 8 // implement the TRACE_EVENT_API macros, and do any other necessary fixup for |
9 // the target platform. The end result is that multiple libraries can funnel | 9 // the target platform. The end result is that multiple libraries can funnel |
10 // events through to a shared trace event collector. | 10 // events through to a shared trace event collector. |
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 INTERNAL_TRACE_EVENT_UID(catstatic) = \ | 525 INTERNAL_TRACE_EVENT_UID(catstatic) = \ |
526 TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); \ | 526 TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); \ |
527 base::subtle::NoBarrier_Store(&INTERNAL_TRACE_EVENT_UID(atomic), \ | 527 base::subtle::NoBarrier_Store(&INTERNAL_TRACE_EVENT_UID(atomic), \ |
528 reinterpret_cast<base::subtle::AtomicWord>( \ | 528 reinterpret_cast<base::subtle::AtomicWord>( \ |
529 INTERNAL_TRACE_EVENT_UID(catstatic))); \ | 529 INTERNAL_TRACE_EVENT_UID(catstatic))); \ |
530 } | 530 } |
531 | 531 |
532 // Implementation detail: internal macro to create static category and add | 532 // Implementation detail: internal macro to create static category and add |
533 // event if the category is enabled. | 533 // event if the category is enabled. |
534 #define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \ | 534 #define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \ |
535 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 535 do { \ |
536 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 536 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
537 trace_event_internal::AddTraceEvent( \ | 537 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
538 phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \ | 538 trace_event_internal::AddTraceEvent( \ |
539 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ | 539 phase, INTERNAL_TRACE_EVENT_UID(catstatic), name, \ |
540 } | 540 trace_event_internal::kNoEventId, flags, ##__VA_ARGS__); \ |
| 541 } \ |
| 542 } while (0) |
541 | 543 |
542 // Implementation detail: internal macro to create static category and add begin | 544 // Implementation detail: internal macro to create static category and add begin |
543 // event if the category is enabled. Also adds the end event when the scope | 545 // event if the category is enabled. Also adds the end event when the scope |
544 // ends. | 546 // ends. |
545 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \ | 547 #define INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, ...) \ |
546 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 548 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
547 trace_event_internal::TraceEndOnScopeClose \ | 549 trace_event_internal::TraceEndOnScopeClose \ |
548 INTERNAL_TRACE_EVENT_UID(profileScope); \ | 550 INTERNAL_TRACE_EVENT_UID(profileScope); \ |
549 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 551 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
550 trace_event_internal::AddTraceEvent( \ | 552 trace_event_internal::AddTraceEvent( \ |
(...skipping 22 matching lines...) Expand all Loading... |
573 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ | 575 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ |
574 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ | 576 INTERNAL_TRACE_EVENT_UID(profileScope).Initialize( \ |
575 INTERNAL_TRACE_EVENT_UID(catstatic), name, \ | 577 INTERNAL_TRACE_EVENT_UID(catstatic), name, \ |
576 INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \ | 578 INTERNAL_TRACE_EVENT_UID(begin_event_id), threshold); \ |
577 } | 579 } |
578 | 580 |
579 // Implementation detail: internal macro to create static category and add | 581 // Implementation detail: internal macro to create static category and add |
580 // event if the category is enabled. | 582 // event if the category is enabled. |
581 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \ | 583 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \ |
582 ...) \ | 584 ...) \ |
583 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 585 do { \ |
584 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ | 586 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
585 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 587 if (*INTERNAL_TRACE_EVENT_UID(catstatic)) { \ |
586 trace_event_internal::TraceID trace_event_trace_id( \ | 588 unsigned char trace_event_flags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
587 id, &trace_event_flags); \ | 589 trace_event_internal::TraceID trace_event_trace_id( \ |
588 trace_event_internal::AddTraceEvent( \ | 590 id, &trace_event_flags); \ |
589 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ | 591 trace_event_internal::AddTraceEvent( \ |
590 name, trace_event_trace_id.data(), trace_event_flags, \ | 592 phase, INTERNAL_TRACE_EVENT_UID(catstatic), \ |
591 ##__VA_ARGS__); \ | 593 name, trace_event_trace_id.data(), trace_event_flags, \ |
592 } | 594 ##__VA_ARGS__); \ |
| 595 } \ |
| 596 } while (0) |
593 | 597 |
594 // Notes regarding the following definitions: | 598 // Notes regarding the following definitions: |
595 // New values can be added and propagated to third party libraries, but existing | 599 // New values can be added and propagated to third party libraries, but existing |
596 // definitions must never be changed, because third party libraries may use old | 600 // definitions must never be changed, because third party libraries may use old |
597 // definitions. | 601 // definitions. |
598 | 602 |
599 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. | 603 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
600 #define TRACE_EVENT_PHASE_BEGIN ('B') | 604 #define TRACE_EVENT_PHASE_BEGIN ('B') |
601 #define TRACE_EVENT_PHASE_END ('E') | 605 #define TRACE_EVENT_PHASE_END ('E') |
602 #define TRACE_EVENT_PHASE_INSTANT ('I') | 606 #define TRACE_EVENT_PHASE_INSTANT ('I') |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 const char* name; | 863 const char* name; |
860 int threshold_begin_id; | 864 int threshold_begin_id; |
861 }; | 865 }; |
862 Data* p_data_; | 866 Data* p_data_; |
863 Data data_; | 867 Data data_; |
864 }; | 868 }; |
865 | 869 |
866 } // namespace trace_event_internal | 870 } // namespace trace_event_internal |
867 | 871 |
868 #endif // BASE_DEBUG_TRACE_EVENT_H_ | 872 #endif // BASE_DEBUG_TRACE_EVENT_H_ |
OLD | NEW |