mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 15:26:11 +01:00
Refactor CATCH_BREAK_INTO_DEBUGGER() to avoid repetition
Don't duplicate Catch::isDebuggerActive() check many times, do it just once in CATCH_BREAK_INTO_DEBUGGER() definition and use a separate CATCH_TRAP() macro for the really platform-dependent part.
This commit is contained in:
parent
b634e592da
commit
25d017763b
@ -25,29 +25,29 @@ namespace Catch{
|
|||||||
// http://cocoawithlove.com/2008/03/break-into-debugger.html
|
// http://cocoawithlove.com/2008/03/break-into-debugger.html
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#if defined(__ppc64__) || defined(__ppc__)
|
#if defined(__ppc64__) || defined(__ppc__)
|
||||||
#define CATCH_BREAK_INTO_DEBUGGER() \
|
#define CATCH_TRAP() \
|
||||||
if( Catch::isDebuggerActive() ) { \
|
|
||||||
__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
|
__asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \
|
||||||
: : : "memory","r0","r3","r4" ); \
|
: : : "memory","r0","r3","r4" )
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
#define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );}
|
#define CATCH_TRAP() _asm__("int $3\n" : : )
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#elif defined(CATCH_PLATFORM_LINUX)
|
#elif defined(CATCH_PLATFORM_LINUX)
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { raise(SIGTRAP); }
|
#define CATCH_TRAP() raise(SIGTRAP)
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
#define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { __debugbreak(); }
|
#define CATCH_TRAP() __debugbreak()
|
||||||
#elif defined(__MINGW32__)
|
#elif defined(__MINGW32__)
|
||||||
extern "C" __declspec(dllimport) void __stdcall DebugBreak();
|
extern "C" __declspec(dllimport) void __stdcall DebugBreak();
|
||||||
#define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { DebugBreak(); }
|
#define CATCH_TRAP() DebugBreak()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CATCH_BREAK_INTO_DEBUGGER
|
#ifdef CATCH_TRAP
|
||||||
#define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue();
|
#define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); }
|
||||||
|
#else
|
||||||
|
#define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED
|
#endif // TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED
|
||||||
|
Loading…
Reference in New Issue
Block a user