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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 #define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ | 175 #define TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) \ |
176 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \ | 176 INTERNAL_TRACE_EVENT_ADD_SCOPED(category, name, arg1_name, arg1_val, \ |
177 arg2_name, arg2_val) | 177 arg2_name, arg2_val) |
178 | 178 |
179 // Same as TRACE_EVENT except that they are not included in official builds. | 179 // Same as TRACE_EVENT except that they are not included in official builds. |
180 #ifdef OFFICIAL_BUILD | 180 #ifdef OFFICIAL_BUILD |
181 #define UNSHIPPED_TRACE_EVENT0(category, name) (void)0 | 181 #define UNSHIPPED_TRACE_EVENT0(category, name) (void)0 |
182 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) (void)0 | 182 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) (void)0 |
183 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \ | 183 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \ |
184 arg2_name, arg2_val) (void)0 | 184 arg2_name, arg2_val) (void)0 |
185 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name) (void)0 | 185 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name, scope) (void)0 |
186 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ | 186 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, scope, \ |
187 (void)0 | 187 arg1_name, arg1_val) (void)0 |
188 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ | 188 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, scope, \ |
| 189 arg1_name, arg1_val, \ |
189 arg2_name, arg2_val) (void)0 | 190 arg2_name, arg2_val) (void)0 |
190 #else | 191 #else |
191 #define UNSHIPPED_TRACE_EVENT0(category, name) \ | 192 #define UNSHIPPED_TRACE_EVENT0(category, name) \ |
192 TRACE_EVENT0(category, name) | 193 TRACE_EVENT0(category, name) |
193 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) \ | 194 #define UNSHIPPED_TRACE_EVENT1(category, name, arg1_name, arg1_val) \ |
194 TRACE_EVENT1(category, name, arg1_name, arg1_val) | 195 TRACE_EVENT1(category, name, arg1_name, arg1_val) |
195 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \ | 196 #define UNSHIPPED_TRACE_EVENT2(category, name, arg1_name, arg1_val, \ |
196 arg2_name, arg2_val) \ | 197 arg2_name, arg2_val) \ |
197 TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) | 198 TRACE_EVENT2(category, name, arg1_name, arg1_val, arg2_name, arg2_val) |
198 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name) \ | 199 #define UNSHIPPED_TRACE_EVENT_INSTANT0(category, name, scope) \ |
199 TRACE_EVENT_INSTANT0(category, name) | 200 TRACE_EVENT_INSTANT0(category, name, scope) |
200 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ | 201 #define UNSHIPPED_TRACE_EVENT_INSTANT1(category, name, scope, \ |
201 TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) | 202 arg1_name, arg1_val) \ |
202 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ | 203 TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) |
| 204 #define UNSHIPPED_TRACE_EVENT_INSTANT2(category, name, scope, \ |
| 205 arg1_name, arg1_val, \ |
203 arg2_name, arg2_val) \ | 206 arg2_name, arg2_val) \ |
204 TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ | 207 TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \ |
205 arg2_name, arg2_val) | 208 arg2_name, arg2_val) |
206 #endif | 209 #endif |
207 | 210 |
208 // Records a single event called "name" immediately, with 0, 1 or 2 | 211 // Records a single event called "name" immediately, with 0, 1 or 2 |
209 // associated arguments. If the category is not enabled, then this | 212 // associated arguments. If the category is not enabled, then this |
210 // does nothing. | 213 // does nothing. |
211 // - category and name strings must have application lifetime (statics or | 214 // - category and name strings must have application lifetime (statics or |
212 // literals). They may not include " chars. | 215 // literals). They may not include " chars. |
213 #define TRACE_EVENT_INSTANT0(category, name) \ | 216 #define TRACE_EVENT_INSTANT0(category, name, scope) \ |
214 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 217 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
215 category, name, TRACE_EVENT_FLAG_NONE) | 218 category, name, TRACE_EVENT_FLAG_NONE | scope) |
216 #define TRACE_EVENT_INSTANT1(category, name, arg1_name, arg1_val) \ | 219 #define TRACE_EVENT_INSTANT1(category, name, scope, arg1_name, arg1_val) \ |
217 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 220 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
218 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val) | 221 category, name, TRACE_EVENT_FLAG_NONE | scope, \ |
219 #define TRACE_EVENT_INSTANT2(category, name, arg1_name, arg1_val, \ | 222 arg1_name, arg1_val) |
220 arg2_name, arg2_val) \ | 223 #define TRACE_EVENT_INSTANT2(category, name, scope, arg1_name, arg1_val, \ |
| 224 arg2_name, arg2_val) \ |
221 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 225 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
222 category, name, TRACE_EVENT_FLAG_NONE, arg1_name, arg1_val, \ | 226 category, name, TRACE_EVENT_FLAG_NONE | scope, \ |
223 arg2_name, arg2_val) | 227 arg1_name, arg1_val, arg2_name, arg2_val) |
224 #define TRACE_EVENT_COPY_INSTANT0(category, name) \ | 228 #define TRACE_EVENT_COPY_INSTANT0(category, name, scope) \ |
225 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 229 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
226 category, name, TRACE_EVENT_FLAG_COPY) | 230 category, name, TRACE_EVENT_FLAG_COPY | scope) |
227 #define TRACE_EVENT_COPY_INSTANT1(category, name, arg1_name, arg1_val) \ | 231 #define TRACE_EVENT_COPY_INSTANT1(category, name, scope, \ |
| 232 arg1_name, arg1_val) \ |
228 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 233 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
229 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val) | 234 category, name, TRACE_EVENT_FLAG_COPY | scope, arg1_name, arg1_val) |
230 #define TRACE_EVENT_COPY_INSTANT2(category, name, arg1_name, arg1_val, \ | 235 #define TRACE_EVENT_COPY_INSTANT2(category, name, scope, \ |
231 arg2_name, arg2_val) \ | 236 arg1_name, arg1_val, \ |
| 237 arg2_name, arg2_val) \ |
232 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ | 238 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_INSTANT, \ |
233 category, name, TRACE_EVENT_FLAG_COPY, arg1_name, arg1_val, \ | 239 category, name, TRACE_EVENT_FLAG_COPY | scope, \ |
234 arg2_name, arg2_val) | 240 arg1_name, arg1_val, arg2_name, arg2_val) |
235 | 241 |
236 // Sets the current sample state to the given category and name (both must be | 242 // Sets the current sample state to the given category and name (both must be |
237 // constant strings). These states are intended for a sampling profiler. | 243 // constant strings). These states are intended for a sampling profiler. |
238 // Implementation note: we store category and name together because we don't | 244 // Implementation note: we store category and name together because we don't |
239 // want the inconsistency/expense of storing two pointers. | 245 // want the inconsistency/expense of storing two pointers. |
240 // |thread_bucket| is [0..2] and is used to statically isolate samples in one | 246 // |thread_bucket| is [0..2] and is used to statically isolate samples in one |
241 // thread from others. | 247 // thread from others. |
242 #define TRACE_EVENT_SAMPLE_STATE(thread_bucket, category, name) \ | 248 #define TRACE_EVENT_SAMPLE_STATE(thread_bucket, category, name) \ |
243 TRACE_EVENT_API_ATOMIC_STORE( \ | 249 TRACE_EVENT_API_ATOMIC_STORE( \ |
244 TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \ | 250 TRACE_EVENT_API_THREAD_BUCKET(thread_bucket), \ |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
687 } while (0) | 693 } while (0) |
688 | 694 |
689 // Notes regarding the following definitions: | 695 // Notes regarding the following definitions: |
690 // New values can be added and propagated to third party libraries, but existing | 696 // New values can be added and propagated to third party libraries, but existing |
691 // definitions must never be changed, because third party libraries may use old | 697 // definitions must never be changed, because third party libraries may use old |
692 // definitions. | 698 // definitions. |
693 | 699 |
694 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. | 700 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
695 #define TRACE_EVENT_PHASE_BEGIN ('B') | 701 #define TRACE_EVENT_PHASE_BEGIN ('B') |
696 #define TRACE_EVENT_PHASE_END ('E') | 702 #define TRACE_EVENT_PHASE_END ('E') |
697 #define TRACE_EVENT_PHASE_INSTANT ('I') | 703 #define TRACE_EVENT_PHASE_INSTANT ('i') |
698 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') | 704 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') |
699 #define TRACE_EVENT_PHASE_ASYNC_STEP ('T') | 705 #define TRACE_EVENT_PHASE_ASYNC_STEP ('T') |
700 #define TRACE_EVENT_PHASE_ASYNC_END ('F') | 706 #define TRACE_EVENT_PHASE_ASYNC_END ('F') |
701 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') | 707 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') |
702 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') | 708 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') |
703 #define TRACE_EVENT_PHASE_FLOW_END ('f') | 709 #define TRACE_EVENT_PHASE_FLOW_END ('f') |
704 #define TRACE_EVENT_PHASE_METADATA ('M') | 710 #define TRACE_EVENT_PHASE_METADATA ('M') |
705 #define TRACE_EVENT_PHASE_COUNTER ('C') | 711 #define TRACE_EVENT_PHASE_COUNTER ('C') |
706 #define TRACE_EVENT_PHASE_SAMPLE ('P') | 712 #define TRACE_EVENT_PHASE_SAMPLE ('P') |
707 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') | 713 #define TRACE_EVENT_PHASE_CREATE_OBJECT ('N') |
708 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') | 714 #define TRACE_EVENT_PHASE_DELETE_OBJECT ('D') |
709 | 715 |
710 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. | 716 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. |
711 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0)) | 717 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0)) |
712 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0)) | 718 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0)) |
713 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1)) | 719 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1)) |
714 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2)) | 720 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2)) |
| 721 #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned char>(1 << 3)) |
| 722 |
| 723 #define TRACE_EVENT_FLAG_SCOPE_MASK (static_cast<unsigned char>( \ |
| 724 TRACE_EVENT_FLAG_SCOPE_OFFSET | (TRACE_EVENT_FLAG_SCOPE_OFFSET << 1))) |
715 | 725 |
716 // Type values for identifying types in the TraceValue union. | 726 // Type values for identifying types in the TraceValue union. |
717 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) | 727 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) |
718 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) | 728 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) |
719 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3)) | 729 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3)) |
720 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4)) | 730 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4)) |
721 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5)) | 731 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5)) |
722 #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6)) | 732 #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6)) |
723 #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7)) | 733 #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7)) |
724 | 734 |
| 735 // Enum reflecting the scope of an INSTANT event. Must fit within |
| 736 // TRACE_EVENT_FLAG_SCOPE_MASK. |
| 737 #define TRACE_EVENT_SCOPE_GLOBAL (static_cast<unsigned char>(0 << 3)) |
| 738 #define TRACE_EVENT_SCOPE_PROCESS (static_cast<unsigned char>(1 << 3)) |
| 739 #define TRACE_EVENT_SCOPE_THREAD (static_cast<unsigned char>(2 << 3)) |
| 740 |
| 741 #define TRACE_EVENT_SCOPE_NAME_GLOBAL ('g') |
| 742 #define TRACE_EVENT_SCOPE_NAME_PROCESS ('p') |
| 743 #define TRACE_EVENT_SCOPE_NAME_THREAD ('t') |
| 744 |
725 namespace trace_event_internal { | 745 namespace trace_event_internal { |
726 | 746 |
727 // Specify these values when the corresponding argument of AddTraceEvent is not | 747 // Specify these values when the corresponding argument of AddTraceEvent is not |
728 // used. | 748 // used. |
729 const int kZeroNumArgs = 0; | 749 const int kZeroNumArgs = 0; |
730 const unsigned long long kNoEventId = 0; | 750 const unsigned long long kNoEventId = 0; |
731 | 751 |
732 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers | 752 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers |
733 // are mangled with the Process ID so that they are unlikely to collide when the | 753 // are mangled with the Process ID so that they are unlikely to collide when the |
734 // same pointer is used on different processes. | 754 // same pointer is used on different processes. |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1037 // This macro generates less code then TRACE_EVENT0 but is also | 1057 // This macro generates less code then TRACE_EVENT0 but is also |
1038 // slower to execute when tracing is off. It should generally only be | 1058 // slower to execute when tracing is off. It should generally only be |
1039 // used with code that is seldom executed or conditionally executed | 1059 // used with code that is seldom executed or conditionally executed |
1040 // when debugging. | 1060 // when debugging. |
1041 #define TRACE_EVENT_BINARY_EFFICIENT0(category, name) \ | 1061 #define TRACE_EVENT_BINARY_EFFICIENT0(category, name) \ |
1042 INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED(category, name) | 1062 INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED(category, name) |
1043 | 1063 |
1044 } // namespace trace_event_internal | 1064 } // namespace trace_event_internal |
1045 | 1065 |
1046 #endif // BASE_DEBUG_TRACE_EVENT_INTERNAL_H_ | 1066 #endif // BASE_DEBUG_TRACE_EVENT_INTERNAL_H_ |
OLD | NEW |