Improve plugin console diagnostics.

This commit is contained in:
David Anderson 2015-09-20 13:51:24 -07:00
parent 87e9dee78b
commit 59623695af
2 changed files with 36 additions and 63 deletions

View File

@ -1913,73 +1913,44 @@ void CPluginManager::OnRootConsoleCommand(const char *cmdname, const ICommandArg
const sm_plugininfo_t *info = pl->GetPublicInfo();
rootmenu->ConsolePrint(" Filename: %s", pl->GetFilename());
if (pl->GetStatus() <= Plugin_Error || pl->GetStatus() == Plugin_Failed)
{
if (IS_STR_FILLED(info->name))
{
if (pl->GetStatus() != Plugin_BadLoad) {
if (IS_STR_FILLED(info->name)) {
if (IS_STR_FILLED(info->description))
{
rootmenu->ConsolePrint(" Title: %s (%s)", info->name, info->description);
} else {
else
rootmenu->ConsolePrint(" Title: %s", info->name);
}
}
if (IS_STR_FILLED(info->author))
{
if (IS_STR_FILLED(info->author)) {
rootmenu->ConsolePrint(" Author: %s", info->author);
}
if (IS_STR_FILLED(info->version))
{
if (IS_STR_FILLED(info->version)) {
rootmenu->ConsolePrint(" Version: %s", info->version);
}
if (IS_STR_FILLED(info->url))
{
if (IS_STR_FILLED(info->url)) {
rootmenu->ConsolePrint(" URL: %s", info->url);
}
if (pl->GetStatus() == Plugin_Error || pl->GetStatus() == Plugin_Failed)
{
if (pl->IsInErrorState()) {
rootmenu->ConsolePrint(" Error: %s", pl->GetErrorMsg());
} else {
rootmenu->ConsolePrint(" Status: running");
}
else
{
if (pl->GetStatus() == Plugin_Running)
{
rootmenu->ConsolePrint(" Status: running");
}
else
{
rootmenu->ConsolePrint(" Status: not running");
}
}
if (pl->GetFileVersion() >= 3)
{
if (pl->GetFileVersion() >= 3) {
rootmenu->ConsolePrint(" Timestamp: %s", pl->GetDateTime());
}
unsigned char *pCodeHash = pl->GetRuntime()->GetCodeHash();
unsigned char *pDataHash = pl->GetRuntime()->GetDataHash();
if (IPluginRuntime *runtime = pl->GetRuntime()) {
unsigned char *pCodeHash = runtime->GetCodeHash();
unsigned char *pDataHash = runtime->GetDataHash();
char combinedHash[33];
for (int i = 0; i < 16; i++)
ke::SafeSprintf(combinedHash + (i * 2), 3, "%02x", pCodeHash[i] ^ pDataHash[i]);
char combinedHash[33];
for (int i = 0; i < 16; i++)
ke::SafeSprintf(combinedHash + (i * 2), 3, "%02x", pCodeHash[i] ^ pDataHash[i]);
rootmenu->ConsolePrint(" Hash: %s", combinedHash);
}
else
{
rootmenu->ConsolePrint(" Load error: %s", pl->GetErrorMsg());
if (pl->GetStatus() < Plugin_Created)
{
rootmenu->ConsolePrint(" File info: (title \"%s\") (version \"%s\")",
info->name ? info->name : "<none>",
info->version ? info->version : "<none>");
if (IS_STR_FILLED(info->url))
{
rootmenu->ConsolePrint(" File URL: %s", info->url);
}
rootmenu->ConsolePrint(" Hash: %s", combinedHash);
}
} else {
rootmenu->ConsolePrint(" Load error: %s", pl->GetErrorMsg());
}
return;
}
else if (strcmp(cmd, "refresh") == 0)

View File

@ -237,8 +237,10 @@ public:
return m_EnteredSecondPass;
}
bool HasErrorOrFail() const {
return m_status == Plugin_Error || m_status == Plugin_Failed;
bool IsInErrorState() const {
if (m_status == Plugin_Running || m_status == Plugin_Loaded)
return false;
return true;
}
bool TryCompile();