| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 #define ENABLE_ASSERT 0 | 55 #define ENABLE_ASSERT 0 |
| 56 #else | 56 #else |
| 57 #define ENABLE_ASSERT 1 | 57 #define ENABLE_ASSERT 1 |
| 58 #endif /* defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) */ | 58 #endif /* defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) */ |
| 59 #endif | 59 #endif |
| 60 | 60 |
| 61 #ifndef ASSERT_MSG_DISABLED | 61 #ifndef ASSERT_MSG_DISABLED |
| 62 #define ASSERT_MSG_DISABLED !ENABLE(ASSERT) | 62 #define ASSERT_MSG_DISABLED !ENABLE(ASSERT) |
| 63 #endif | 63 #endif |
| 64 | 64 |
| 65 #ifndef ASSERT_ARG_DISABLED | |
| 66 #define ASSERT_ARG_DISABLED !ENABLE(ASSERT) | |
| 67 #endif | |
| 68 | |
| 69 #ifndef LOG_DISABLED | 65 #ifndef LOG_DISABLED |
| 70 #define LOG_DISABLED !ENABLE(ASSERT) | 66 #define LOG_DISABLED !ENABLE(ASSERT) |
| 71 #endif | 67 #endif |
| 72 | 68 |
| 73 #if COMPILER(GCC) | 69 #if COMPILER(GCC) |
| 74 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__
((__format__(printf, formatStringArgument, extraArguments))) | 70 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) __attribute__
((__format__(printf, formatStringArgument, extraArguments))) |
| 75 #else | 71 #else |
| 76 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) | 72 #define WTF_ATTRIBUTE_PRINTF(formatStringArgument, extraArguments) |
| 77 #endif | 73 #endif |
| 78 | 74 |
| 79 /* These helper functions are always declared, but not necessarily always define
d if the corresponding function is disabled. */ | 75 /* These helper functions are always declared, but not necessarily always define
d if the corresponding function is disabled. */ |
| 80 | 76 |
| 81 typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState; | 77 typedef enum { WTFLogChannelOff, WTFLogChannelOn } WTFLogChannelState; |
| 82 | 78 |
| 83 typedef struct { | 79 typedef struct { |
| 84 WTFLogChannelState state; | 80 WTFLogChannelState state; |
| 85 } WTFLogChannel; | 81 } WTFLogChannel; |
| 86 | 82 |
| 87 WTF_EXPORT void WTFReportAssertionFailure(const char* file, int line, const char
* function, const char* assertion); | 83 WTF_EXPORT void WTFReportAssertionFailure(const char* file, int line, const char
* function, const char* assertion); |
| 88 WTF_EXPORT void WTFReportArgumentAssertionFailure(const char* file, int line, co
nst char* function, const char* argName, const char* assertion); | |
| 89 WTF_EXPORT void WTFLog(WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PR
INTF(2, 3); | 84 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)
; | 85 WTF_EXPORT void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2)
; |
| 91 | 86 |
| 92 WTF_EXPORT void WTFGetBacktrace(void** stack, int* size); | 87 WTF_EXPORT void WTFGetBacktrace(void** stack, int* size); |
| 93 WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31); | 88 WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31); |
| 94 WTF_EXPORT void WTFPrintBacktrace(void** stack, int size); | 89 WTF_EXPORT void WTFPrintBacktrace(void** stack, int size); |
| 95 | 90 |
| 96 /* IMMEDIATE_CRASH() - Like CRASH() below but crashes in the fastest, simplest p
ossible way with no attempt at logging. */ | 91 /* IMMEDIATE_CRASH() - Like CRASH() below but crashes in the fastest, simplest p
ossible way with no attempt at logging. */ |
| 97 #ifndef IMMEDIATE_CRASH | 92 #ifndef IMMEDIATE_CRASH |
| 98 #if COMPILER(GCC) || COMPILER(CLANG) | 93 #if COMPILER(GCC) || COMPILER(CLANG) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 #endif | 188 #endif |
| 194 | 189 |
| 195 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure | 190 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure |
| 196 // that code testing this macro has included this header. | 191 // that code testing this macro has included this header. |
| 197 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) | 192 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) |
| 198 #define ENABLE_SECURITY_ASSERT 1 | 193 #define ENABLE_SECURITY_ASSERT 1 |
| 199 #else | 194 #else |
| 200 #define ENABLE_SECURITY_ASSERT 0 | 195 #define ENABLE_SECURITY_ASSERT 0 |
| 201 #endif | 196 #endif |
| 202 | 197 |
| 203 /* ASSERT_ARG */ | |
| 204 | |
| 205 #if ASSERT_ARG_DISABLED | |
| 206 | |
| 207 #define ASSERT_ARG(argName, assertion) ((void)0) | |
| 208 | |
| 209 #else | |
| 210 | |
| 211 #define ASSERT_ARG(argName, assertion) do \ | |
| 212 if (!(assertion)) { \ | |
| 213 WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTIO
N, #argName, #assertion); \ | |
| 214 CRASH(); \ | |
| 215 } \ | |
| 216 while (0) | |
| 217 | |
| 218 #endif | |
| 219 | |
| 220 // WTF_LOG | 198 // WTF_LOG |
| 221 // This is deprecated. Should be replaced with DVLOG(verboselevel), which works | 199 // This is deprecated. Should be replaced with DVLOG(verboselevel), which works |
| 222 // only in debug build, or VLOG(verboselevel), which works in release build too. | 200 // only in debug build, or VLOG(verboselevel), which works in release build too. |
| 223 #if LOG_DISABLED | 201 #if LOG_DISABLED |
| 224 #define WTF_LOG(channel, ...) ((void)0) | 202 #define WTF_LOG(channel, ...) ((void)0) |
| 225 #else | 203 #else |
| 226 #define WTF_LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_P
REFIX, channel), __VA_ARGS__) | 204 #define WTF_LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_P
REFIX, channel), __VA_ARGS__) |
| 227 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREF
IX_LEVEL_2(prefix, channel) | 205 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREF
IX_LEVEL_2(prefix, channel) |
| 228 #define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel | 206 #define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel |
| 229 #endif | 207 #endif |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 } \ | 261 } \ |
| 284 inline const thisType& to##thisType(const argumentType& argumentName) \ | 262 inline const thisType& to##thisType(const argumentType& argumentName) \ |
| 285 { \ | 263 { \ |
| 286 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ | 264 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ |
| 287 return static_cast<const thisType&>(argumentName); \ | 265 return static_cast<const thisType&>(argumentName); \ |
| 288 } \ | 266 } \ |
| 289 void to##thisType(const thisType*); \ | 267 void to##thisType(const thisType*); \ |
| 290 void to##thisType(const thisType&) | 268 void to##thisType(const thisType&) |
| 291 | 269 |
| 292 #endif /* WTF_Assertions_h */ | 270 #endif /* WTF_Assertions_h */ |
| OLD | NEW |