mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-26 07:16:10 +01:00
Send to debugger console by default if running within debugger (only support on Windows at the moment)
This commit is contained in:
parent
62e23ac5a8
commit
8431fa1ec5
@ -137,6 +137,8 @@ namespace Catch
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
Config config;
|
Config config;
|
||||||
|
if( isDebuggerActive() )
|
||||||
|
config.useStream( "debug" );
|
||||||
return Main( argc, argv, config );
|
return Main( argc, argv, config );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
// The following function is taken directly from the following technical note:
|
// The following function is taken directly from the following technical note:
|
||||||
// http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html
|
// http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html
|
||||||
|
|
||||||
inline bool AmIBeingDebugged(void)
|
inline bool isDebuggerActive()
|
||||||
// Returns true if the current process is being debugged (either
|
// Returns true if the current process is being debugged (either
|
||||||
// running under the debugger or has a debugger attached post facto).
|
// running under the debugger or has a debugger attached post facto).
|
||||||
{
|
{
|
||||||
@ -74,13 +74,13 @@
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#if defined(__ppc64__) || defined(__ppc__)
|
#if defined(__ppc64__) || defined(__ppc__)
|
||||||
#define BreakIntoDebugger() \
|
#define BreakIntoDebugger() \
|
||||||
if( Catch::AmIBeingDebugged() ) \
|
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 BreakIntoDebugger() if( Catch::AmIBeingDebugged() ) {__asm__("int $3\n" : : );}
|
#define BreakIntoDebugger() if( Catch::isDebuggerActive() ) {__asm__("int $3\n" : : );}
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
inline void BreakIntoDebugger(){}
|
inline void BreakIntoDebugger(){}
|
||||||
@ -89,7 +89,11 @@
|
|||||||
#elif defined(CATCH_PLATFORM_WINDOWS)
|
#elif defined(CATCH_PLATFORM_WINDOWS)
|
||||||
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
|
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
|
||||||
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
|
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA( const char* );
|
||||||
#define BreakIntoDebugger() if (IsDebuggerPresent() ) { __debugbreak(); }
|
#define BreakIntoDebugger() if (IsDebuggerPresent() ) { __debugbreak(); }
|
||||||
|
inline bool isDebuggerActive()
|
||||||
|
{
|
||||||
|
return IsDebuggerPresent();
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
inline void BreakIntoDebugger(){}
|
inline void BreakIntoDebugger(){}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user