| 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 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 long long as_int; | 1090 long long as_int; |
| 1091 double as_double; | 1091 double as_double; |
| 1092 const void* as_pointer; | 1092 const void* as_pointer; |
| 1093 const char* as_string; | 1093 const char* as_string; |
| 1094 }; | 1094 }; |
| 1095 | 1095 |
| 1096 // Simple container for const char* that should be copied instead of retained. | 1096 // Simple container for const char* that should be copied instead of retained. |
| 1097 class TraceStringWithCopy { | 1097 class TraceStringWithCopy { |
| 1098 public: | 1098 public: |
| 1099 explicit TraceStringWithCopy(const char* str) : str_(str) {} | 1099 explicit TraceStringWithCopy(const char* str) : str_(str) {} |
| 1100 operator const char* () const { return str_; } | 1100 const char* str() const { return str_; } |
| 1101 private: | 1101 private: |
| 1102 const char* str_; | 1102 const char* str_; |
| 1103 }; | 1103 }; |
| 1104 | 1104 |
| 1105 // Define SetTraceValue for each allowed type. It stores the type and | 1105 // Define SetTraceValue for each allowed type. It stores the type and |
| 1106 // value in the return arguments. This allows this API to avoid declaring any | 1106 // value in the return arguments. This allows this API to avoid declaring any |
| 1107 // structures so that it is portable to third_party libraries. | 1107 // structures so that it is portable to third_party libraries. |
| 1108 #define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, \ | 1108 #define INTERNAL_DECLARE_SET_TRACE_VALUE(actual_type, \ |
| 1109 arg_expression, \ |
| 1109 union_member, \ | 1110 union_member, \ |
| 1110 value_type_id) \ | 1111 value_type_id) \ |
| 1111 static inline void SetTraceValue( \ | 1112 static inline void SetTraceValue( \ |
| 1112 actual_type arg, \ | 1113 actual_type arg, \ |
| 1113 unsigned char* type, \ | 1114 unsigned char* type, \ |
| 1114 unsigned long long* value) { \ | 1115 unsigned long long* value) { \ |
| 1115 TraceValueUnion type_value; \ | 1116 TraceValueUnion type_value; \ |
| 1116 type_value.union_member = arg; \ | 1117 type_value.union_member = arg_expression; \ |
| 1117 *type = value_type_id; \ | 1118 *type = value_type_id; \ |
| 1118 *value = type_value.as_uint; \ | 1119 *value = type_value.as_uint; \ |
| 1119 } | 1120 } |
| 1120 // Simpler form for int types that can be safely casted. | 1121 // Simpler form for int types that can be safely casted. |
| 1121 #define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, \ | 1122 #define INTERNAL_DECLARE_SET_TRACE_VALUE_INT(actual_type, \ |
| 1122 value_type_id) \ | 1123 value_type_id) \ |
| 1123 static inline void SetTraceValue( \ | 1124 static inline void SetTraceValue( \ |
| 1124 actual_type arg, \ | 1125 actual_type arg, \ |
| 1125 unsigned char* type, \ | 1126 unsigned char* type, \ |
| 1126 unsigned long long* value) { \ | 1127 unsigned long long* value) { \ |
| 1127 *type = value_type_id; \ | 1128 *type = value_type_id; \ |
| 1128 *value = static_cast<unsigned long long>(arg); \ | 1129 *value = static_cast<unsigned long long>(arg); \ |
| 1129 } | 1130 } |
| 1130 | 1131 |
| 1131 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT) | 1132 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long long, TRACE_VALUE_TYPE_UINT) |
| 1132 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long, TRACE_VALUE_TYPE_UINT) | 1133 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned long, TRACE_VALUE_TYPE_UINT) |
| 1133 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT) | 1134 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned int, TRACE_VALUE_TYPE_UINT) |
| 1134 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT) | 1135 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned short, TRACE_VALUE_TYPE_UINT) |
| 1135 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT) | 1136 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(unsigned char, TRACE_VALUE_TYPE_UINT) |
| 1136 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT) | 1137 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long long, TRACE_VALUE_TYPE_INT) |
| 1137 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long, TRACE_VALUE_TYPE_INT) | 1138 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(long, TRACE_VALUE_TYPE_INT) |
| 1138 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT) | 1139 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(int, TRACE_VALUE_TYPE_INT) |
| 1139 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT) | 1140 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(short, TRACE_VALUE_TYPE_INT) |
| 1140 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT) | 1141 INTERNAL_DECLARE_SET_TRACE_VALUE_INT(signed char, TRACE_VALUE_TYPE_INT) |
| 1141 INTERNAL_DECLARE_SET_TRACE_VALUE(bool, as_bool, TRACE_VALUE_TYPE_BOOL) | 1142 INTERNAL_DECLARE_SET_TRACE_VALUE(bool, arg, as_bool, TRACE_VALUE_TYPE_BOOL) |
| 1142 INTERNAL_DECLARE_SET_TRACE_VALUE(double, as_double, TRACE_VALUE_TYPE_DOUBLE) | 1143 INTERNAL_DECLARE_SET_TRACE_VALUE(double, arg, as_double, |
| 1143 INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, as_pointer, | 1144 TRACE_VALUE_TYPE_DOUBLE) |
| 1145 INTERNAL_DECLARE_SET_TRACE_VALUE(const void*, arg, as_pointer, |
| 1144 TRACE_VALUE_TYPE_POINTER) | 1146 TRACE_VALUE_TYPE_POINTER) |
| 1145 INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, as_string, | 1147 INTERNAL_DECLARE_SET_TRACE_VALUE(const char*, arg, as_string, |
| 1146 TRACE_VALUE_TYPE_STRING) | 1148 TRACE_VALUE_TYPE_STRING) |
| 1147 INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, as_string, | 1149 INTERNAL_DECLARE_SET_TRACE_VALUE(const TraceStringWithCopy&, arg.str(), |
| 1148 TRACE_VALUE_TYPE_COPY_STRING) | 1150 as_string, TRACE_VALUE_TYPE_COPY_STRING) |
| 1149 | 1151 |
| 1150 #undef INTERNAL_DECLARE_SET_TRACE_VALUE | 1152 #undef INTERNAL_DECLARE_SET_TRACE_VALUE |
| 1151 #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT | 1153 #undef INTERNAL_DECLARE_SET_TRACE_VALUE_INT |
| 1152 | 1154 |
| 1153 // std::string version of SetTraceValue so that trace arguments can be strings. | 1155 // std::string version of SetTraceValue so that trace arguments can be strings. |
| 1154 static inline void SetTraceValue(const std::string& arg, | 1156 static inline void SetTraceValue(const std::string& arg, |
| 1155 unsigned char* type, | 1157 unsigned char* type, |
| 1156 unsigned long long* value) { | 1158 unsigned long long* value) { |
| 1157 TraceValueUnion type_value; | 1159 TraceValueUnion type_value; |
| 1158 type_value.as_string = arg.c_str(); | 1160 type_value.as_string = arg.c_str(); |
| (...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 const char* name_; | 1511 const char* name_; |
| 1510 IDType id_; | 1512 IDType id_; |
| 1511 | 1513 |
| 1512 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); | 1514 DISALLOW_COPY_AND_ASSIGN(TraceScopedTrackableObject); |
| 1513 }; | 1515 }; |
| 1514 | 1516 |
| 1515 } // namespace debug | 1517 } // namespace debug |
| 1516 } // namespace base | 1518 } // namespace base |
| 1517 | 1519 |
| 1518 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ | 1520 #endif /* BASE_DEBUG_TRACE_EVENT_H_ */ |
| OLD | NEW |