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 file defines the set of trace_event macros without specifying | 5 // This header file defines the set of 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 // events to some other universe, you can copy-and-paste this file as well as | 7 // events to some other universe, you can copy-and-paste this file as well as |
8 // trace_event.h, modifying the macros contained there as necessary for the | 8 // trace_event.h, modifying the macros contained there as necessary for the |
9 // target platform. The end result is that multiple libraries can funnel events | 9 // target platform. The end result is that multiple libraries can funnel events |
10 // through to a shared trace event collector. | 10 // through to a shared trace event collector. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 // Converting a large data type to a string can be costly. To help with this, | 137 // Converting a large data type to a string can be costly. To help with this, |
138 // the trace framework provides an interface ConvertableToTraceFormat. If you | 138 // the trace framework provides an interface ConvertableToTraceFormat. If you |
139 // inherit from it and implement the AppendAsTraceFormat method the trace | 139 // inherit from it and implement the AppendAsTraceFormat method the trace |
140 // framework will call back to your object to convert a trace output time. This | 140 // framework will call back to your object to convert a trace output time. This |
141 // means, if the category for the event is disabled, the conversion will not | 141 // means, if the category for the event is disabled, the conversion will not |
142 // happen. | 142 // happen. |
143 // | 143 // |
144 // class MyData : public base::trace_event::ConvertableToTraceFormat { | 144 // class MyData : public base::trace_event::ConvertableToTraceFormat { |
145 // public: | 145 // public: |
146 // MyData() {} | 146 // MyData() {} |
147 // virtual void AppendAsTraceFormat(std::string* out) const override { | 147 // void AppendAsTraceFormat(std::string* out) const override { |
148 // out->append("{\"foo\":1}"); | 148 // out->append("{\"foo\":1}"); |
149 // } | 149 // } |
150 // private: | 150 // private: |
151 // virtual ~MyData() {} | 151 // ~MyData() override {} |
152 // DISALLOW_COPY_AND_ASSIGN(MyData); | 152 // DISALLOW_COPY_AND_ASSIGN(MyData); |
153 // }; | 153 // }; |
154 // | 154 // |
155 // TRACE_EVENT1("foo", "bar", "data", | 155 // TRACE_EVENT1("foo", "bar", "data", |
156 // scoped_refptr<ConvertableToTraceFormat>(new MyData())); | 156 // scoped_refptr<ConvertableToTraceFormat>(new MyData())); |
157 // | 157 // |
158 // The trace framework will take ownership if the passed pointer and it will | 158 // The trace framework will take ownership if the passed pointer and it will |
159 // be free'd when the trace buffer is flushed. | 159 // be free'd when the trace buffer is flushed. |
160 // | 160 // |
161 // Note, we only do the conversion when the buffer is flushed, so the provided | 161 // Note, we only do the conversion when the buffer is flushed, so the provided |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
594 arg1_name, arg1_val, arg2_name, arg2_val) | 594 arg1_name, arg1_val, arg2_name, arg2_val) |
595 | 595 |
596 // Similar to TRACE_EVENT_ASYNC_BEGINx but with a custom |at| timestamp | 596 // Similar to TRACE_EVENT_ASYNC_BEGINx but with a custom |at| timestamp |
597 // provided. | 597 // provided. |
598 #define TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, \ | 598 #define TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, \ |
599 name, id, timestamp) \ | 599 name, id, timestamp) \ |
600 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ | 600 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
601 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \ | 601 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \ |
602 static_cast<int>(base::PlatformThread::CurrentId()), \ | 602 static_cast<int>(base::PlatformThread::CurrentId()), \ |
603 timestamp, TRACE_EVENT_FLAG_NONE) | 603 timestamp, TRACE_EVENT_FLAG_NONE) |
| 604 #define TRACE_EVENT_COPY_ASYNC_BEGIN_WITH_TIMESTAMP0(category_group, \ |
| 605 name, id, timestamp) \ |
| 606 INTERNAL_TRACE_EVENT_ADD_WITH_ID_TID_AND_TIMESTAMP( \ |
| 607 TRACE_EVENT_PHASE_ASYNC_BEGIN, category_group, name, id, \ |
| 608 static_cast<int>(base::PlatformThread::CurrentId()), \ |
| 609 timestamp, TRACE_EVENT_FLAG_COPY) |
604 | 610 |
605 // Records a single ASYNC_STEP_INTO event for |step| immediately. If the | 611 // Records a single ASYNC_STEP_INTO event for |step| immediately. If the |
606 // category is not enabled, then this does nothing. The |name| and |id| must | 612 // category is not enabled, then this does nothing. The |name| and |id| must |
607 // match the ASYNC_BEGIN event above. The |step| param identifies this step | 613 // match the ASYNC_BEGIN event above. The |step| param identifies this step |
608 // within the async event. This should be called at the beginning of the next | 614 // within the async event. This should be called at the beginning of the next |
609 // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any | 615 // phase of an asynchronous operation. The ASYNC_BEGIN event must not have any |
610 // ASYNC_STEP_PAST events. | 616 // ASYNC_STEP_PAST events. |
611 #define TRACE_EVENT_ASYNC_STEP_INTO0(category_group, name, id, step) \ | 617 #define TRACE_EVENT_ASYNC_STEP_INTO0(category_group, name, id, step) \ |
612 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \ | 618 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_ASYNC_STEP_INTO, \ |
613 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) | 619 category_group, name, id, TRACE_EVENT_FLAG_NONE, "step", step) |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
821 #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, snapshot)
\ | 827 #define TRACE_EVENT_OBJECT_SNAPSHOT_WITH_ID(category_group, name, id, snapshot)
\ |
822 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \ | 828 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_SNAPSHOT_OBJECT, \ |
823 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\ | 829 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE,\ |
824 "snapshot", snapshot) | 830 "snapshot", snapshot) |
825 | 831 |
826 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ | 832 #define TRACE_EVENT_OBJECT_DELETED_WITH_ID(category_group, name, id) \ |
827 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ | 833 INTERNAL_TRACE_EVENT_ADD_WITH_ID(TRACE_EVENT_PHASE_DELETE_OBJECT, \ |
828 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) | 834 category_group, name, TRACE_ID_DONT_MANGLE(id), TRACE_EVENT_FLAG_NONE) |
829 | 835 |
830 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ | 836 #define INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE() \ |
831 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ | 837 UNLIKELY(*INTERNAL_TRACE_EVENT_UID(category_group_enabled) & \ |
832 (base::trace_event::TraceLog::ENABLED_FOR_RECORDING | \ | 838 (base::trace_event::TraceLog::ENABLED_FOR_RECORDING | \ |
833 base::trace_event::TraceLog::ENABLED_FOR_EVENT_CALLBACK)) | 839 base::trace_event::TraceLog::ENABLED_FOR_EVENT_CALLBACK | \ |
| 840 base::trace_event::TraceLog::ENABLED_FOR_ETW_EXPORT)) |
834 | 841 |
835 // Macro to efficiently determine if a given category group is enabled. | 842 // Macro to efficiently determine if a given category group is enabled. |
836 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ | 843 #define TRACE_EVENT_CATEGORY_GROUP_ENABLED(category_group, ret) \ |
837 do { \ | 844 do { \ |
838 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ | 845 INTERNAL_TRACE_EVENT_GET_CATEGORY_INFO(category_group); \ |
839 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ | 846 if (INTERNAL_TRACE_EVENT_CATEGORY_GROUP_ENABLED_FOR_RECORDING_MODE()) { \ |
840 *ret = true; \ | 847 *ret = true; \ |
841 } else { \ | 848 } else { \ |
842 *ret = false; \ | 849 *ret = false; \ |
843 } \ | 850 } \ |
(...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1626 const char* name_; | 1633 const char* name_; |
1627 IDType id_; | 1634 IDType id_; |
1628 | 1635 |
1629 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1636 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
1630 }; | 1637 }; |
1631 | 1638 |
1632 } // namespace trace_event | 1639 } // namespace trace_event |
1633 } // namespace base | 1640 } // namespace base |
1634 | 1641 |
1635 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ | 1642 #endif // BASE_TRACE_EVENT_TRACE_EVENT_H_ |
OLD | NEW |