Optimized forwards, now paused functions are stored in a temp list so we dont have to check if they're runnable on each function execution.
2 * ===============================================================
3 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
4 * ===============================================================
6 * This file is not open source and may not be copied without explicit
7 * written permission of AlliedModders LLC. This file may not be redistributed
8 * in whole or significant part.
9 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
14 #include "CDbgReporter.h"
16 #include "PluginSys.h"
18 void CDbgReporter::OnSourceModAllInitialized()
20 g_pSourcePawn->SetDebugListener(this);
23 void CDbgReporter::OnContextExecuteError(IPluginContext *ctx, IContextTrace *error)
26 const char *plname = g_PluginSys.FindPluginByContext(ctx->GetContext())->GetFilename();
27 int n_err = error->GetErrorCode();
29 if (n_err != SP_ERROR_NATIVE)
31 g_Logger.LogError("[SM] Plugin \"%s\" encountered error %d: %s",
34 error->GetErrorString());
37 if ((lastname=error->GetLastNative(NULL)) != NULL)
40 if ((custerr=error->GetCustomErrorString()) != NULL)
42 g_Logger.LogError("[SM] Native \"%s\" reported: \"%s\"", lastname, custerr);
44 g_Logger.LogError("[SM] Native \"%s\" encountered a generic error.", lastname);
48 if (!error->DebugInfoAvailable())
50 g_Logger.LogError("[SM] Debug mode is not enabled for this plugin.");
51 g_Logger.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on",
52 _GetPluginIndex(ctx));
56 CallStackInfo stk_info;
58 g_Logger.LogError("[SM] Displaying call stack trace:");
59 while (error->GetTraceInfo(&stk_info))
61 g_Logger.LogError("[SM] [%d] Line %d, %s::%s()",
69 int CDbgReporter::_GetPluginIndex(IPluginContext *ctx)
72 IPluginIterator *iter = g_PluginSys.GetPluginIterator();
74 for (; iter->MorePlugins(); iter->NextPlugin(), id++)
76 IPlugin *pl = iter->GetPlugin();
77 if (pl->GetBaseContext() == ctx)