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, type, 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, type, 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 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 | 242 // Records a single BEGIN event called "name" immediately, with 0, 1 or 2 |
237 // associated arguments. If the category is not enabled, then this | 243 // associated arguments. If the category is not enabled, then this |
238 // does nothing. | 244 // does nothing. |
239 // - category and name strings must have application lifetime (statics or | 245 // - category and name strings must have application lifetime (statics or |
240 // literals). They may not include " chars. | 246 // literals). They may not include " chars. |
241 #define TRACE_EVENT_BEGIN0(category, name) \ | 247 #define TRACE_EVENT_BEGIN0(category, name) \ |
242 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ | 248 INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, \ |
243 category, name, TRACE_EVENT_FLAG_NONE) | 249 category, name, TRACE_EVENT_FLAG_NONE) |
244 #define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ | 250 #define TRACE_EVENT_BEGIN1(category, name, arg1_name, arg1_val) \ |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 } while (0) | 672 } while (0) |
667 | 673 |
668 // Notes regarding the following definitions: | 674 // Notes regarding the following definitions: |
669 // New values can be added and propagated to third party libraries, but existing | 675 // New values can be added and propagated to third party libraries, but existing |
670 // definitions must never be changed, because third party libraries may use old | 676 // definitions must never be changed, because third party libraries may use old |
671 // definitions. | 677 // definitions. |
672 | 678 |
673 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. | 679 // Phase indicates the nature of an event entry. E.g. part of a begin/end pair. |
674 #define TRACE_EVENT_PHASE_BEGIN ('B') | 680 #define TRACE_EVENT_PHASE_BEGIN ('B') |
675 #define TRACE_EVENT_PHASE_END ('E') | 681 #define TRACE_EVENT_PHASE_END ('E') |
676 #define TRACE_EVENT_PHASE_INSTANT ('I') | 682 #define TRACE_EVENT_PHASE_INSTANT ('i') |
677 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') | 683 #define TRACE_EVENT_PHASE_ASYNC_BEGIN ('S') |
678 #define TRACE_EVENT_PHASE_ASYNC_STEP ('T') | 684 #define TRACE_EVENT_PHASE_ASYNC_STEP ('T') |
679 #define TRACE_EVENT_PHASE_ASYNC_END ('F') | 685 #define TRACE_EVENT_PHASE_ASYNC_END ('F') |
680 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') | 686 #define TRACE_EVENT_PHASE_FLOW_BEGIN ('s') |
681 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') | 687 #define TRACE_EVENT_PHASE_FLOW_STEP ('t') |
682 #define TRACE_EVENT_PHASE_FLOW_END ('f') | 688 #define TRACE_EVENT_PHASE_FLOW_END ('f') |
683 #define TRACE_EVENT_PHASE_METADATA ('M') | 689 #define TRACE_EVENT_PHASE_METADATA ('M') |
684 #define TRACE_EVENT_PHASE_COUNTER ('C') | 690 #define TRACE_EVENT_PHASE_COUNTER ('C') |
685 | 691 |
686 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. | 692 // Flags for changing the behavior of TRACE_EVENT_API_ADD_TRACE_EVENT. |
687 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0)) | 693 #define TRACE_EVENT_FLAG_NONE (static_cast<unsigned char>(0)) |
688 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0)) | 694 #define TRACE_EVENT_FLAG_COPY (static_cast<unsigned char>(1 << 0)) |
689 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1)) | 695 #define TRACE_EVENT_FLAG_HAS_ID (static_cast<unsigned char>(1 << 1)) |
690 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2)) | 696 #define TRACE_EVENT_FLAG_MANGLE_ID (static_cast<unsigned char>(1 << 2)) |
697 #define TRACE_EVENT_FLAG_SCOPE_OFFSET (static_cast<unsigned char>(1 << 3)) | |
698 | |
699 #define TRACE_EVENT_FLAG_SCOPE_MASK (static_cast<unsigned char>( \ | |
700 TRACE_EVENT_FLAG_SCOPE_OFFSET | (TRACE_EVENT_FLAG_SCOPE_OFFSET << 1))) | |
691 | 701 |
692 // Type values for identifying types in the TraceValue union. | 702 // Type values for identifying types in the TraceValue union. |
693 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) | 703 #define TRACE_VALUE_TYPE_BOOL (static_cast<unsigned char>(1)) |
694 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) | 704 #define TRACE_VALUE_TYPE_UINT (static_cast<unsigned char>(2)) |
695 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3)) | 705 #define TRACE_VALUE_TYPE_INT (static_cast<unsigned char>(3)) |
696 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4)) | 706 #define TRACE_VALUE_TYPE_DOUBLE (static_cast<unsigned char>(4)) |
697 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5)) | 707 #define TRACE_VALUE_TYPE_POINTER (static_cast<unsigned char>(5)) |
698 #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6)) | 708 #define TRACE_VALUE_TYPE_STRING (static_cast<unsigned char>(6)) |
699 #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7)) | 709 #define TRACE_VALUE_TYPE_COPY_STRING (static_cast<unsigned char>(7)) |
700 | 710 |
711 // Enum reflecting the scope of an INSTANT event. Must fit within | |
712 // TRACE_EVENT_FLAG_SCOPE_MASK. | |
713 #define TRACE_EVENT_SCOPE_GLOBAL (static_cast<unsigned char>(0 << 3)) | |
714 #define TRACE_EVENT_SCOPE_PROCESS (static_cast<unsigned char>(1 << 3)) | |
715 #define TRACE_EVENT_SCOPE_THREAD (static_cast<unsigned char>(2 << 3)) | |
716 | |
717 #define TRACE_SCOPE_NAME_GLOBAL ('g') | |
nduca
2013/02/21 06:06:04
I think looking up at the phase we seem to do most
| |
718 #define TRACE_SCOPE_NAME_PROCESS ('p') | |
719 #define TRACE_SCOPE_NAME_THREAD ('t') | |
720 | |
701 namespace trace_event_internal { | 721 namespace trace_event_internal { |
702 | 722 |
703 // Specify these values when the corresponding argument of AddTraceEvent is not | 723 // Specify these values when the corresponding argument of AddTraceEvent is not |
704 // used. | 724 // used. |
705 const int kZeroNumArgs = 0; | 725 const int kZeroNumArgs = 0; |
706 const unsigned long long kNoEventId = 0; | 726 const unsigned long long kNoEventId = 0; |
707 | 727 |
708 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers | 728 // TraceID encapsulates an ID that can either be an integer or pointer. Pointers |
709 // are mangled with the Process ID so that they are unlikely to collide when the | 729 // are mangled with the Process ID so that they are unlikely to collide when the |
710 // same pointer is used on different processes. | 730 // same pointer is used on different processes. |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 // This macro generates less code then TRACE_EVENT0 but is also | 1033 // This macro generates less code then TRACE_EVENT0 but is also |
1014 // slower to execute when tracing is off. It should generally only be | 1034 // slower to execute when tracing is off. It should generally only be |
1015 // used with code that is seldom executed or conditionally executed | 1035 // used with code that is seldom executed or conditionally executed |
1016 // when debugging. | 1036 // when debugging. |
1017 #define TRACE_EVENT_BINARY_EFFICIENT0(category, name) \ | 1037 #define TRACE_EVENT_BINARY_EFFICIENT0(category, name) \ |
1018 INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED(category, name) | 1038 INTERNAL_TRACE_EVENT_BINARY_EFFICIENT_ADD_SCOPED(category, name) |
1019 | 1039 |
1020 } // namespace trace_event_internal | 1040 } // namespace trace_event_internal |
1021 | 1041 |
1022 #endif // BASE_DEBUG_TRACE_EVENT_INTERNAL_H_ | 1042 #endif // BASE_DEBUG_TRACE_EVENT_INTERNAL_H_ |
OLD | NEW |