OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 // because addTraceEvent is threadsafe internally and checks the enabled state | 156 // because addTraceEvent is threadsafe internally and checks the enabled state |
157 // again under lock. | 157 // again under lock. |
158 // | 158 // |
159 // Without the use of these static category pointers and enabled flags all | 159 // Without the use of these static category pointers and enabled flags all |
160 // trace points would carry a significant performance cost of aquiring a lock | 160 // trace points would carry a significant performance cost of aquiring a lock |
161 // and resolving the category. | 161 // and resolving the category. |
162 | 162 |
163 #ifndef TraceEvent_h | 163 #ifndef TraceEvent_h |
164 #define TraceEvent_h | 164 #define TraceEvent_h |
165 | 165 |
166 #include "platform/EventTracer.h" | 166 #include "platform/EventTracer.h" |
haraken
2014/03/21 17:10:18
Unfortunately this CL doesn't work because of this
| |
167 | |
168 #include "wtf/DynamicAnnotations.h" | 167 #include "wtf/DynamicAnnotations.h" |
169 #include "wtf/text/CString.h" | 168 #include "wtf/text/CString.h" |
170 | 169 |
171 // By default, const char* argument values are assumed to have long-lived scope | 170 // By default, const char* argument values are assumed to have long-lived scope |
172 // and will not be copied. Use this macro to force a const char* to be copied. | 171 // and will not be copied. Use this macro to force a const char* to be copied. |
173 #define TRACE_STR_COPY(str) \ | 172 #define TRACE_STR_COPY(str) \ |
174 WebCore::TraceEvent::TraceStringWithCopy(str) | 173 WebCore::TraceEvent::TraceStringWithCopy(str) |
175 | 174 |
176 // By default, uint64 ID argument values are not mangled with the Process ID in | 175 // By default, uint64 ID argument values are not mangled with the Process ID in |
177 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. | 176 // TRACE_EVENT_ASYNC macros. Use this macro to force Process ID mangling. |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
562 INTERNAL_TRACE_EVENT_UID3(a, b) | 561 INTERNAL_TRACE_EVENT_UID3(a, b) |
563 #define INTERNALTRACEEVENTUID(name_prefix) \ | 562 #define INTERNALTRACEEVENTUID(name_prefix) \ |
564 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) | 563 INTERNAL_TRACE_EVENT_UID2(name_prefix, __LINE__) |
565 | 564 |
566 // Implementation detail: internal macro to create static category. | 565 // Implementation detail: internal macro to create static category. |
567 // - WTF_ANNOTATE_BENIGN_RACE, see Thread Safety above. | 566 // - WTF_ANNOTATE_BENIGN_RACE, see Thread Safety above. |
568 | 567 |
569 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ | 568 #define INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category) \ |
570 static const unsigned char* INTERNALTRACEEVENTUID(categoryGroupEnabled) = 0; \ | 569 static const unsigned char* INTERNALTRACEEVENTUID(categoryGroupEnabled) = 0; \ |
571 WTF_ANNOTATE_BENIGN_RACE(&INTERNALTRACEEVENTUID(categoryGroupEnabled), \ | 570 WTF_ANNOTATE_BENIGN_RACE(&INTERNALTRACEEVENTUID(categoryGroupEnabled), \ |
572 "trace_event category"); \ | 571 "trace_event category"); \ |
573 if (!INTERNALTRACEEVENTUID(categoryGroupEnabled)) { \ | 572 if (!INTERNALTRACEEVENTUID(categoryGroupEnabled)) { \ |
574 INTERNALTRACEEVENTUID(categoryGroupEnabled) = \ | 573 INTERNALTRACEEVENTUID(categoryGroupEnabled) = \ |
575 TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); \ | 574 TRACE_EVENT_API_GET_CATEGORY_ENABLED(category); \ |
576 } | 575 } |
577 | 576 |
578 // Implementation detail: internal macro to create static category and add | 577 // Implementation detail: internal macro to create static category and add |
579 // event if the category is enabled. | 578 // event if the category is enabled. |
580 #define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \ | 579 #define INTERNAL_TRACE_EVENT_ADD(phase, category, name, flags, ...) \ |
581 do { \ | 580 do { \ |
582 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 581 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
(...skipping 16 matching lines...) Expand all Loading... | |
599 TRACE_EVENT_PHASE_COMPLETE, \ | 598 TRACE_EVENT_PHASE_COMPLETE, \ |
600 INTERNALTRACEEVENTUID(categoryGroupEnabled), \ | 599 INTERNALTRACEEVENTUID(categoryGroupEnabled), \ |
601 name, WebCore::TraceEvent::noEventId, \ | 600 name, WebCore::TraceEvent::noEventId, \ |
602 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ | 601 TRACE_EVENT_FLAG_NONE, ##__VA_ARGS__); \ |
603 INTERNALTRACEEVENTUID(scopedTracer).initialize( \ | 602 INTERNALTRACEEVENTUID(scopedTracer).initialize( \ |
604 INTERNALTRACEEVENTUID(categoryGroupEnabled), name, h); \ | 603 INTERNALTRACEEVENTUID(categoryGroupEnabled), name, h); \ |
605 } | 604 } |
606 | 605 |
607 // Implementation detail: internal macro to create static category and add | 606 // Implementation detail: internal macro to create static category and add |
608 // event if the category is enabled. | 607 // event if the category is enabled. |
609 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, \ | 608 #define INTERNAL_TRACE_EVENT_ADD_WITH_ID(phase, category, name, id, flags, ...) \ |
610 ...) \ | |
611 do { \ | 609 do { \ |
612 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ | 610 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category); \ |
613 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 611 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
614 unsigned char traceEventFlags = flags | TRACE_EVENT_FLAG_HAS_ID; \ | 612 unsigned char traceEventFlags = flags | TRACE_EVENT_FLAG_HAS_ID; \ |
615 WebCore::TraceEvent::TraceID traceEventTraceID( \ | 613 WebCore::TraceEvent::TraceID traceEventTraceID( \ |
616 id, &traceEventFlags); \ | 614 id, &traceEventFlags); \ |
617 WebCore::TraceEvent::addTraceEvent( \ | 615 WebCore::TraceEvent::addTraceEvent( \ |
618 phase, INTERNALTRACEEVENTUID(categoryGroupEnabled), \ | 616 phase, INTERNALTRACEEVENTUID(categoryGroupEnabled), \ |
619 name, traceEventTraceID.data(), traceEventFlags, \ | 617 name, traceEventTraceID.data(), traceEventFlags, ##__VA_ARGS__); \ |
620 ##__VA_ARGS__); \ | |
621 } \ | 618 } \ |
622 } while (0) | 619 } while (0) |
623 | 620 |
624 // Notes regarding the following definitions: | 621 // Notes regarding the following definitions: |
625 // New values can be added and propagated to third party libraries, but existing | 622 // New values can be added and propagated to third party libraries, but existing |
626 // definitions must never be changed, because third party libraries may use old | 623 // definitions must never be changed, because third party libraries may use old |
627 // definitions. | 624 // definitions. |
628 | 625 |
629 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. | 626 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
630 #define TRACE_EVENT_PHASE_BEGIN ('B') | 627 #define TRACE_EVENT_PHASE_BEGIN ('B') |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
736 public: | 733 public: |
737 explicit TraceStringWithCopy(const char* str) : m_str(str) { } | 734 explicit TraceStringWithCopy(const char* str) : m_str(str) { } |
738 operator const char* () const { return m_str; } | 735 operator const char* () const { return m_str; } |
739 private: | 736 private: |
740 const char* m_str; | 737 const char* m_str; |
741 }; | 738 }; |
742 | 739 |
743 // Define setTraceValue for each allowed type. It stores the type and | 740 // Define setTraceValue for each allowed type. It stores the type and |
744 // value in the return arguments. This allows this API to avoid declaring any | 741 // value in the return arguments. This allows this API to avoid declaring any |
745 // structures so that it is portable to third_party libraries. | 742 // structures so that it is portable to third_party libraries. |
746 #define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, \ | 743 #define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, union_member, value_type_i d) \ |
747 union_member, \ | 744 static inline void setTraceValue(actual_type arg, unsigned char* type, unsig ned long long* value) { \ |
748 value_type_id) \ | |
749 static inline void setTraceValue(actual_type arg, \ | |
750 unsigned char* type, \ | |
751 unsigned long long* value) { \ | |
752 TraceValueUnion typeValue; \ | 745 TraceValueUnion typeValue; \ |
753 typeValue.union_member = arg; \ | 746 typeValue.union_member = arg; \ |
754 *type = value_type_id; \ | 747 *type = value_type_id; \ |
755 *value = typeValue.m_uint; \ | 748 *value = typeValue.m_uint; \ |
756 } | 749 } |
757 // Simpler form for int types that can be safely casted. | 750 // Simpler form for int types that can be safely casted. |
758 #define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, \ | 751 #define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, value_type_id) \ |
759 value_type_id) \ | 752 static inline void setTraceValue(actual_type arg, unsigned char* type, unsig ned long long* value) { \ |
760 static inline void setTraceValue(actual_type arg, \ | |
761 unsigned char* type, \ | |
762 unsigned long long* value) { \ | |
763 *type = value_type_id; \ | 753 *type = value_type_id; \ |
764 *value = static_cast<unsigned long long>(arg); \ | 754 *value = static_cast<unsigned long long>(arg); \ |
765 } | 755 } |
766 | 756 |
767 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT) | 757 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT) |
768 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT) | 758 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned, TRACE_VALUE_TYPE_UINT) |
769 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT) | 759 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT) |
770 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT) | 760 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT) |
771 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT) | 761 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT) |
772 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT) | 762 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT) |
773 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT) | 763 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT) |
774 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT) | 764 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT) |
775 INTERNAL_DECLARE_SET_TRACE_VALUE(bool, m_bool, TRACE_VALUE_TYPE_BOOL) | 765 INTERNAL_DECLARE_SET_TRACE_VALUE(bool, m_bool, TRACE_VALUE_TYPE_BOOL) |
776 INTERNAL_DECLARE_SET_TRACE_VALUE(double, m_double, TRACE_VALUE_TYPE_DOUBLE) | 766 INTERNAL_DECLARE_SET_TRACE_VALUE(double, m_double, TRACE_VALUE_TYPE_DOUBLE) |
777 INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, m_pointer, | 767 INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, m_pointer, TRACE_VALUE_TYPE_POINTE R) |
778 TRACE_VALUE_TYPE_POINTER) | 768 INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, m_string, TRACE_VALUE_TYPE_STRING) |
779 INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, m_string, | 769 INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, m_string, TRACE_VAL UE_TYPE_COPY_STRING) |
780 TRACE_VALUE_TYPE_STRING) | |
781 INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, m_string, | |
782 TRACE_VALUE_TYPE_COPY_STRING) | |
783 | 770 |
784 #undef INTERNAL_DECLARE_SET_TRACE_VALUE | 771 #undef INTERNAL_DECLARE_SET_TRACE_VALUE |
785 #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT | 772 #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT |
786 | 773 |
787 // WTF::String version of setTraceValue so that trace arguments can be strings. | 774 // WTF::String version of setTraceValue so that trace arguments can be strings. |
788 static inline void setTraceValue(const WTF::CString& arg, unsigned char* type, u nsigned long long* value) | 775 static inline void setTraceValue(const WTF::CString& arg, unsigned char* type, u nsigned long long* value) |
789 { | 776 { |
790 TraceValueUnion typeValue; | 777 TraceValueUnion typeValue; |
791 typeValue.m_string = arg.data(); | 778 typeValue.m_string = arg.data(); |
792 *type = TRACE_VALUE_TYPE_COPY_STRING; | 779 *type = TRACE_VALUE_TYPE_COPY_STRING; |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
939 const char* m_categoryGroup; | 926 const char* m_categoryGroup; |
940 const char* m_name; | 927 const char* m_name; |
941 IDType m_id; | 928 IDType m_id; |
942 }; | 929 }; |
943 | 930 |
944 } // namespace TraceEvent | 931 } // namespace TraceEvent |
945 | 932 |
946 } // namespace WebCore | 933 } // namespace WebCore |
947 | 934 |
948 #endif | 935 #endif |
OLD | NEW |