forked from ValveSoftware/source-sdk-2013
-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
82bc30c
commit e6cd644
Showing
15 changed files
with
21,490 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
//----------------------------------------------------------------------- | ||
// github.com/samisalreadytaken/sqdbg | ||
//----------------------------------------------------------------------- | ||
// | ||
// Squirrel Debugger | ||
// | ||
|
||
#ifndef SQDBG_H | ||
#define SQDBG_H | ||
|
||
#include <squirrel.h> | ||
|
||
#define SQDBG_SV_API_VER 1 | ||
|
||
struct SQDebugServer; | ||
typedef SQDebugServer* HSQDEBUGSERVER; | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
// Create and attach a new debugger | ||
// Memory is owned by the VM, it is freed when the VM dies or | ||
// the debugger is disconnected via sqdbg_destroy_debugger() | ||
extern HSQDEBUGSERVER sqdbg_attach_debugger( HSQUIRRELVM vm ); | ||
|
||
// Detach and destroy the debugger attached to this VM | ||
// Invalidates the handle returned from sqdbg_attach_debugger() | ||
extern void sqdbg_destroy_debugger( HSQUIRRELVM vm ); | ||
|
||
// Open specified port and allow client connections | ||
// If port is 0, the system will choose a unique available port | ||
// Returns 0 on success | ||
extern int sqdbg_listen_socket( HSQDEBUGSERVER dbg, unsigned short port ); | ||
|
||
// Process client connections and incoming messages | ||
// Blocks on script breakpoints while a client is connected | ||
extern void sqdbg_frame( HSQDEBUGSERVER dbg ); | ||
|
||
// Copies the script to be able to source it to debugger clients | ||
extern void sqdbg_on_script_compile( HSQDEBUGSERVER dbg, const SQChar *script, SQInteger size, | ||
const SQChar *sourcename, SQInteger sourcenamelen ); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif // SQDBG_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
//----------------------------------------------------------------------- | ||
// github.com/samisalreadytaken/sqdbg | ||
//----------------------------------------------------------------------- | ||
// | ||
|
||
#include <tier0/dbg.h> | ||
|
||
#if 0 | ||
#ifndef SQDBG_DEBUG_H | ||
#define SQDBG_DEBUG_H | ||
|
||
#ifdef _DEBUG | ||
#ifdef _WIN32 | ||
#include <crtdbg.h> | ||
|
||
extern "C" WINBASEAPI BOOL WINAPI IsDebuggerPresent( VOID ); | ||
|
||
static inline const char *GetModuleBaseName() | ||
{ | ||
static char module[MAX_PATH]; | ||
DWORD len = GetModuleFileNameA( NULL, module, sizeof(module) ); | ||
|
||
if ( len != 0 ) | ||
{ | ||
for ( char *pBase = module + len; pBase-- > module; ) | ||
{ | ||
if ( *pBase == '\\' ) | ||
return pBase + 1; | ||
} | ||
|
||
return module; | ||
} | ||
|
||
return ""; | ||
} | ||
|
||
#define DebuggerBreak() do { if ( IsDebuggerPresent() ) __debugbreak(); } while(0); | ||
|
||
#define Assert( x ) \ | ||
do { \ | ||
__CAT( L, __LINE__ ): \ | ||
if ( !(x) && (1 == _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, GetModuleBaseName(), #x)) ) \ | ||
{ \ | ||
if ( !IsDebuggerPresent() ) \ | ||
goto __CAT( L, __LINE__ ); \ | ||
__debugbreak(); \ | ||
} \ | ||
} while(0) | ||
|
||
#define AssertMsg( x, msg ) \ | ||
do { \ | ||
__CAT( L, __LINE__ ): \ | ||
if ( !(x) && (1 == _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, GetModuleBaseName(), msg)) ) \ | ||
{ \ | ||
if ( !IsDebuggerPresent() ) \ | ||
goto __CAT( L, __LINE__ ); \ | ||
__debugbreak(); \ | ||
} \ | ||
} while(0) | ||
|
||
#define AssertMsg1( x, msg, a1 ) \ | ||
do { \ | ||
__CAT( L, __LINE__ ): \ | ||
if ( !(x) && (1 == _CrtDbgReport(_CRT_ASSERT, __FILE__, __LINE__, GetModuleBaseName(), msg, a1)) ) \ | ||
{ \ | ||
if ( !IsDebuggerPresent() ) \ | ||
goto __CAT( L, __LINE__ ); \ | ||
__debugbreak(); \ | ||
} \ | ||
} while(0) | ||
#else | ||
extern "C" int printf(const char *, ...); | ||
|
||
#define DebuggerBreak() asm("int3") | ||
|
||
#define Assert( x ) \ | ||
do { \ | ||
if ( !(x) ) \ | ||
{ \ | ||
::printf("Assertion failed %s:%d: %s\n", __FILE__, __LINE__, #x); \ | ||
DebuggerBreak(); \ | ||
} \ | ||
} while(0) | ||
|
||
#define AssertMsg( x, msg ) \ | ||
do { \ | ||
if ( !(x) ) \ | ||
{ \ | ||
::printf("Assertion failed %s:%d: %s\n", __FILE__, __LINE__, msg); \ | ||
DebuggerBreak(); \ | ||
} \ | ||
} while(0) | ||
|
||
#define AssertMsg1( x, msg, a1 ) \ | ||
do { \ | ||
if ( !(x) ) \ | ||
{ \ | ||
::printf("Assertion failed %s:%d: ", __FILE__, __LINE__); \ | ||
::printf(msg, a1); \ | ||
::printf("\n"); \ | ||
DebuggerBreak(); \ | ||
} \ | ||
} while(0) | ||
#endif | ||
#define Verify(x) Assert(x) | ||
#else | ||
#define DebuggerBreak() ((void)0) | ||
#define Assert( x ) ((void)0) | ||
#define AssertMsg( x, msg ) ((void)0) | ||
#define AssertMsg1( x, msg, a1 ) ((void)0) | ||
#define Verify(x) x | ||
#endif // _DEBUG | ||
|
||
#ifdef _WIN32 | ||
#define UNREACHABLE() do { Assert(!"UNREACHABLE"); __assume(0); } while(0); | ||
#define UNREACHABLE_RET(r) UNREACHABLE() | ||
#else | ||
#define UNREACHABLE() do { Assert(!"UNREACHABLE"); __builtin_unreachable(); } while(0); | ||
#define UNREACHABLE_RET(r) UNREACHABLE(); return (r); | ||
#endif | ||
|
||
#ifndef assert | ||
#define assert(x) Assert(x) | ||
#endif | ||
|
||
#endif // SQDBG_DEBUG_H | ||
#endif |
Oops, something went wrong.