Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project 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 #ifndef V8_BASE_LOGGING_H_ | 5 #ifndef V8_BASE_LOGGING_H_ |
| 6 #define V8_BASE_LOGGING_H_ | 6 #define V8_BASE_LOGGING_H_ |
| 7 | 7 |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <sstream> | 9 #include <sstream> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 // | 42 // |
| 43 // We make sure CHECK et al. always evaluates their arguments, as | 43 // We make sure CHECK et al. always evaluates their arguments, as |
| 44 // doing CHECK(FunctionWithSideEffect()) is a common idiom. | 44 // doing CHECK(FunctionWithSideEffect()) is a common idiom. |
| 45 #define CHECK(condition) \ | 45 #define CHECK(condition) \ |
| 46 do { \ | 46 do { \ |
| 47 if (V8_UNLIKELY(!(condition))) { \ | 47 if (V8_UNLIKELY(!(condition))) { \ |
| 48 V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", #condition); \ | 48 V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", #condition); \ |
| 49 } \ | 49 } \ |
| 50 } while (0) | 50 } while (0) |
| 51 | 51 |
| 52 // CHECK_EXTRA is like CHECK, but has two or more arguments: a boolean | |
| 53 // expression, a format string, and any number of extra arguments. The boolean | |
| 54 // expression will be evaluated at runtime. If it evaluates to false, then an | |
| 55 // error message will be shown containing the condition, as well as the extra | |
| 56 // info formatted like with printf. | |
| 57 #define CHECK_EXTRA(condition, fmt, ...) \ | |
| 58 do { \ | |
| 59 if (V8_UNLIKELY(!(condition))) { \ | |
| 60 V8_Fatal(__FILE__, __LINE__, "Check failed: %s. Extra info: " fmt, \ | |
| 61 #condition, ##__VA_ARGS__); \ | |
| 62 } \ | |
| 63 } while (0) | |
|
bgeron
2016/08/11 10:56:18
Removed from next patchset.
| |
| 52 | 64 |
| 53 #ifdef DEBUG | 65 #ifdef DEBUG |
| 54 | 66 |
| 55 // Helper macro for binary operators. | 67 // Helper macro for binary operators. |
| 56 // Don't use this macro directly in your code, use CHECK_EQ et al below. | 68 // Don't use this macro directly in your code, use CHECK_EQ et al below. |
| 57 #define CHECK_OP(name, op, lhs, rhs) \ | 69 #define CHECK_OP(name, op, lhs, rhs) \ |
| 58 do { \ | 70 do { \ |
| 59 if (std::string* _msg = ::v8::base::Check##name##Impl( \ | 71 if (std::string* _msg = ::v8::base::Check##name##Impl( \ |
| 60 (lhs), (rhs), #lhs " " #op " " #rhs)) { \ | 72 (lhs), (rhs), #lhs " " #op " " #rhs)) { \ |
| 61 V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", _msg->c_str()); \ | 73 V8_Fatal(__FILE__, __LINE__, "Check failed: %s.", _msg->c_str()); \ |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 void DumpBacktrace(); | 157 void DumpBacktrace(); |
| 146 | 158 |
| 147 } // namespace base | 159 } // namespace base |
| 148 } // namespace v8 | 160 } // namespace v8 |
| 149 | 161 |
| 150 | 162 |
| 151 // The DCHECK macro is equivalent to CHECK except that it only | 163 // The DCHECK macro is equivalent to CHECK except that it only |
| 152 // generates code in debug builds. | 164 // generates code in debug builds. |
| 153 #ifdef DEBUG | 165 #ifdef DEBUG |
| 154 #define DCHECK(condition) CHECK(condition) | 166 #define DCHECK(condition) CHECK(condition) |
| 167 #define DCHECK_EXTRA(condition, fmt, ...) \ | |
| 168 CHECK_EXTRA(condition, fmt, ##__VA_ARGS__) | |
| 155 #define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2) | 169 #define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2) |
| 156 #define DCHECK_NE(v1, v2) CHECK_NE(v1, v2) | 170 #define DCHECK_NE(v1, v2) CHECK_NE(v1, v2) |
| 157 #define DCHECK_GT(v1, v2) CHECK_GT(v1, v2) | 171 #define DCHECK_GT(v1, v2) CHECK_GT(v1, v2) |
| 158 #define DCHECK_GE(v1, v2) CHECK_GE(v1, v2) | 172 #define DCHECK_GE(v1, v2) CHECK_GE(v1, v2) |
| 159 #define DCHECK_LT(v1, v2) CHECK_LT(v1, v2) | 173 #define DCHECK_LT(v1, v2) CHECK_LT(v1, v2) |
| 160 #define DCHECK_LE(v1, v2) CHECK_LE(v1, v2) | 174 #define DCHECK_LE(v1, v2) CHECK_LE(v1, v2) |
| 161 #define DCHECK_NULL(val) CHECK_NULL(val) | 175 #define DCHECK_NULL(val) CHECK_NULL(val) |
| 162 #define DCHECK_NOT_NULL(val) CHECK_NOT_NULL(val) | 176 #define DCHECK_NOT_NULL(val) CHECK_NOT_NULL(val) |
| 163 #define DCHECK_IMPLIES(v1, v2) CHECK_IMPLIES(v1, v2) | 177 #define DCHECK_IMPLIES(v1, v2) CHECK_IMPLIES(v1, v2) |
| 164 #else | 178 #else |
| 165 #define DCHECK(condition) ((void) 0) | 179 #define DCHECK(condition) ((void) 0) |
| 180 #define DCHECK_EXTRA(condition, fmt, ...) ((void)0) | |
| 166 #define DCHECK_EQ(v1, v2) ((void) 0) | 181 #define DCHECK_EQ(v1, v2) ((void) 0) |
| 167 #define DCHECK_NE(v1, v2) ((void) 0) | 182 #define DCHECK_NE(v1, v2) ((void) 0) |
| 168 #define DCHECK_GT(v1, v2) ((void) 0) | 183 #define DCHECK_GT(v1, v2) ((void) 0) |
| 169 #define DCHECK_GE(v1, v2) ((void) 0) | 184 #define DCHECK_GE(v1, v2) ((void) 0) |
| 170 #define DCHECK_LT(v1, v2) ((void) 0) | 185 #define DCHECK_LT(v1, v2) ((void) 0) |
| 171 #define DCHECK_LE(v1, v2) ((void) 0) | 186 #define DCHECK_LE(v1, v2) ((void) 0) |
| 172 #define DCHECK_NULL(val) ((void) 0) | 187 #define DCHECK_NULL(val) ((void) 0) |
| 173 #define DCHECK_NOT_NULL(val) ((void) 0) | 188 #define DCHECK_NOT_NULL(val) ((void) 0) |
| 174 #define DCHECK_IMPLIES(v1, v2) ((void) 0) | 189 #define DCHECK_IMPLIES(v1, v2) ((void) 0) |
| 175 #endif | 190 #endif |
| 176 | 191 |
| 177 #endif // V8_BASE_LOGGING_H_ | 192 #endif // V8_BASE_LOGGING_H_ |
| OLD | NEW |