Added capability to toggle debug state in plugins at runtime

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40295
This commit is contained in:
Borja Ferrer
2007-01-15 00:56:39 +00:00
parent e13c228c5a
commit 89350a1785
6 changed files with 150 additions and 14 deletions
+63 -2
View File
@@ -485,11 +485,53 @@ bool CPlugin::SetPauseState(bool paused)
return true;
}
IdentityToken_t *CPlugin::GetIdentity()
IdentityToken_t *CPlugin::GetIdentity() const
{
return m_ident;
}
bool CPlugin::ToggleDebugMode(bool debug)
{
int err;
if (!IsRunnable())
{
return false;
}
if ((debug && IsDebugging()) || (!debug && !IsDebugging()))
{
return false;
}
ICompilation *co = g_pVM->StartCompilation(m_ctx.ctx->plugin);
if (!g_pVM->SetCompilationOption(co, "debug", (debug) ? "1" : "0"))
{
return false;
}
sp_context_t *new_ctx = g_pVM->CompileToContext(co, &err);
memcpy(new_ctx->memory, m_ctx.ctx->memory, m_ctx.ctx->mem_size);
new_ctx->hp = m_ctx.ctx->hp;
new_ctx->sp = m_ctx.ctx->sp;
new_ctx->frm = m_ctx.ctx->frm;
new_ctx->dbreak = m_ctx.ctx->dbreak;
new_ctx->context = m_ctx.ctx->context;
memcpy(new_ctx->user, m_ctx.ctx->user, sizeof(m_ctx.ctx->user));
g_pVM->FreeContext(m_ctx.ctx);
m_ctx.ctx = new_ctx;
m_ctx.base->SetContext(new_ctx);
UpdateInfo();
return true;
}
bool CPlugin::IsRunnable() const
{
return (m_status <= Plugin_Paused) ? true : false;
}
/*******************
* PLUGIN ITERATOR *
*******************/
@@ -1152,7 +1194,7 @@ bool CPluginManager::TestAliasMatch(const char *alias, const char *localpath)
return true;
}
bool CPluginManager::IsLateLoadTime()
bool CPluginManager::IsLateLoadTime() const
{
return (m_AllPluginsLoaded || g_SourceMod.IsLateLoadInMap());
}
@@ -1210,3 +1252,22 @@ IPlugin *CPluginManager::PluginFromHandle(Handle_t handle, HandleError *err)
return pPlugin;
}
CPlugin *CPluginManager::GetPluginByOrder(int num)
{
if (num < 1 || num > (int)GetPluginCount())
{
return NULL;
}
CPlugin *pl;
int id = 1;
IPluginIterator *iter = GetPluginIterator();
for (; iter->MorePlugins() && id<num; iter->NextPlugin(), id++) {}
pl = (CPlugin *)(iter->GetPlugin());
iter->Release();
return pl;
}