New "debug" status for amxx plugins.

Correctly switches between amx_opcodelist and nodebug.
Fixed metamod and amxmodx GPL alignment.
Fixed debug mode not being set for non-JIT.
This commit is contained in:
David Anderson 2004-09-17 00:27:28 +00:00
parent 2d9ec5295d
commit b7c0c47c05
6 changed files with 45 additions and 31 deletions

View File

@ -72,12 +72,10 @@ int CPluginMngr::loadPluginsFromFile( const char* filename )
sscanf(line,"%s %s",pluginName, debug); sscanf(line,"%s %s",pluginName, debug);
if (!isalnum(*pluginName)) continue; if (!isalnum(*pluginName)) continue;
#ifdef JIT
if (isalnum(*debug) && strcmp(debug, "debug") == 0) if (isalnum(*debug) && strcmp(debug, "debug") == 0)
{ {
debugFlag = 1; debugFlag = 1;
} }
#endif
CPlugin* plugin = loadPlugin( pluginsDir , pluginName , error, debugFlag); CPlugin* plugin = loadPlugin( pluginsDir , pluginName , error, debugFlag);
@ -130,7 +128,16 @@ CPluginMngr::CPlugin* CPluginMngr::findPlugin(const char* name) {
const char* CPluginMngr::CPlugin::getStatus() const { const char* CPluginMngr::CPlugin::getStatus() const {
switch(status){ switch(status){
case ps_running: return "running"; case ps_running:
{
if (getAMX()->flags & AMX_FLAG_DEBUG)
{
return "debug";
} else {
return "running";
}
break;
}
case ps_paused: return "paused"; case ps_paused: return "paused";
case ps_bad_load: return "bad load"; case ps_bad_load: return "bad load";
case ps_stopped: return "stopped"; case ps_stopped: return "stopped";

View File

@ -81,6 +81,7 @@ public:
inline int getStatusCode() { return status; } inline int getStatusCode() { return status; }
inline int getId() const { return id; } inline int getId() const { return id; }
inline AMX* getAMX() { return &amx; } inline AMX* getAMX() { return &amx; }
inline const AMX* getAMX() const { return &amx; }
inline void setTitle( const char* n ) { title.assign(n); } inline void setTitle( const char* n ) { title.assign(n); }
inline void setAuthor( const char* n ) { author.assign(n); } inline void setAuthor( const char* n ) { author.assign(n); }
inline void setVersion( const char* n ) { version.assign(n); } inline void setVersion( const char* n ) { version.assign(n); }

View File

@ -1817,7 +1817,12 @@ static void *amx_opcodelist_nodebug[] = {
if ((amx->flags & AMX_FLAG_BROWSE)==AMX_FLAG_BROWSE) { if ((amx->flags & AMX_FLAG_BROWSE)==AMX_FLAG_BROWSE) {
assert(sizeof(cell)==sizeof(void *)); assert(sizeof(cell)==sizeof(void *));
assert(retval!=NULL); assert(retval!=NULL);
if (amx->flags & AMX_FLAG_DEBUG)
{
*retval=(cell)(amx_opcodelist);
} else {
*retval=(cell)(amx_opcodelist_nodebug); *retval=(cell)(amx_opcodelist_nodebug);
}
return 0; return 0;
} /* if */ } /* if */
@ -2223,10 +2228,6 @@ static void *amx_opcodelist_nodebug[] = {
cip=(cell *)(code+(int)offs); cip=(cell *)(code+(int)offs);
NEXT(cip); NEXT(cip);
op_ret_nodebug: op_ret_nodebug:
if (tracer)
{
(tracer)(amx, 1);
}
POP(frm); POP(frm);
POP(offs); POP(offs);
/* verify the return address */ /* verify the return address */
@ -2248,10 +2249,6 @@ static void *amx_opcodelist_nodebug[] = {
stk+= *(cell *)(data+(int)stk) + sizeof(cell); /* remove parameters from the stack */ stk+= *(cell *)(data+(int)stk) + sizeof(cell); /* remove parameters from the stack */
NEXT(cip); NEXT(cip);
op_retn_nodebug: op_retn_nodebug:
if (tracer)
{
(tracer)(amx, 1);
}
POP(frm); POP(frm);
POP(offs); POP(offs);
/* verify the return address */ /* verify the return address */
@ -2269,10 +2266,6 @@ static void *amx_opcodelist_nodebug[] = {
cip=JUMPABS(code, cip); /* jump to the address */ cip=JUMPABS(code, cip); /* jump to the address */
NEXT(cip); NEXT(cip);
op_call_nodebug: op_call_nodebug:
if (tracer)
{
(tracer)(amx, 2);
}
PUSH(((unsigned char *)cip-code)+sizeof(cell));/* push address behind instruction */ PUSH(((unsigned char *)cip-code)+sizeof(cell));/* push address behind instruction */
cip=JUMPABS(code, cip); /* jump to the address */ cip=JUMPABS(code, cip); /* jump to the address */
NEXT(cip); NEXT(cip);
@ -2285,10 +2278,6 @@ static void *amx_opcodelist_nodebug[] = {
cip=(cell *)(code+(int)pri); cip=(cell *)(code+(int)pri);
NEXT(cip); NEXT(cip);
op_call_pri_nodebug: op_call_pri_nodebug:
if (tracer)
{
(tracer)(amx, 2);
}
PUSH((unsigned char *)cip-code); PUSH((unsigned char *)cip-code);
cip=(cell *)(code+(int)pri); cip=(cell *)(code+(int)pri);
NEXT(cip); NEXT(cip);
@ -2849,7 +2838,12 @@ int AMXAPI amx_Exec(AMX *amx, cell *retval, int index, int numparams, ...)
*/ */
*retval=(cell)amx_opcodelist; *retval=(cell)amx_opcodelist;
#else #else
if (amx->flags & AMX_FLAG_DEBUG)
{
*retval=(cell)(amx_opcodelist);
} else {
*retval=(cell)(amx_opcodelist_nodebug); *retval=(cell)(amx_opcodelist_nodebug);
}
#endif #endif
return 0; return 0;
} /* if */ } /* if */

View File

@ -117,8 +117,14 @@
_dbgaddr EQU 38h ;DD ? _dbgaddr EQU 38h ;DD ?
_dbgparam EQU 3ch ;DD ? _dbgparam EQU 3ch ;DD ?
_dbgname EQU 40h ;DD ? _dbgname EQU 40h ;DD ?
_usertags EQU 44h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h) _usertags1 EQU 44h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
_userdata EQU 54h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h) _usertags2 EQU 44h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
_usertags3 EQU 44h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
_usertags4 EQU 44h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
_userdata1 EQU 54h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
_userdata2 EQU 54h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
_userdata3 EQU 54h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
_userdata4 EQU 54h ;DD 4 DUP (?) ; 4 = AMX_USERNUM (#define'd in amx.h)
_error EQU 64h ;DD ? _error EQU 64h ;DD ?
_pri EQU 68h ;DD ? _pri EQU 68h ;DD ?
_alt EQU 6ch ;DD ? _alt EQU 6ch ;DD ?
@ -171,6 +177,8 @@
AMX_FLAG_CHAR16 EQU 0001h ; characters are 16-bit AMX_FLAG_CHAR16 EQU 0001h ; characters are 16-bit
AMX_FLAG_DEBUG EQU 0002h ; symbolic info. available AMX_FLAG_DEBUG EQU 0002h ; symbolic info. available
AMX_FLAG_LINEOPS EQU 0020h ; line op information
AMX_FLAG_TRACED EQU 0040h ;
AMX_FLAG_BROWSE EQU 4000h AMX_FLAG_BROWSE EQU 4000h
AMX_FLAG_RELOC EQU 8000h ; jump/call addresses relocated AMX_FLAG_RELOC EQU 8000h ; jump/call addresses relocated

View File

@ -148,7 +148,7 @@ int load_amxscript(AMX *amx, void **program, const char *filename, char error[64
return (amx->error = AMX_ERR_FORMAT); return (amx->error = AMX_ERR_FORMAT);
} }
if ( ((int)CVAR_GET_FLOAT("amx_debug") >= 2 || (debug && (int)CVAR_GET_FLOAT("amx_debug"))) ) if ( (int)CVAR_GET_FLOAT("amx_debug") >= 2 || debug)
{ {
//automatic debug mode //automatic debug mode
hdr->flags |= AMX_FLAG_LINEOPS; hdr->flags |= AMX_FLAG_LINEOPS;
@ -1200,7 +1200,11 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
} else { } else {
GenericError(amx, err, line, buf, dbg->files[file]); GenericError(amx, err, line, buf, dbg->files[file]);
} }
AMXXLOG_Log("[AMXX] %s %s", buf, vbuf); AMXXLOG_Log("[AMXX] %s", buf);
if (*vbuf)
{
AMXXLOG_Log("[AMXX] %s", vbuf);
}
AMXXLOG_Log("[AMXX] Debug Trace =>"); AMXXLOG_Log("[AMXX] Debug Trace =>");
//log the error right away //log the error right away
while (t != NULL) while (t != NULL)
@ -1209,9 +1213,9 @@ void LogError(AMX *amx, int err, const char *fmt, ...)
file = t->file; file = t->file;
if (file >= dbg->numFiles) if (file >= dbg->numFiles)
{ {
AMXXLOG_Log("[AMXX] [%d] Line %d, Plugin \"%s\"", i++, line, g_plugins.findPluginFast(amx)->getName()); AMXXLOG_Log("[AMXX] [%d] Line %d, File \"%s\"", i++, line, g_plugins.findPluginFast(amx)->getName());
} else { } else {
AMXXLOG_Log("[AMXX] [%d] Line %d, Plugin \"%s\"", i++, line, dbg->files[file]); AMXXLOG_Log("[AMXX] [%d] Line %d, File \"%s\"", i++, line, dbg->files[file]);
} }
if (tracer) if (tracer)
(tracer)(amx, 1); //pop (tracer)(amx, 1); //pop