partial fix for dynamic natives when running on debug mode

This commit is contained in:
Borja Ferrer 2006-01-06 04:59:39 +00:00
parent 4b51565e3b
commit 0d3055e505
3 changed files with 25 additions and 16 deletions

View File

@ -935,8 +935,9 @@ int Handler::HandleModule(const char *module)
*/
cell hea_addr, *phys_addr, retval;
Debugger *pd;
DisableDebugHandler(m_pAmx);
pd = DisableDebugHandler(m_pAmx);
//temporarily set prenit
m_pAmx->flags |= AMX_FLAG_PRENIT;
@ -945,7 +946,7 @@ int Handler::HandleModule(const char *module)
amx_Release(m_pAmx, hea_addr);
m_pAmx->flags &= ~AMX_FLAG_PRENIT;
EnableDebugHandler(m_pAmx);
EnableDebugHandler(m_pAmx, pd);
if (err != AMX_ERR_NONE)
return 0;
@ -1012,7 +1013,7 @@ int Handler::HandleNative(const char *native, int index, int trap)
if (pDebugger && trap)
pDebugger->EndExec();
else if (pDebugger && !trap)
EnableDebugHandler(m_pAmx);
EnableDebugHandler(m_pAmx, pDebugger);
amx_Release(m_pAmx, hea_addr);

View File

@ -454,7 +454,8 @@ int set_amxnatives(AMX* amx, char error[128])
int idx, err;
cell retval;
DisableDebugHandler(amx);
Debugger *pd;
pd = DisableDebugHandler(amx);
if (amx_FindPublic(amx, "plugin_natives", &idx) == AMX_ERR_NONE)
{
@ -465,7 +466,7 @@ int set_amxnatives(AMX* amx, char error[128])
}
}
EnableDebugHandler(amx);
EnableDebugHandler(amx, pd);
amx->flags &= ~(AMX_FLAG_PRENIT);
@ -1783,20 +1784,24 @@ void *Module_ReqFnptr(const char *funcName)
return NULL;
}
void DisableDebugHandler(AMX *amx)
Debugger *DisableDebugHandler(AMX *amx)
{
Debugger *pd = static_cast<Debugger *>(amx->userdata[UD_DEBUGGER]);
amx->userdata[UD_DEBUGGER] = NULL;
amx->flags &= ~(AMX_FLAG_DEBUG);
amx_SetDebugHook(amx, NULL);
return pd;
}
void EnableDebugHandler(AMX *amx)
void EnableDebugHandler(AMX *amx, Debugger *pd)
{
if (amx->flags & AMX_FLAG_DEBUG)
{
if (amx->userdata[UD_DEBUGGER] != NULL)
{
amx_SetDebugHook(amx, &Debugger::DebugHook);
}
}
if (pd)
amx->flags |= AMX_FLAG_DEBUG;
amx->userdata[UD_DEBUGGER] = pd;
amx_SetDebugHook(amx, &Debugger::DebugHook);
}
#if !defined MEMORY_TEST && !defined WIN32

View File

@ -73,8 +73,11 @@ typedef enum
int CheckModules(AMX *amx, char error[128]);
const char *StrCaseStr(const char *as, const char *bs);
void DisableDebugHandler(AMX *amx);
void EnableDebugHandler(AMX *amx);
class Debugger;
Debugger *DisableDebugHandler(AMX *amx);
void EnableDebugHandler(AMX *amx, Debugger *pd);
const char* GetFileName(AMX *amx);
#endif // __MODULES_H__