Renamed DebugBreak to avoid collision and implemented in terms of __debugbreak() on Windows

This commit is contained in:
Phil Nash 2011-02-16 18:58:15 +00:00
parent 7d65a8c612
commit dea778138e
2 changed files with 10 additions and 10 deletions

View File

@ -443,7 +443,7 @@ inline bool isTrue
#define INTERNAL_CATCH_ACCEPT_RESULT( result, stopOnFailure ) \ #define INTERNAL_CATCH_ACCEPT_RESULT( result, stopOnFailure ) \
if( Catch::ResultAction::Value action = Catch::Hub::getResultCapture().acceptResult( result ) ) \ if( Catch::ResultAction::Value action = Catch::Hub::getResultCapture().acceptResult( result ) ) \
{ \ { \
if( action == Catch::ResultAction::DebugFailed ) DebugBreak(); \ if( action == Catch::ResultAction::DebugFailed ) BreakIntoDebugger(); \
if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \ if( Catch::isTrue( stopOnFailure ) ) throw Catch::TestFailureException(); \
} }

View File

@ -8,8 +8,7 @@
* Distributed under the Boost Software License, Version 1.0. (See accompanying * Distributed under the Boost Software License, Version 1.0. (See accompanying
* file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
* *
* Provides a DebugBreak() macro for platforms other than Windows * Provides a BreakIntoDebugger() macro for Windows and Mac (so far)
* (currently only Macs are supported)
*/ */
#ifndef TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED #ifndef TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED
@ -68,21 +67,22 @@
// 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 DebugBreak() \ #define BreakIntoDebugger() \
if( Catch::AmIBeingDebugged() ) \ if( Catch::AmIBeingDebugged() ) \
{ \ { \
__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 DebugBreak() if( Catch::AmIBeingDebugged() ) {__asm__("int $3\n" : : );} #define BreakIntoDebugger() if( Catch::AmIBeingDebugged() ) {__asm__("int $3\n" : : );}
#endif #endif
#endif #endif
#endif #elif defined(__WIN32__) && defined(_MSC_VER)
extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent();
#ifndef DebugBreak #define BreakIntoDebugger() if (IsDebuggerPresent() ) { __debugbreak(); }
inline void DebugBreak(){} #else
inline void BreakIntoDebugger(){}
#endif #endif
inline void writeToDebugConsole( const std::string& text ) inline void writeToDebugConsole( const std::string& text )
@ -97,4 +97,4 @@ inline void writeToDebugConsole( const std::string& text )
//#endif //#endif
} }
#endif // TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED #endif // TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED