| 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 WTFLogVerbose(const char* file, int line, const char* function,
WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6); | 85 WTF_EXPORT void WTFLogVerbose(const char* file, int line, const char* function,
WTFLogChannel*, const char* format, ...) WTF_ATTRIBUTE_PRINTF(5, 6); |
| 91 WTF_EXPORT void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2)
; | 86 WTF_EXPORT void WTFLogAlways(const char* format, ...) WTF_ATTRIBUTE_PRINTF(1, 2)
; |
| 92 | 87 |
| 93 WTF_EXPORT void WTFGetBacktrace(void** stack, int* size); | 88 WTF_EXPORT void WTFGetBacktrace(void** stack, int* size); |
| 94 WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31); | 89 WTF_EXPORT void WTFReportBacktrace(int framesToShow = 31); |
| 95 WTF_EXPORT void WTFPrintBacktrace(void** stack, int size); | 90 WTF_EXPORT void WTFPrintBacktrace(void** stack, int size); |
| 96 | 91 |
| 97 /* IMMEDIATE_CRASH() - Like CRASH() below but crashes in the fastest, simplest p
ossible way with no attempt at logging. */ | 92 /* IMMEDIATE_CRASH() - Like CRASH() below but crashes in the fastest, simplest p
ossible way with no attempt at logging. */ |
| 98 #ifndef IMMEDIATE_CRASH | 93 #ifndef IMMEDIATE_CRASH |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 #endif | 189 #endif |
| 195 | 190 |
| 196 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure | 191 // Users must test "#if ENABLE(SECURITY_ASSERT)", which helps ensure |
| 197 // that code testing this macro has included this header. | 192 // that code testing this macro has included this header. |
| 198 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) | 193 #if defined(ADDRESS_SANITIZER) || ENABLE(ASSERT) |
| 199 #define ENABLE_SECURITY_ASSERT 1 | 194 #define ENABLE_SECURITY_ASSERT 1 |
| 200 #else | 195 #else |
| 201 #define ENABLE_SECURITY_ASSERT 0 | 196 #define ENABLE_SECURITY_ASSERT 0 |
| 202 #endif | 197 #endif |
| 203 | 198 |
| 204 /* ASSERT_ARG */ | |
| 205 | |
| 206 #if ASSERT_ARG_DISABLED | |
| 207 | |
| 208 #define ASSERT_ARG(argName, assertion) ((void)0) | |
| 209 | |
| 210 #else | |
| 211 | |
| 212 #define ASSERT_ARG(argName, assertion) do \ | |
| 213 if (!(assertion)) { \ | |
| 214 WTFReportArgumentAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTIO
N, #argName, #assertion); \ | |
| 215 CRASH(); \ | |
| 216 } \ | |
| 217 while (0) | |
| 218 | |
| 219 #endif | |
| 220 | |
| 221 // WTF_LOG | 199 // WTF_LOG |
| 222 // This is deprecated. Should be replaced with DVLOG(verboselevel), which works | 200 // This is deprecated. Should be replaced with DVLOG(verboselevel), which works |
| 223 // only in debug build, or VLOG(verboselevel), which works in release build too. | 201 // only in debug build, or VLOG(verboselevel), which works in release build too. |
| 224 #if LOG_DISABLED | 202 #if LOG_DISABLED |
| 225 #define WTF_LOG(channel, ...) ((void)0) | 203 #define WTF_LOG(channel, ...) ((void)0) |
| 226 #else | 204 #else |
| 227 #define WTF_LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_P
REFIX, channel), __VA_ARGS__) | 205 #define WTF_LOG(channel, ...) WTFLog(&JOIN_LOG_CHANNEL_WITH_PREFIX(LOG_CHANNEL_P
REFIX, channel), __VA_ARGS__) |
| 228 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREF
IX_LEVEL_2(prefix, channel) | 206 #define JOIN_LOG_CHANNEL_WITH_PREFIX(prefix, channel) JOIN_LOG_CHANNEL_WITH_PREF
IX_LEVEL_2(prefix, channel) |
| 229 #define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel | 207 #define JOIN_LOG_CHANNEL_WITH_PREFIX_LEVEL_2(prefix, channel) prefix ## channel |
| 230 #endif | 208 #endif |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 } \ | 262 } \ |
| 285 inline const thisType& to##thisType(const argumentType& argumentName) \ | 263 inline const thisType& to##thisType(const argumentType& argumentName) \ |
| 286 { \ | 264 { \ |
| 287 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ | 265 ASSERT_WITH_SECURITY_IMPLICATION(referencePredicate); \ |
| 288 return static_cast<const thisType&>(argumentName); \ | 266 return static_cast<const thisType&>(argumentName); \ |
| 289 } \ | 267 } \ |
| 290 void to##thisType(const thisType*); \ | 268 void to##thisType(const thisType*); \ |
| 291 void to##thisType(const thisType&) | 269 void to##thisType(const thisType&) |
| 292 | 270 |
| 293 #endif /* WTF_Assertions_h */ | 271 #endif /* WTF_Assertions_h */ |
| OLD | NEW |