rev feedback v1.

This commit is contained in:
HarrievG 2021-07-01 01:09:15 +02:00
parent d4db77b9ed
commit ebf53cdc21
9 changed files with 119 additions and 139 deletions

View file

@ -302,16 +302,11 @@ void idGameLocal::Clear( void ) {
#endif #endif
} }
static DebuggerArgs_t * userDebuggerArgs; static bool ( *updateDebuggerFnPtr )( idInterpreter *interpreter, idProgram *program, int instructionPointer ) = NULL;
static bool ( *checkDebuggerBreakpointFnPtr )( void ) = NULL; bool updateGameDebugger( idInterpreter *interpreter, idProgram *program, int instructionPointer ) {
bool IsGameDebuggerActive( idInterpreter *interpreter, idProgram *program, int instructionPointer ) {
bool ret = false; bool ret = false;
if ( interpreter != nullptr && program != nullptr ) { if ( interpreter != nullptr && program != nullptr ) {
userDebuggerArgs->interpreter = interpreter; ret = updateDebuggerFnPtr ? updateDebuggerFnPtr( interpreter , program, instructionPointer ) : false;
userDebuggerArgs->program = program;
userDebuggerArgs->instructionPointer = instructionPointer;
ret = checkDebuggerBreakpointFnPtr ? checkDebuggerBreakpointFnPtr( ) : false;
} }
return ret; return ret;
} }
@ -427,8 +422,7 @@ void idGameLocal::Init( void ) {
Printf( "...%d aas types\n", aasList.Num() ); Printf( "...%d aas types\n", aasList.Num() );
//debugger support //debugger support
common->GetAdditionalFunction( idCommon::FT_CheckDebuggerBreakpoint, common->GetAdditionalFunction( idCommon::FT_CheckDebuggerBreakpoint,( idCommon::FunctionPointer * ) &updateDebuggerFnPtr,NULL);
( idCommon::FunctionPointer * ) &checkDebuggerBreakpointFnPtr, ( void ** ) &userDebuggerArgs );
} }
@ -1370,7 +1364,7 @@ void idGameLocal::InitFromNewMap(const char* mapName, idRenderWorld* renderWorld
idGameLocal::InitFromSaveGame idGameLocal::InitFromSaveGame
================= =================
*/ */
bool idGameLocal::InitFromSaveGame( const char *mapName, idRenderWorld *renderWorld, idSoundWorld *soundWorld, idFile *saveGameFile, int activeEditors) { bool idGameLocal::InitFromSaveGame( const char *mapName, idRenderWorld *renderWorld, idSoundWorld *soundWorld, idFile *saveGameFile ) {
int i; int i;
int num; int num;
idEntity *ent; idEntity *ent;

View file

@ -36,7 +36,7 @@ If you have questions concerning this license or the applicable additional terms
#include "framework/FileSystem.h" #include "framework/FileSystem.h"
// HvG: Debugger support // HvG: Debugger support
extern bool IsGameDebuggerActive( idInterpreter *interpreter, idProgram *program, int instructionPointer ); extern bool updateGameDebugger( idInterpreter *interpreter, idProgram *program, int instructionPointer );
/* /*
================ ================
@ -181,6 +181,15 @@ void idInterpreter::Reset( void ) {
doneProcessing = true; doneProcessing = true;
} }
/*
================
idInterpreter::GetRegisterValue
Returns a string representation of the value of the register. This is
used primarily for the debugger and debugging
================
*/
bool idInterpreter::GetRegisterValue( const char *name, idStr &out, int scopeDepth ) { bool idInterpreter::GetRegisterValue( const char *name, idStr &out, int scopeDepth ) {
varEval_t reg; varEval_t reg;
idVarDef *d; idVarDef *d;
@ -199,8 +208,7 @@ bool idInterpreter::GetRegisterValue(const char* name, idStr& out, int scopeDept
if ( scopeDepth == callStackDepth ) { if ( scopeDepth == callStackDepth ) {
func = currentFunction; func = currentFunction;
} } else {
else {
func = callStack[ scopeDepth ].f; func = callStack[ scopeDepth ].f;
} }
if ( !func ) { if ( !func ) {
@ -217,8 +225,7 @@ bool idInterpreter::GetRegisterValue(const char* name, idStr& out, int scopeDept
{ {
scope = gameLocal.program.GetDef( NULL, funcName, scopeObj ); scope = gameLocal.program.GetDef( NULL, funcName, scopeObj );
} }
} } else {
else {
funcName = funcObject; funcName = funcObject;
scope = gameLocal.program.GetDef( NULL, func->Name(), &def_namespace ); scope = gameLocal.program.GetDef( NULL, func->Name(), &def_namespace );
scopeObj = NULL; scopeObj = NULL;
@ -255,8 +262,7 @@ bool idInterpreter::GetRegisterValue(const char* name, idStr& out, int scopeDept
case ev_float: case ev_float:
if ( reg.floatPtr ) { if ( reg.floatPtr ) {
out = va("%g", *reg.floatPtr ); out = va("%g", *reg.floatPtr );
} } else {
else {
out = "0"; out = "0";
} }
return true; return true;
@ -265,8 +271,7 @@ bool idInterpreter::GetRegisterValue(const char* name, idStr& out, int scopeDept
case ev_vector: case ev_vector:
if ( reg.vectorPtr ) { if ( reg.vectorPtr ) {
out = va( "%g,%g,%g", reg.vectorPtr->x, reg.vectorPtr->y, reg.vectorPtr->z ); out = va( "%g,%g,%g", reg.vectorPtr->x, reg.vectorPtr->y, reg.vectorPtr->z );
} } else {
else {
out = "0,0,0"; out = "0,0,0";
} }
return true; return true;
@ -275,8 +280,7 @@ bool idInterpreter::GetRegisterValue(const char* name, idStr& out, int scopeDept
case ev_boolean: case ev_boolean:
if ( reg.intPtr ) { if ( reg.intPtr ) {
out = va( "%d", *reg.intPtr ); out = va( "%d", *reg.intPtr );
} } else {
else {
out = "0"; out = "0";
} }
return true; return true;
@ -318,8 +322,7 @@ bool idInterpreter::GetRegisterValue(const char* name, idStr& out, int scopeDept
str = reinterpret_cast<const char*>( &obj->data[ reg.ptrOffset ] ); str = reinterpret_cast<const char*>( &obj->data[ reg.ptrOffset ] );
if ( !str ) { if ( !str ) {
out = "\"\""; out = "\"\"";
} } else {
else {
out = "\""; out = "\"";
out += str; out += str;
out += "\""; out += "\"";
@ -339,8 +342,7 @@ bool idInterpreter::GetRegisterValue(const char* name, idStr& out, int scopeDept
out = "\""; out = "\"";
out += reg.stringPtr; out += reg.stringPtr;
out += "\""; out += "\"";
} } else {
else {
out = "\"\""; out = "\"\"";
} }
return true; return true;
@ -1004,7 +1006,7 @@ bool idInterpreter::Execute( void ) {
// next statement // next statement
st = &gameLocal.program.GetStatement( instructionPointer ); st = &gameLocal.program.GetStatement( instructionPointer );
if ( !IsGameDebuggerActive( this, &gameLocal.program, instructionPointer ) if ( !updateGameDebugger( this, &gameLocal.program, instructionPointer )
&& g_debugScript.GetBool( ) ) && g_debugScript.GetBool( ) )
{ {
static int lastLineNumber = -1; static int lastLineNumber = -1;

View file

@ -3290,13 +3290,11 @@ static bool isDemo( void )
return sessLocal.IsDemoVersion(); return sessLocal.IsDemoVersion();
} }
static DebuggerArgs_t userDebuggerArgs; static bool updateDebugger( idInterpreter *interpreter, idProgram *program, int instructionPointer )
static bool checkForDebuggerBreakPoint( void )
{ {
if (com_editors & EDITOR_DEBUGGER) if (com_editors & EDITOR_DEBUGGER)
{ {
DebuggerServerCheckBreakpoint( userDebuggerArgs.interpreter, userDebuggerArgs.program, userDebuggerArgs.instructionPointer ); DebuggerServerCheckBreakpoint( interpreter, program, instructionPointer );
return true; return true;
} }
return false; return false;
@ -3323,9 +3321,8 @@ bool idCommonLocal::GetAdditionalFunction(idCommon::FunctionType ft, idCommon::F
return true; return true;
case idCommon::FT_CheckDebuggerBreakpoint: case idCommon::FT_CheckDebuggerBreakpoint:
*out_fnptr = (idCommon::FunctionPointer)checkForDebuggerBreakPoint; *out_fnptr = (idCommon::FunctionPointer)updateDebugger;
if (out_userArg != NULL )
*out_userArg = &userDebuggerArgs;
return true; return true;
default: default:
@ -3339,13 +3336,10 @@ idGameCallbacks gameCallbacks;
idGameCallbacks::idGameCallbacks() idGameCallbacks::idGameCallbacks()
: reloadImagesCB(NULL), reloadImagesUserArg(NULL) : reloadImagesCB(NULL), reloadImagesUserArg(NULL)
, checkBreakPointCB(NULL), checkBreakPointUserArg(NULL)
{} {}
void idGameCallbacks::Reset() void idGameCallbacks::Reset()
{ {
reloadImagesCB = NULL; reloadImagesCB = NULL;
reloadImagesUserArg = NULL; reloadImagesUserArg = NULL;
checkBreakPointCB = NULL;
checkBreakPointUserArg = NULL;
} }

View file

@ -117,12 +117,6 @@ class idLangDict;
class idInterpreter; class idInterpreter;
class idProgram; class idProgram;
struct DebuggerArgs_t {
idInterpreter *interpreter;
idProgram *program;
int instructionPointer;
};
class idCommon { class idCommon {
public: public:
virtual ~idCommon( void ) {} virtual ~idCommon( void ) {}
@ -277,6 +271,14 @@ public:
// it returns true if we're currently running the doom3 demo // it returns true if we're currently running the doom3 demo
// not relevant for mods, only for game/ aka base.dll/base.so/... // not relevant for mods, only for game/ aka base.dll/base.so/...
FT_IsDemo = 1, FT_IsDemo = 1,
// the function's signature is bool fn(void) - no arguments.
// it returns true if the game debugger is active
// relevant for mods.
FT_DebuggerActive,
// the function's signature is bool fn(idInterpreter,idProgram,int) with arguments:
// idInterpreter *interpreter, idProgram *program, int instructionPointer
// it returns true if the game debugger is active.
// relevant for mods.
FT_CheckDebuggerBreakpoint, FT_CheckDebuggerBreakpoint,
}; };

View file

@ -43,10 +43,6 @@ struct idGameCallbacks {
ReloadImagesCallback reloadImagesCB; ReloadImagesCallback reloadImagesCB;
void* reloadImagesUserArg; void* reloadImagesUserArg;
typedef void ( *CheckBreakpointCallback )( void *userArg, idInterpreter *interpreter, idProgram *program, int instructionPointer );
CheckBreakpointCallback checkBreakPointCB;
void* checkBreakPointUserArg;
idGameCallbacks(); idGameCallbacks();
// called when Game DLL is unloaded (=> the registered callbacks become invalid) // called when Game DLL is unloaded (=> the registered callbacks become invalid)

View file

@ -270,18 +270,11 @@ bool IsDoom3DemoVersion()
return ret; return ret;
} }
static DebuggerArgs_t * userDebuggerArgs; static bool ( *updateDebuggerFnPtr )( idInterpreter *interpreter, idProgram *program, int instructionPointer ) = NULL;
static bool ( *checkDebuggerBreakpointFnPtr )( void ) = NULL; bool updateGameDebugger( idInterpreter *interpreter, idProgram *program, int instructionPointer ) {
bool IsGameDebuggerActive( idInterpreter *interpreter, idProgram *program, int instructionPointer )
{
bool ret = false; bool ret = false;
if ( interpreter != nullptr && program != nullptr ) {
if (interpreter != nullptr && program != nullptr ) ret = updateDebuggerFnPtr ? updateDebuggerFnPtr( interpreter, program, instructionPointer ) : false;
{
userDebuggerArgs->interpreter = interpreter;
userDebuggerArgs->program = program;
userDebuggerArgs->instructionPointer = instructionPointer;
ret = checkDebuggerBreakpointFnPtr ? checkDebuggerBreakpointFnPtr( ) : false;
} }
return ret; return ret;
} }
@ -368,8 +361,7 @@ void idGameLocal::Init( void ) {
// DG: hack to support the Demo version of Doom3 // DG: hack to support the Demo version of Doom3
common->GetAdditionalFunction(idCommon::FT_IsDemo, (idCommon::FunctionPointer*)&isDemoFnPtr, NULL); common->GetAdditionalFunction(idCommon::FT_IsDemo, (idCommon::FunctionPointer*)&isDemoFnPtr, NULL);
//debugger support //debugger support
common->GetAdditionalFunction( idCommon::FT_CheckDebuggerBreakpoint, common->GetAdditionalFunction(idCommon::FT_CheckDebuggerBreakpoint,(idCommon::FunctionPointer*) &updateDebuggerFnPtr,NULL);
( idCommon::FunctionPointer * ) &checkDebuggerBreakpointFnPtr, (void**)&userDebuggerArgs );
} }
/* /*

View file

@ -293,7 +293,7 @@ public:
idEntityPtr<idEntity> lastGUIEnt; // last entity with a GUI, used by Cmd_NextGUI_f idEntityPtr<idEntity> lastGUIEnt; // last entity with a GUI, used by Cmd_NextGUI_f
int lastGUI; // last GUI on the lastGUIEnt int lastGUI; // last GUI on the lastGUIEnt
int editors; // Mirrored editors flags from common to determine which editors are running
// ---------------------- Public idGame Interface ------------------- // ---------------------- Public idGame Interface -------------------
idGameLocal(); idGameLocal();

View file

@ -36,7 +36,7 @@ If you have questions concerning this license or the applicable additional terms
#include "framework/FileSystem.h" #include "framework/FileSystem.h"
// HvG: Debugger support // HvG: Debugger support
extern bool IsGameDebuggerActive( idInterpreter *interpreter, idProgram *program, int instructionPointer ); extern bool updateGameDebugger( idInterpreter *interpreter, idProgram *program, int instructionPointer );
/* /*
================ ================
@ -1007,7 +1007,7 @@ bool idInterpreter::Execute( void ) {
// next statement // next statement
st = &gameLocal.program.GetStatement( instructionPointer ); st = &gameLocal.program.GetStatement( instructionPointer );
if ( !IsGameDebuggerActive( this, &gameLocal.program, instructionPointer ) if ( !updateGameDebugger( this, &gameLocal.program, instructionPointer )
&& g_debugScript.GetBool( ) ) && g_debugScript.GetBool( ) )
{ {
static int lastLineNumber = -1; static int lastLineNumber = -1;

View file

@ -147,8 +147,11 @@ Starts up the debugger server
*/ */
bool DebuggerServerInit ( void ) bool DebuggerServerInit ( void )
{ {
com_enableDebuggerServer.ClearModified( );
// Dont do this if we are in the debugger already // Dont do this if we are in the debugger already
if ( com_editors & EDITOR_DEBUGGER ) if ( gDebuggerServer != NULL
|| ( com_editors & EDITOR_DEBUGGER ) )
{ {
return false; return false;
} }
@ -168,8 +171,6 @@ bool DebuggerServerInit ( void )
return false; return false;
} }
com_enableDebuggerServer.ClearModified( );
// Start the debugger server thread // Start the debugger server thread
#if SDL_VERSION_ATLEAST(2, 0, 0) #if SDL_VERSION_ATLEAST(2, 0, 0)
gDebuggerServerThread = SDL_CreateThread( DebuggerServerThread, "DebuggerServer", NULL ); gDebuggerServerThread = SDL_CreateThread( DebuggerServerThread, "DebuggerServer", NULL );
@ -177,7 +178,6 @@ bool DebuggerServerInit ( void )
gDebuggerServerThread = SDL_CreateThread( DebuggerServerThread, NULL ); gDebuggerServerThread = SDL_CreateThread( DebuggerServerThread, NULL );
#endif #endif
return true; return true;
} }