mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 07:15:35 +08:00
BLACK_AUDIT macro for paranoid checks on data consistency
Summary: Triggers a breakpoint when the debugger is attached to a debug build. Otherwise, logs a warning. Related: T101 Reviewers: kbasan, rwinklmeier Reviewed By: kbasan Subscribers: jenkins Tags: #swift_pilot_client Differential Revision: https://dev.swift-project.org/D35
This commit is contained in:
@@ -9,7 +9,6 @@
|
||||
|
||||
#include "blackmisc/verify.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
#ifdef BLACK_USE_CRASHPAD
|
||||
@@ -18,7 +17,7 @@
|
||||
|
||||
#if defined(Q_CC_MSVC)
|
||||
#include <intrin.h>
|
||||
#elif defined(Q_OS_UNIX)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(Q_CC_CLANG)
|
||||
@@ -32,14 +31,36 @@ namespace BlackMisc
|
||||
namespace Private
|
||||
{
|
||||
// cppcheck-suppress unusedFunction
|
||||
void failedVerify(const char *condition, const char *filename, int line, const char *context, const char *message)
|
||||
void failedVerify(const char *condition, const char *filename, int line, const char *context, const char *message, bool audit)
|
||||
{
|
||||
Q_UNUSED(condition);
|
||||
Q_UNUSED(filename);
|
||||
Q_UNUSED(line);
|
||||
Q_UNUSED(context);
|
||||
Q_UNUSED(message);
|
||||
#if defined(QT_NO_DEBUG)
|
||||
Q_UNUSED(audit);
|
||||
|
||||
#if defined(QT_DEBUG)
|
||||
# if defined(Q_CC_MSVC)
|
||||
if (!audit || IsDebuggerPresent())
|
||||
{
|
||||
__debugbreak();
|
||||
return;
|
||||
}
|
||||
# elif defined(BLACK_HAS_BUILTIN_DEBUGGER)
|
||||
__builtin_debugger();
|
||||
# elif defined(Q_PROCESSOR_X86)
|
||||
__asm__ volatile("int $0x03");
|
||||
# elif defined(Q_PROCESSOR_ARM)
|
||||
__asm__ volatile(".inst 0xe7f001f0");
|
||||
# elif defined(Q_OS_UNIX)
|
||||
raise(SIGTRAP);
|
||||
# else
|
||||
Q_ASSERT(false);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(QT_NO_DEBUG) || defined(Q_CC_MSVC)
|
||||
# if defined(BLACK_USE_CRASHPAD)
|
||||
CRASHPAD_SIMULATE_CRASH();
|
||||
# endif
|
||||
@@ -51,18 +72,6 @@ namespace BlackMisc
|
||||
{
|
||||
CLogMessage(CLogCategory::verification()).warning("Failed to verify: %1 in %2 line %3") << condition << filename << line;
|
||||
}
|
||||
#elif defined(Q_CC_MSVC)
|
||||
__debugbreak();
|
||||
#elif defined(BLACK_HAS_BUILTIN_DEBUGGER)
|
||||
__builtin_debugger();
|
||||
#elif defined(Q_PROCESSOR_X86)
|
||||
__asm__ volatile("int $0x03");
|
||||
#elif defined(Q_PROCESSOR_ARM)
|
||||
__asm__ volatile(".inst 0xe7f001f0");
|
||||
#elif defined(Q_OS_UNIX)
|
||||
raise(SIGTRAP);
|
||||
#else
|
||||
Q_ASSERT(false);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user