| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2003, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 /* These helper functions are always declared, but not necessarily always define
d if the corresponding function is disabled. */ | 83 /* These helper functions are always declared, but not necessarily always define
d if the corresponding function is disabled. */ |
| 84 | 84 |
| 85 typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState; | 85 typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState; |
| 86 | 86 |
| 87 typedef struct { | 87 typedef struct { |
| 88 WTFLogChannelState state; | 88 WTFLogChannelState state; |
| 89 } WTFLogChannel; | 89 } WTFLogChannel; |
| 90 | 90 |
| 91 WTF_EXPORT void WTFReportAssertionFailure(const char* file, int line, const char
* function, const char* assertion); | 91 WTF_EXPORT void WTFReportAssertionFailure(const char* file, int line, const char
* function, const char* assertion); |
| 92 WTF_EXPORT void WTFReportAssertionFailureWithMessage(const char* file, int line,
const char* function, const char* assertion, const char* format, ...) WTF_ATTRI
BUTE_PRINTF(5, 6); | |
| 93 WTF_EXPORT void WTFReportArgumentAssertionFailure(const char* file, int line, co
nst char* function, const char* argName, const char* assertion); | 92 WTF_EXPORT void WTFReportArgumentAssertionFailure(const char* file, int line, co
nst char* function, const char* argName, const char* assertion); |
| 94 WTF_EXPORT void WTFReportError(const char* file, int line, const char* function,
const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5); | 93 WTF_EXPORT void WTFReportError(const char* file, int line, const char* function,
const char* format, ...) WTF_ATTRIBUTE_PRINTF(4, 5); |
| 95 WTF_EXPORT void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PR
INTF(2, 3); | 94 WTF_EXPORT void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PR
INTF(2, 3); |
| 96 WTF_EXPORT void WTFLogVerbose(const char* file, int line, const char* function,
WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6); | 95 WTF_EXPORT void WTFLogVerbose(const char* file, int line, const char* function,
WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6); |
| 97 WTF_EXPORT void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2)
; | 96 WTF_EXPORT void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2)
; |
| 98 | 97 |
| 99 WTF_EXPORT void WTFGetBacktrace(void** stack, int* size); | 98 WTF_EXPORT void WTFGetBacktrace(void** stack, int* size); |
| 100 WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31); | 99 WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31); |
| 101 WTF_EXPORT void WTFPrintBacktrace(void** stack, int size); | 100 WTF_EXPORT void WTFPrintBacktrace(void** stack, int size); |
| 102 | 101 |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 #endif | 202 #endif |
| 204 | 203 |
| 205 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure | 204 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure |
| 206 // that code testing this macro has included this header. | 205 // that code testing this macro has included this header. |
| 207 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) | 206 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) |
| 208 #define ENABLE_SECURITY_ASSERT 1 | 207 #define ENABLE_SECURITY_ASSERT 1 |
| 209 #else | 208 #else |
| 210 #define ENABLE_SECURITY_ASSERT 0 | 209 #define ENABLE_SECURITY_ASSERT 0 |
| 211 #endif | 210 #endif |
| 212 | 211 |
| 213 // ASSERT_WITH_MESSAGE | |
| 214 // This is deprecated. We should use DCHECK() << "message". | |
| 215 #if ASSERT_MSG_DISABLED | |
| 216 #define ASSERT_WITH_MESSAGE(assertion, ...) ((void)0) | |
| 217 #else | |
| 218 #define ASSERT_WITH_MESSAGE(assertion, ...) do \ | |
| 219 if (!(assertion)) { \ | |
| 220 WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNC
TION, #assertion, __VA_ARGS__); \ | |
| 221 CRASH(); \ | |
| 222 } \ | |
| 223 while (0) | |
| 224 #endif | |
| 225 | |
| 226 // ASSERT_WITH_MESSAGE_UNUSED | |
| 227 // This is deprecated. We should use DCHECK() << "message" and | |
| 228 // ALLOW_UNUSED_LOCAL(). | |
| 229 #if ASSERT_MSG_DISABLED | |
| 230 #define ASSERT_WITH_MESSAGE_UNUSED(variable, assertion, ...) ((void)variable) | |
| 231 #else | |
| 232 #define ASSERT_WITH_MESSAGE_UNUSED(variable, assertion, ...) do \ | |
| 233 if (!(assertion)) { \ | |
| 234 WTFReportAssertionFailureWithMessage(__FILE__, __LINE__, WTF_PRETTY_FUNC
TION, #assertion, __VA_ARGS__); \ | |
| 235 CRASH(); \ | |
| 236 } \ | |
| 237 while (0) | |
| 238 #endif | |
| 239 | |
| 240 /* ASSERT_ARG */ | 212 /* ASSERT_ARG */ |
| 241 | 213 |
| 242 #if ASSERT_ARG_DISABLED | 214 #if ASSERT_ARG_DISABLED |
| 243 | 215 |
| 244 #define ASSERT_ARG(argName, assertion) ((void)0) | 216 #define ASSERT_ARG(argName, assertion) ((void)0) |
| 245 | 217 |
| 246 #else | 218 #else |
| 247 | 219 |
| 248 #define ASSERT_ARG(argName, assertion) do \ | 220 #define ASSERT_ARG(argName, assertion) do \ |
| 249 if (!(assertion)) { \ | 221 if (!(assertion)) { \ |
| (...skipping 17 matching lines...) Expand all Loading... |
| 267 | 239 |
| 268 /* RELEASE_ASSERT | 240 /* RELEASE_ASSERT |
| 269 | 241 |
| 270 Use in places where failure of an assertion indicates a definite security | 242 Use in places where failure of an assertion indicates a definite security |
| 271 vulnerability from which execution must not continue even in a release build. | 243 vulnerability from which execution must not continue even in a release build. |
| 272 Please sure to file bugs for these failures using the security template: | 244 Please sure to file bugs for these failures using the security template: |
| 273 http://code.google.com/p/chromium/issues/entry?template=Security%20Bug | 245 http://code.google.com/p/chromium/issues/entry?template=Security%20Bug |
| 274 */ | 246 */ |
| 275 // RELEASE_ASSERT* are deprecated. We should use: | 247 // RELEASE_ASSERT* are deprecated. We should use: |
| 276 // - CHECK() for RELEASE_ASSERT() | 248 // - CHECK() for RELEASE_ASSERT() |
| 277 // - CHECK() << message for RELEASE_ASSERT_WITH_MESSAGE() | |
| 278 // - RELEASE_NOTREACHED() for RELEASE_ASSERT_NOT_REACHED(). | 249 // - RELEASE_NOTREACHED() for RELEASE_ASSERT_NOT_REACHED(). |
| 279 #if ENABLE(ASSERT) | 250 #if ENABLE(ASSERT) |
| 280 #define RELEASE_ASSERT(assertion) ASSERT(assertion) | 251 #define RELEASE_ASSERT(assertion) ASSERT(assertion) |
| 281 #define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) ASSERT_WITH_MESSAGE(assertio
n, __VA_ARGS__) | |
| 282 #define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED() | 252 #define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED() |
| 283 #else | 253 #else |
| 284 #define RELEASE_ASSERT(assertion) (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH())
: (void)0) | 254 #define RELEASE_ASSERT(assertion) (UNLIKELY(!(assertion)) ? (IMMEDIATE_CRASH())
: (void)0) |
| 285 #define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) RELEASE_ASSERT(assertion) | |
| 286 #define RELEASE_ASSERT_NOT_REACHED() IMMEDIATE_CRASH() | 255 #define RELEASE_ASSERT_NOT_REACHED() IMMEDIATE_CRASH() |
| 287 #endif | 256 #endif |
| 288 // TODO(tkent): Move this to base/logging.h? | 257 // TODO(tkent): Move this to base/logging.h? |
| 289 #define RELEASE_NOTREACHED() LOG(FATAL) | 258 #define RELEASE_NOTREACHED() LOG(FATAL) |
| 290 | 259 |
| 291 /* DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES */ | 260 /* DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES */ |
| 292 | 261 |
| 293 // Allow equality comparisons of Objects by reference or pointer, interchangeabl
y. | 262 // Allow equality comparisons of Objects by reference or pointer, interchangeabl
y. |
| 294 // This can be only used on types whose equality makes no other sense than point
er equality. | 263 // This can be only used on types whose equality makes no other sense than point
er equality. |
| 295 #define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \ | 264 #define DEFINE_COMPARISON_OPERATORS_WITH_REFERENCES(thisType) \ |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 } \ | 296 } \ |
| 328 inline const thisType& to##thisType(const argumentType& argumentName) \ | 297 inline const thisType& to##thisType(const argumentType& argumentName) \ |
| 329 { \ | 298 { \ |
| 330 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ | 299 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ |
| 331 return static_cast<const thisType&>(argumentName); \ | 300 return static_cast<const thisType&>(argumentName); \ |
| 332 } \ | 301 } \ |
| 333 void to##thisType(const thisType*); \ | 302 void to##thisType(const thisType*); \ |
| 334 void to##thisType(const thisType&) | 303 void to##thisType(const thisType&) |
| 335 | 304 |
| 336 #endif /* WTF_Assertions_h */ | 305 #endif /* WTF_Assertions_h */ |
| OLD | NEW |