| 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 <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 | 10 |
| 11 #include "src/base/build_config.h" | 11 #include "src/base/build_config.h" |
| 12 | 12 |
| 13 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); | 13 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); |
| 14 | 14 |
| 15 #if defined(DEBUG) || defined(DCHECK_ALWAYS_ON) |
| 16 #define DCHECK_IS_ON 1 |
| 17 #else |
| 18 #define DCHECK_IS_ON 0 |
| 19 #endif |
| 20 |
| 15 | 21 |
| 16 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during | 22 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during |
| 17 // development, but they should not be relied on in the final product. | 23 // development, but they should not be relied on in the final product. |
| 18 #ifdef DEBUG | 24 #if DCHECK_IS_ON |
| 19 #define FATAL(msg) \ | 25 #define FATAL(msg) \ |
| 20 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) | 26 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) |
| 21 #define UNIMPLEMENTED() \ | 27 #define UNIMPLEMENTED() \ |
| 22 V8_Fatal(__FILE__, __LINE__, "unimplemented code") | 28 V8_Fatal(__FILE__, __LINE__, "unimplemented code") |
| 23 #define UNREACHABLE() \ | 29 #define UNREACHABLE() \ |
| 24 V8_Fatal(__FILE__, __LINE__, "unreachable code") | 30 V8_Fatal(__FILE__, __LINE__, "unreachable code") |
| 25 #else | 31 #else |
| 26 #define FATAL(msg) \ | 32 #define FATAL(msg) \ |
| 27 V8_Fatal("", 0, "%s", (msg)) | 33 V8_Fatal("", 0, "%s", (msg)) |
| 28 #define UNIMPLEMENTED() \ | 34 #define UNIMPLEMENTED() \ |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 namespace base { | 190 namespace base { |
| 185 | 191 |
| 186 // Exposed for making debugging easier (to see where your function is being | 192 // Exposed for making debugging easier (to see where your function is being |
| 187 // called, just add a call to DumpBacktrace). | 193 // called, just add a call to DumpBacktrace). |
| 188 void DumpBacktrace(); | 194 void DumpBacktrace(); |
| 189 | 195 |
| 190 } } // namespace v8::base | 196 } } // namespace v8::base |
| 191 | 197 |
| 192 | 198 |
| 193 // The DCHECK macro is equivalent to CHECK except that it only | 199 // The DCHECK macro is equivalent to CHECK except that it only |
| 194 // generates code in debug builds. | 200 // generates code in debug builds or if DCHECK_ALWAYS_ON is defined. |
| 195 #ifdef DEBUG | 201 #if DCHECK_IS_ON |
| 196 #define DCHECK_RESULT(expr) CHECK(expr) | 202 #define DCHECK_RESULT(expr) CHECK(expr) |
| 197 #define DCHECK(condition) CHECK(condition) | 203 #define DCHECK(condition) CHECK(condition) |
| 198 #define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2) | 204 #define DCHECK_EQ(v1, v2) CHECK_EQ(v1, v2) |
| 199 #define DCHECK_NE(v1, v2) CHECK_NE(v1, v2) | 205 #define DCHECK_NE(v1, v2) CHECK_NE(v1, v2) |
| 200 #define DCHECK_GE(v1, v2) CHECK_GE(v1, v2) | 206 #define DCHECK_GE(v1, v2) CHECK_GE(v1, v2) |
| 201 #define DCHECK_LT(v1, v2) CHECK_LT(v1, v2) | 207 #define DCHECK_LT(v1, v2) CHECK_LT(v1, v2) |
| 202 #define DCHECK_LE(v1, v2) CHECK_LE(v1, v2) | 208 #define DCHECK_LE(v1, v2) CHECK_LE(v1, v2) |
| 203 #else | 209 #else |
| 204 #define DCHECK_RESULT(expr) (expr) | 210 #define DCHECK_RESULT(expr) (expr) |
| 205 #define DCHECK(condition) ((void) 0) | 211 #define DCHECK(condition) ((void) 0) |
| 206 #define DCHECK_EQ(v1, v2) ((void) 0) | 212 #define DCHECK_EQ(v1, v2) ((void) 0) |
| 207 #define DCHECK_NE(v1, v2) ((void) 0) | 213 #define DCHECK_NE(v1, v2) ((void) 0) |
| 208 #define DCHECK_GE(v1, v2) ((void) 0) | 214 #define DCHECK_GE(v1, v2) ((void) 0) |
| 209 #define DCHECK_LT(v1, v2) ((void) 0) | 215 #define DCHECK_LT(v1, v2) ((void) 0) |
| 210 #define DCHECK_LE(v1, v2) ((void) 0) | 216 #define DCHECK_LE(v1, v2) ((void) 0) |
| 211 #endif | 217 #endif |
| 212 | 218 |
| 213 #define DCHECK_NOT_NULL(p) DCHECK_NE(NULL, p) | 219 #define DCHECK_NOT_NULL(p) DCHECK_NE(NULL, p) |
| 214 | 220 |
| 215 // "Extra checks" are lightweight checks that are enabled in some release | 221 // "Extra checks" are lightweight checks that are enabled in some release |
| 216 // builds. | 222 // builds. |
| 217 #ifdef ENABLE_EXTRA_CHECKS | 223 #ifdef ENABLE_EXTRA_CHECKS |
| 218 #define EXTRA_CHECK(condition) CHECK(condition) | 224 #define EXTRA_CHECK(condition) CHECK(condition) |
| 219 #else | 225 #else |
| 220 #define EXTRA_CHECK(condition) ((void) 0) | 226 #define EXTRA_CHECK(condition) ((void) 0) |
| 221 #endif | 227 #endif |
| 222 | 228 |
| 223 #endif // V8_BASE_LOGGING_H_ | 229 #endif // V8_BASE_LOGGING_H_ |
| OLD | NEW |