From e880da93bd335e59a0d4b00bfcb9f06ab4b7c847 Mon Sep 17 00:00:00 2001 From: khyperia Date: Mon, 27 Jan 2020 15:43:27 +0100 Subject: [PATCH] Make CATCH_BREAK_INTO_DEBUGGER be user-configurable --- docs/configuration.md | 13 +++++++++++++ src/catch2/catch_debugger.h | 10 ++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/configuration.md b/docs/configuration.md index f0dac1c9..38043a67 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -16,6 +16,7 @@ [Windows header clutter](#windows-header-clutter)
[Enabling stringification](#enabling-stringification)
[Disabling exceptions](#disabling-exceptions)
+[Overriding Catch's debug break (`-b`)](#overriding-catchs-debug-break--b)
Catch is designed to "just work" as much as possible. For most people the only configuration needed is telling Catch which source file should host all the implementation code (```CATCH_CONFIG_MAIN```). @@ -249,6 +250,18 @@ namespace Catch { } ``` +## Overriding Catch's debug break (`-b`) + +> [Introduced](https://github.com/catchorg/Catch2/pull/1846) in Catch X.Y.Z. + +You can override Catch2's break-into-debugger code by defining the +`CATCH_BREAK_INTO_DEBUGGER()` macro. This can be used if e.g. Catch2 does +not know your platform, or your platform is misdetected. + +The macro will be used as is, that is, `CATCH_BREAK_INTO_DEBUGGER();` +must compile and must break into debugger. + + --- [Home](Readme.md#top) diff --git a/src/catch2/catch_debugger.h b/src/catch2/catch_debugger.h index 96925fc9..8c2abef3 100644 --- a/src/catch2/catch_debugger.h +++ b/src/catch2/catch_debugger.h @@ -48,10 +48,12 @@ namespace Catch { #define CATCH_TRAP() DebugBreak() #endif -#ifdef CATCH_TRAP - #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }() -#else - #define CATCH_BREAK_INTO_DEBUGGER() []{}() +#ifndef CATCH_BREAK_INTO_DEBUGGER + #ifdef CATCH_TRAP + #define CATCH_BREAK_INTO_DEBUGGER() []{ if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } }() + #else + #define CATCH_BREAK_INTO_DEBUGGER() []{}() + #endif #endif #endif // TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED