1 #include "CDbgReporter.h"
5 void CDbgReporter::OnSourceModAllInitialized()
7 g_pSourcePawn->SetDebugListener(this);
10 void CDbgReporter::OnContextExecuteError(IPluginContext *ctx, IContextTrace *error)
13 const char *plname = g_PluginSys.FindPluginByContext(ctx->GetContext())->GetFilename();
14 int n_err = error->GetErrorCode();
16 if (n_err != SP_ERROR_NATIVE)
18 g_Logger.LogError("[SOURCEMOD] Plugin \"%s\" encountered error %d: %s",
21 error->GetErrorString());
24 if ((lastname=error->GetLastNative(NULL)) != NULL)
27 if ((custerr=error->GetCustomErrorString()) != NULL)
29 g_Logger.LogError("[SOURCEMOD] Native \"%s\" reported: \"%s\"", lastname, custerr);
31 g_Logger.LogError("[SOURCEMOD] Native \"%s\" encountered a generic error.", lastname);
35 if (!error->DebugInfoAvailable())
37 g_Logger.LogError("[SOURCEMOD] Debug mode is not enabled for this plugin.");
38 g_Logger.LogError("[SOURCEMOD] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on",
39 _GetPluginIndex(ctx));
43 CallStackInfo stk_info;
45 g_Logger.LogError("[SOURCEMOD] Displaying call stack trace:");
46 while (error->GetTraceInfo(&stk_info))
48 g_Logger.LogError("[SOURCEMOD] [%d] Line %d, %s::%s()",
56 int CDbgReporter::_GetPluginIndex(IPluginContext *ctx)
59 IPluginIterator *iter = g_PluginSys.GetPluginIterator();
61 for (; iter->MorePlugins(); iter->NextPlugin(), id++)
63 IPlugin *pl = iter->GetPlugin();
64 if (pl->GetBaseContext() == ctx)