| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 #endif | 72 #endif |
| 73 | 73 |
| 74 #if COMPILER(GCC) | 74 #if COMPILER(GCC) |
| 75 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__
((__format__(printf, formatStringArgument, extraArguments))) | 75 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__
((__format__(printf, formatStringArgument, extraArguments))) |
| 76 #else | 76 #else |
| 77 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) | 77 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) |
| 78 #endif | 78 #endif |
| 79 | 79 |
| 80 /* These helper functions are always declared, but not necessarily always define
d if the corresponding function is disabled. */ | 80 /* These helper functions are always declared, but not necessarily always define
d if the corresponding function is disabled. */ |
| 81 | 81 |
| 82 typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState; | |
| 83 | |
| 84 typedef struct { | |
| 85 WTFLogChannelState state; | |
| 86 } WTFLogChannel; | |
| 87 | |
| 88 WTF_EXPORT void WTFReportAssertionFailure(const char* file, int line, const char
* function, const char* assertion); | 82 WTF_EXPORT void WTFReportAssertionFailure(const char* file, int line, const char
* function, const char* assertion); |
| 89 WTF_EXPORT void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PR
INTF(2, 3); | |
| 90 WTF_EXPORT void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2)
; | 83 WTF_EXPORT void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2)
; |
| 91 | 84 |
| 92 WTF_EXPORT void WTFGetBacktrace(void** stack, int* size); | 85 WTF_EXPORT void WTFGetBacktrace(void** stack, int* size); |
| 93 WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31); | 86 WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31); |
| 94 WTF_EXPORT void WTFPrintBacktrace(void** stack, int size); | 87 WTF_EXPORT void WTFPrintBacktrace(void** stack, int size); |
| 95 | 88 |
| 96 namespace WTF { | 89 namespace WTF { |
| 97 | 90 |
| 98 #if LOG_DISABLED | 91 #if LOG_DISABLED |
| 99 | 92 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 #if ENABLE_SECURITY_ASSERT | 256 #if ENABLE_SECURITY_ASSERT |
| 264 #define SECURITY_DCHECK(condition) LOG_IF(FATAL, !(condition)) << "Security chec
k failed: " #condition ". " | 257 #define SECURITY_DCHECK(condition) LOG_IF(FATAL, !(condition)) << "Security chec
k failed: " #condition ". " |
| 265 // TODO(tkent): Should we make SECURITY_CHECK different from SECURITY_DCHECK? | 258 // TODO(tkent): Should we make SECURITY_CHECK different from SECURITY_DCHECK? |
| 266 // A SECURITY_CHECK failure is actually not vulnerable. | 259 // A SECURITY_CHECK failure is actually not vulnerable. |
| 267 #define SECURITY_CHECK(condition) SECURITY_DCHECK(condition) | 260 #define SECURITY_CHECK(condition) SECURITY_DCHECK(condition) |
| 268 #else | 261 #else |
| 269 #define SECURITY_DCHECK(condition) ((void)0) | 262 #define SECURITY_DCHECK(condition) ((void)0) |
| 270 #define SECURITY_CHECK(condition) CHECK(condition) | 263 #define SECURITY_CHECK(condition) CHECK(condition) |
| 271 #endif | 264 #endif |
| 272 | 265 |
| 273 // WTF_LOG | |
| 274 // This is deprecated. Should be replaced with DVLOG(verboselevel), which works | |
| 275 // only in debug build, or VLOG(verboselevel), which works in release build too. | |
| 276 #if LOG_DISABLED | |
| 277 #define WTF_LOG(channel, ...) ((void)0) | |
| 278 #else | |
| 279 #define WTF_LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_P
REFIX, channel), __VA_ARGS__) | |
| 280 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREF
IX_LEVEL_2(prefix, channel) | |
| 281 #define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel | |
| 282 #endif | |
| 283 | |
| 284 /* RELEASE_ASSERT | 266 /* RELEASE_ASSERT |
| 285 | 267 |
| 286 Use in places where failure of an assertion indicates a definite security | 268 Use in places where failure of an assertion indicates a definite security |
| 287 vulnerability from which execution must not continue even in a release build. | 269 vulnerability from which execution must not continue even in a release build. |
| 288 Please sure to file bugs for these failures using the security template: | 270 Please sure to file bugs for these failures using the security template: |
| 289 http://code.google.com/p/chromium/issues/entry?template=Security%20Bug | 271 http://code.google.com/p/chromium/issues/entry?template=Security%20Bug |
| 290 */ | 272 */ |
| 291 // RELEASE_ASSERT is deprecated. We should use CHECK() instead. | 273 // RELEASE_ASSERT is deprecated. We should use CHECK() instead. |
| 292 #if ENABLE(ASSERT) | 274 #if ENABLE(ASSERT) |
| 293 #define RELEASE_ASSERT(assertion) ASSERT(assertion) | 275 #define RELEASE_ASSERT(assertion) ASSERT(assertion) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 } \ | 318 } \ |
| 337 inline const thisType& to##thisType(const argumentType& argumentName) \ | 319 inline const thisType& to##thisType(const argumentType& argumentName) \ |
| 338 { \ | 320 { \ |
| 339 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ | 321 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ |
| 340 return static_cast<const thisType&>(argumentName); \ | 322 return static_cast<const thisType&>(argumentName); \ |
| 341 } \ | 323 } \ |
| 342 void to##thisType(const thisType*); \ | 324 void to##thisType(const thisType*); \ |
| 343 void to##thisType(const thisType&) | 325 void to##thisType(const thisType&) |
| 344 | 326 |
| 345 #endif /* WTF_Assertions_h */ | 327 #endif /* WTF_Assertions_h */ |
| OLD | NEW |