启用调试选项时,webkit构建脚本通过将ndebug和ASSERT_ENABLED宏启用为1来自动启用ASSERT。
WebKit/Source/WTF/wtf/Assertions.h
#if !ASSERT_ENABLED
#define ASSERT(assertion, ...) ((void)0)
#define ASSERT_UNDER_CONSTEXPR_CONTEXT(assertion) ((void)0)
#define ASSERT_AT(assertion, file, line, function) ((void)0)
#define ASSERT_NOT_REACHED(...) ((void)0)
#define ASSERT_NOT_REACHED_UNDER_CONSTEXPR_CONTEXT(...) ((void)0)
#define ASSERT_NOT_IMPLEMENTED_YET() ((void)0)
#define ASSERT_IMPLIES(condition, assertion) ((void)0)
#define NO_RETURN_DUE_TO_ASSERT
#define ASSERT_UNUSED(variable, assertion, ...) ((void)variable)
#if ENABLE(SECURITY_ASSERTIONS)
#define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \
(!(assertion) ? \
(WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion), \
CRASH_WITH_SECURITY_IMPLICATION()) : \
(void)0)
#define ASSERT_WITH_SECURITY_IMPLICATION_DISABLED 0
#else /* not ENABLE(SECURITY_ASSERTIONS) */
#define ASSERT_WITH_SECURITY_IMPLICATION(assertion) ((void)0)
#define ASSERT_WITH_SECURITY_IMPLICATION_DISABLED 1
#endif /* ENABLE(SECURITY_ASSERTIONS) */
#else /* ASSERT_ENABLED */
#define ASSERT(assertion, ...) do { \
if (!(assertion)) { \
WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion); \
CRASH_WITH_INFO(__VA_ARGS__); \
} \
} while (0)
#define ASSERT_UNDER_CONSTEXPR_CONTEXT(assertion) do { \
if (!(assertion)) { \
WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion); \
CRASH_UNDER_CONSTEXPR_CONTEXT(); \
} \
} while (0)
#define ASSERT_AT(assertion, file, line, function) do { \
if (!(assertion)) { \
WTFReportAssertionFailure(file, line, function, #assertion); \
CRASH(); \
} \
} while (0)
#define ASSERT_NOT_REACHED(...) do { \
WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, 0); \
CRASH_WITH_INFO(__VA_ARGS__); \
} while (0)
#define ASSERT_NOT_REACHED_UNDER_CONSTEXPR_CONTEXT(...) do { \
CRASH_UNDER_CONSTEXPR_CONTEXT(); \
} while (0)
#define ASSERT_NOT_IMPLEMENTED_YET() do { \
WTFReportNotImplementedYet(__FILE__, __LINE__, WTF_PRETTY_FUNCTION); \
CRASH(); \
} while (0)
#define ASSERT_IMPLIES(condition, assertion) do { \
if ((condition) && !(assertion)) { \
WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #condition " => " #assertion); \
CRASH(); \
} \
} while (0)
#define ASSERT_UNUSED(variable, assertion, ...) ASSERT(assertion, __VA_ARGS__)
#define NO_RETURN_DUE_TO_ASSERT NO_RETURN_DUE_TO_CRASH
/* ASSERT_WITH_SECURITY_IMPLICATION
Failure of this assertion indicates a possible security vulnerability.
Class of vulnerabilities that it tests include bad casts, out of bounds
accesses, use-after-frees, etc. Please file a bug using the security
template - https://bugs.webkit.org/enter_bug.cgi?product=Security.
*/
#define ASSERT_WITH_SECURITY_IMPLICATION(assertion) \
(!(assertion) ? \
(WTFReportAssertionFailure(__FILE__, __LINE__, WTF_PRETTY_FUNCTION, #assertion), \
CRASH_WITH_SECURITY_IMPLICATION()) : \
(void)0)
#define ASSERT_WITH_SECURITY_IMPLICATION_DISABLED 0
#endif /* ASSERT_ENABLED */
我想禁用ASSERT(例如,ASSERT_ENABLED 0)在构建webkit与调试选项。(./Tools/Scripts/build-webkit --debug)特别是,查看webkit makefile中的以下代码,它似乎支持在发布模式下启用assert。
...
release+assert ra:
@$(build_target_for_each_module)
...
但是,我找不到在调试模式下禁用assert的选项。如何删除Assert?
1条答案
按热度按时间bogh5gae1#
我不确定是否有一个简单的方法来做到这一点。
我目前正在做的是在调试模式下构建时应用此修补程序
也许另一种选择是通过编译器标志传递
-DASSERT_ENABLED=0
(例如,相应地设置CXXFLAGS
和CFLAGS
环境变量)