Call raise for DebuggerBreak() in non-debug mode on OS X and define import for Plat_DebugString() on Linux and OS X.

This changes come from the 2013 SDK but they also seem to match Dota 2 code on these platforms.
This commit is contained in:
Scott Ehlert 2014-03-04 15:09:50 -06:00
parent 82969bfa84
commit 0058f609e5

View File

@ -661,7 +661,11 @@ typedef unsigned int uint;
#elif COMPILER_MSVCX360 #elif COMPILER_MSVCX360
#define DebuggerBreak() DebugBreak() #define DebuggerBreak() DebugBreak()
#elif COMPILER_GCC #elif COMPILER_GCC
#if defined( PLATFORM_CYGWIN ) || defined( PLATFORM_POSIX ) #if defined( PLATFORM_OSX )
// On OSX, SIGTRAP doesn't really stop the thread cold when debugging.
// So if being debugged, use INT3 which is precise.
#define DebuggerBreak() { if ( Plat_IsInDebugSession() ) { __asm ( "int $3" ); } else { raise(SIGTRAP); } }
#elif defined( PLATFORM_CYGWIN ) || defined( PLATFORM_POSIX )
#define DebuggerBreak() __asm__( "int $0x3;") #define DebuggerBreak() __asm__( "int $0x3;")
#else #else
#define DebuggerBreak() asm( "int3" ) #define DebuggerBreak() asm( "int3" )
@ -696,14 +700,14 @@ typedef unsigned int uint;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Returns true if debugger attached, false otherwise // Returns true if debugger attached, false otherwise
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#if defined( PLATFORM_WINDOWS ) #if defined( PLATFORM_WINDOWS ) || defined( PLATFORM_LINUX ) || defined( PLATFORM_OSX )
PLATFORM_INTERFACE bool Plat_IsInDebugSession();
PLATFORM_INTERFACE void Plat_DebugString( const tchar * ); PLATFORM_INTERFACE void Plat_DebugString( const tchar * );
#else #else
inline bool Plat_IsInDebugSession() { return false; }
#define Plat_DebugString(s) ((void)0) #define Plat_DebugString(s) ((void)0)
#endif #endif
PLATFORM_INTERFACE bool Plat_IsInDebugSession();
#define DebuggerBreakIfDebugging() if ( !Plat_IsInDebugSession() ) ; else DebuggerBreak() #define DebuggerBreakIfDebugging() if ( !Plat_IsInDebugSession() ) ; else DebuggerBreak()
@ -746,6 +750,7 @@ PLATFORM_INTERFACE void Plat_MessageBox( const char *pTitle, const tchar *pMessa
#include <alloca.h> #include <alloca.h>
#include <unistd.h> // get unlink #include <unistd.h> // get unlink
#include <signal.h>
#include <errno.h> #include <errno.h>
#endif // PLATFORM_POSIX #endif // PLATFORM_POSIX