A failed BLACK_VERIFY will generate a Crashpad crash report.

Using noinline to make sure the call to failedVerify is visible in the stack trace.
This commit is contained in:
Mathew Sutcliffe
2017-05-15 22:02:01 +01:00
parent 5b8d76c06c
commit ce6d0d8f1e
2 changed files with 16 additions and 1 deletions

View File

@@ -12,6 +12,10 @@
#include <QtGlobal>
#ifdef BLACK_USE_CRASHPAD
#include "crashpad/client/simulate_crash.h"
#endif
#if defined(Q_CC_MSVC)
#include <intrin.h>
#elif defined(Q_OS_UNIX)
@@ -36,6 +40,9 @@ namespace BlackMisc
Q_UNUSED(context);
Q_UNUSED(message);
#if defined(QT_NO_DEBUG)
# if defined(BLACK_USE_CRASHPAD)
CRASHPAD_SIMULATE_CRASH();
# endif
if (context && message)
{
CLogMessage(CLogCategory::verification()).warning("Failed to verify: %1 (%2 in %3) in %4 line %5") << condition << message << context << filename << line;

View File

@@ -14,6 +14,14 @@
#include "blackmisc/blackmiscexport.h"
//! \cond
#ifdef Q_CC_MSVC
#define BLACK_NO_INLINE __declspec(noinline)
#else
#define BLACK_NO_INLINE __attribute__((noinline))
#endif
//! \endcond
namespace BlackMisc
{
namespace Private
@@ -22,7 +30,7 @@ namespace BlackMisc
inline void noop() {}
//! \private Called by BLACK_VERIFY when the condition is false.
BLACKMISC_EXPORT void failedVerify(const char *condition, const char *filename, int line, const char *context = nullptr, const char *message = nullptr);
BLACKMISC_EXPORT BLACK_NO_INLINE void failedVerify(const char *condition, const char *filename, int line, const char *context = nullptr, const char *message = nullptr);
}
}