# HG changeset patch # User David Anderson # Date 1361059020 28800 # Node ID d8a07e40bcb60b605a766ee7f851d2b7b81036d1 # Parent 47e1ee9cea862b60340c1ababd19a05b0f55579a Move DebugReporter from core to logic (bug 5607, r=psychonic). diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/AMBuilder --- a/core/AMBuilder Sat Feb 16 15:52:11 2013 -0800 +++ b/core/AMBuilder Sat Feb 16 15:57:00 2013 -0800 @@ -86,7 +86,6 @@ 'smn_core.cpp', 'smn_hudtext.cpp', 'smn_usermsgs.cpp', - 'DebugReporter.cpp', 'MenuStyle_Base.cpp', 'ShareSys.cpp', 'smn_database.cpp', diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/DebugReporter.cpp --- a/core/DebugReporter.cpp Sat Feb 16 15:52:11 2013 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,201 +0,0 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourceMod - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. - * ============================================================================= - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 3.0, as published by the - * Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - * - * As a special exception, AlliedModders LLC gives you permission to link the - * code of this program (as well as its derivative works) to "Half-Life 2," the - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software - * by the Valve Corporation. You must obey the GNU General Public License in - * all respects for all other code used. Additionally, AlliedModders LLC grants - * this exception to all derivative works. AlliedModders LLC defines further - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), - * or . - * - * Version: $Id$ - */ - -#include "DebugReporter.h" -#include "Logger.h" -#include "PluginSys.h" -#include "sm_stringutil.h" - -DebugReport g_DbgReporter; - -void DebugReport::OnSourceModAllInitialized() -{ - g_pSourcePawn->SetDebugListener(this); -} - -void DebugReport::OnDebugSpew(const char *msg, ...) -{ - va_list ap; - char buffer[512]; - - va_start(ap, msg); - UTIL_FormatArgs(buffer, sizeof(buffer), msg, ap); - va_end(ap); - - g_Logger.LogMessage("[SM] %s", buffer); -} - -void DebugReport::GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...) -{ - va_list ap; - - va_start(ap, message); - GenerateErrorVA(ctx, func_idx, err, message, ap); - va_end(ap); -} - -void DebugReport::GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, const char *message, va_list ap) -{ - char buffer[512]; - UTIL_FormatArgs(buffer, sizeof(buffer), message, ap); - - const char *plname = g_PluginSys.FindPluginByContext(ctx->GetContext())->GetFilename(); - const char *error = g_pSourcePawn2->GetErrorString(err); - - if (error) - { - g_Logger.LogError("[SM] Plugin \"%s\" encountered error %d: %s", plname, err, error); - } else { - g_Logger.LogError("[SM] Plugin \"%s\" encountered unknown error %d", plname, err); - } - - g_Logger.LogError("[SM] %s", buffer); - - if (func_idx != -1) - { - if (func_idx & 1) - { - func_idx >>= 1; - sp_public_t *function; - if (ctx->GetRuntime()->GetPublicByIndex(func_idx, &function) == SP_ERROR_NONE) - { - g_Logger.LogError("[SM] Unable to call function \"%s\" due to above error(s).", function->name); - } - } - } -} - -void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr, int err, const char *message, ...) -{ - va_list ap; - char buffer[512]; - - va_start(ap, message); - UTIL_FormatArgs(buffer, sizeof(buffer), message, ap); - va_end(ap); - - const char *plname = g_PluginSys.FindPluginByContext(pContext->GetContext())->GetFilename(); - const char *error = g_pSourcePawn2->GetErrorString(err); - - if (error) - { - g_Logger.LogError("[SM] Plugin \"%s\" encountered error %d: %s", plname, err, error); - } else { - g_Logger.LogError("[SM] Plugin \"%s\" encountered unknown error %d", plname, err); - } - - g_Logger.LogError("[SM] %s", buffer); - - IPluginDebugInfo *pDebug; - if ((pDebug = pContext->GetRuntime()->GetDebugInfo()) == NULL) - { - g_Logger.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); - g_Logger.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", - _GetPluginIndex(pContext)); - return; - } - - const char *name; - if (pDebug->LookupFunction(code_addr, &name) == SP_ERROR_NONE) - { - g_Logger.LogError("[SM] Unable to call function \"%s\" due to above error(s).", name); - } else { - g_Logger.LogError("[SM] Unable to call function (name unknown, address \"%x\").", code_addr); - } -} - -void DebugReport::OnContextExecuteError(IPluginContext *ctx, IContextTrace *error) -{ - const char *lastname; - const char *plname = g_PluginSys.FindPluginByContext(ctx->GetContext())->GetFilename(); - int n_err = error->GetErrorCode(); - - if (n_err != SP_ERROR_NATIVE) - { - g_Logger.LogError("[SM] Plugin encountered error %d: %s", - n_err, - error->GetErrorString()); - } - - if ((lastname=error->GetLastNative(NULL)) != NULL) - { - const char *custerr; - if ((custerr=error->GetCustomErrorString()) != NULL) - { - g_Logger.LogError("[SM] Native \"%s\" reported: %s", lastname, custerr); - } else { - g_Logger.LogError("[SM] Native \"%s\" encountered a generic error.", lastname); - } - } - - if (!error->DebugInfoAvailable()) - { - g_Logger.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); - g_Logger.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", - _GetPluginIndex(ctx)); - return; - } - - CallStackInfo stk_info; - int i = 0; - g_Logger.LogError("[SM] Displaying call stack trace for plugin \"%s\":", plname); - while (error->GetTraceInfo(&stk_info)) - { - g_Logger.LogError("[SM] [%d] Line %d, %s::%s()", - i++, - stk_info.line, - stk_info.filename, - stk_info.function); - } -} - -int DebugReport::_GetPluginIndex(IPluginContext *ctx) -{ - int id = 1; - IPluginIterator *iter = g_PluginSys.GetPluginIterator(); - - for (; iter->MorePlugins(); iter->NextPlugin(), id++) - { - IPlugin *pl = iter->GetPlugin(); - if (pl->GetBaseContext() == ctx) - { - iter->Release(); - return id; - } - } - - iter->Release(); - - /* If we don't know which plugin this is, it's one being loaded. Fake its index for now. */ - - return g_PluginSys.GetPluginCount() + 1; -} - diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/DebugReporter.h --- a/core/DebugReporter.h Sat Feb 16 15:52:11 2013 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/** - * vim: set ts=4 : - * ============================================================================= - * SourceMod - * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. - * ============================================================================= - * - * This program is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, version 3.0, as published by the - * Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License along with - * this program. If not, see . - * - * As a special exception, AlliedModders LLC gives you permission to link the - * code of this program (as well as its derivative works) to "Half-Life 2," the - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software - * by the Valve Corporation. You must obey the GNU General Public License in - * all respects for all other code used. Additionally, AlliedModders LLC grants - * this exception to all derivative works. AlliedModders LLC defines further - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), - * or . - * - * Version: $Id$ - */ - -#ifndef _INCLUDE_SOURCEMOD_CDBGREPORTER_H_ -#define _INCLUDE_SOURCEMOD_CDBGREPORTER_H_ - -#include "sp_vm_api.h" -#include "sm_globals.h" - -class DebugReport : - public SMGlobalClass, - public IDebugListener -{ -public: // SMGlobalClass - void OnSourceModAllInitialized(); -public: // IDebugListener - void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error); - void OnDebugSpew(const char *msg, ...); -public: - void GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...); - void GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, const char *message, va_list ap); - void GenerateCodeError(IPluginContext *ctx, uint32_t code_addr, int err, const char *message, ...); -private: - int _GetPluginIndex(IPluginContext *ctx); -}; - -extern DebugReport g_DbgReporter; - -#endif // _INCLUDE_SOURCEMOD_CDBGREPORTER_H_ - diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/ForwardSys.cpp --- a/core/ForwardSys.cpp Sat Feb 16 15:52:11 2013 -0800 +++ b/core/ForwardSys.cpp Sat Feb 16 15:57:00 2013 -0800 @@ -35,7 +35,7 @@ #include "ForwardSys.h" #include "PluginSys.h" #include "ShareSys.h" -#include "DebugReporter.h" +#include "logic_bridge.h" CForwardManager g_Forwards; @@ -356,7 +356,7 @@ if (err != SP_ERROR_NONE) { - g_DbgReporter.GenerateError(func->GetParentContext(), + logicore.GenerateError(func->GetParentContext(), func->GetFunctionID(), err, "Failed to push parameter while executing forward"); diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/logic/AMBuilder --- a/core/logic/AMBuilder Sat Feb 16 15:52:11 2013 -0800 +++ b/core/logic/AMBuilder Sat Feb 16 15:57:00 2013 -0800 @@ -49,7 +49,8 @@ 'smn_gameconfigs.cpp', 'GameConfigs.cpp', 'sm_crc32.cpp', - 'smn_profiler.cpp' + 'smn_profiler.cpp', + 'DebugReporter.cpp' ] if AMBuild.target['platform'] == 'windows': files.append('thread/WinThreads.cpp') diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/logic/DebugReporter.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/logic/DebugReporter.cpp Sat Feb 16 15:57:00 2013 -0800 @@ -0,0 +1,199 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#include +#include "DebugReporter.h" + +DebugReport g_DbgReporter; + +void DebugReport::OnSourceModAllInitialized() +{ + g_pSourcePawn->SetDebugListener(this); +} + +void DebugReport::OnDebugSpew(const char *msg, ...) +{ + va_list ap; + char buffer[512]; + + va_start(ap, msg); + smcore.FormatArgs(buffer, sizeof(buffer), msg, ap); + va_end(ap); + + smcore.Log("[SM] %s", buffer); +} + +void DebugReport::GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...) +{ + va_list ap; + + va_start(ap, message); + GenerateErrorVA(ctx, func_idx, err, message, ap); + va_end(ap); +} + +void DebugReport::GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, const char *message, va_list ap) +{ + char buffer[512]; + smcore.FormatArgs(buffer, sizeof(buffer), message, ap); + + const char *plname = pluginsys->FindPluginByContext(ctx->GetContext())->GetFilename(); + const char *error = g_pSourcePawn2->GetErrorString(err); + + if (error) + { + smcore.LogError("[SM] Plugin \"%s\" encountered error %d: %s", plname, err, error); + } else { + smcore.LogError("[SM] Plugin \"%s\" encountered unknown error %d", plname, err); + } + + smcore.LogError("[SM] %s", buffer); + + if (func_idx != -1) + { + if (func_idx & 1) + { + func_idx >>= 1; + sp_public_t *function; + if (ctx->GetRuntime()->GetPublicByIndex(func_idx, &function) == SP_ERROR_NONE) + { + smcore.LogError("[SM] Unable to call function \"%s\" due to above error(s).", function->name); + } + } + } +} + +void DebugReport::GenerateCodeError(IPluginContext *pContext, uint32_t code_addr, int err, const char *message, ...) +{ + va_list ap; + char buffer[512]; + + va_start(ap, message); + smcore.FormatArgs(buffer, sizeof(buffer), message, ap); + va_end(ap); + + const char *plname = pluginsys->FindPluginByContext(pContext->GetContext())->GetFilename(); + const char *error = g_pSourcePawn2->GetErrorString(err); + + if (error) + { + smcore.LogError("[SM] Plugin \"%s\" encountered error %d: %s", plname, err, error); + } else { + smcore.LogError("[SM] Plugin \"%s\" encountered unknown error %d", plname, err); + } + + smcore.LogError("[SM] %s", buffer); + + IPluginDebugInfo *pDebug; + if ((pDebug = pContext->GetRuntime()->GetDebugInfo()) == NULL) + { + smcore.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); + smcore.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", + _GetPluginIndex(pContext)); + return; + } + + const char *name; + if (pDebug->LookupFunction(code_addr, &name) == SP_ERROR_NONE) + { + smcore.LogError("[SM] Unable to call function \"%s\" due to above error(s).", name); + } else { + smcore.LogError("[SM] Unable to call function (name unknown, address \"%x\").", code_addr); + } +} + +void DebugReport::OnContextExecuteError(IPluginContext *ctx, IContextTrace *error) +{ + const char *lastname; + const char *plname = pluginsys->FindPluginByContext(ctx->GetContext())->GetFilename(); + int n_err = error->GetErrorCode(); + + if (n_err != SP_ERROR_NATIVE) + { + smcore.LogError("[SM] Plugin encountered error %d: %s", + n_err, + error->GetErrorString()); + } + + if ((lastname=error->GetLastNative(NULL)) != NULL) + { + const char *custerr; + if ((custerr=error->GetCustomErrorString()) != NULL) + { + smcore.LogError("[SM] Native \"%s\" reported: %s", lastname, custerr); + } else { + smcore.LogError("[SM] Native \"%s\" encountered a generic error.", lastname); + } + } + + if (!error->DebugInfoAvailable()) + { + smcore.LogError("[SM] Debug mode is not enabled for \"%s\"", plname); + smcore.LogError("[SM] To enable debug mode, edit plugin_settings.cfg, or type: sm plugins debug %d on", + _GetPluginIndex(ctx)); + return; + } + + CallStackInfo stk_info; + int i = 0; + smcore.LogError("[SM] Displaying call stack trace for plugin \"%s\":", plname); + while (error->GetTraceInfo(&stk_info)) + { + smcore.LogError("[SM] [%d] Line %d, %s::%s()", + i++, + stk_info.line, + stk_info.filename, + stk_info.function); + } +} + +int DebugReport::_GetPluginIndex(IPluginContext *ctx) +{ + int id = 1; + IPluginIterator *iter = pluginsys->GetPluginIterator(); + + for (; iter->MorePlugins(); iter->NextPlugin(), id++) + { + IPlugin *pl = iter->GetPlugin(); + if (pl->GetBaseContext() == ctx) + { + iter->Release(); + return id; + } + } + + iter->Release(); + + /* If we don't know which plugin this is, it's one being loaded. Fake its index for now. */ + + return pluginsys->GetPluginCount() + 1; +} + diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/logic/DebugReporter.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/logic/DebugReporter.h Sat Feb 16 15:57:00 2013 -0800 @@ -0,0 +1,58 @@ +/** + * vim: set ts=4 : + * ============================================================================= + * SourceMod + * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved. + * ============================================================================= + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU General Public License, version 3.0, as published by the + * Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more + * details. + * + * You should have received a copy of the GNU General Public License along with + * this program. If not, see . + * + * As a special exception, AlliedModders LLC gives you permission to link the + * code of this program (as well as its derivative works) to "Half-Life 2," the + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software + * by the Valve Corporation. You must obey the GNU General Public License in + * all respects for all other code used. Additionally, AlliedModders LLC grants + * this exception to all derivative works. AlliedModders LLC defines further + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), + * or . + * + * Version: $Id$ + */ + +#ifndef _INCLUDE_SOURCEMOD_CDBGREPORTER_H_ +#define _INCLUDE_SOURCEMOD_CDBGREPORTER_H_ + +#include "sp_vm_api.h" +#include "common_logic.h" + +class DebugReport : + public SMGlobalClass, + public IDebugListener +{ +public: // SMGlobalClass + void OnSourceModAllInitialized(); +public: // IDebugListener + void OnContextExecuteError(IPluginContext *ctx, IContextTrace *error); + void OnDebugSpew(const char *msg, ...); +public: + void GenerateError(IPluginContext *ctx, cell_t func_idx, int err, const char *message, ...); + void GenerateErrorVA(IPluginContext *ctx, cell_t func_idx, int err, const char *message, va_list ap); + void GenerateCodeError(IPluginContext *ctx, uint32_t code_addr, int err, const char *message, ...); +private: + int _GetPluginIndex(IPluginContext *ctx); +}; + +extern DebugReport g_DbgReporter; + +#endif // _INCLUDE_SOURCEMOD_CDBGREPORTER_H_ + diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/logic/common_logic.cpp --- a/core/logic/common_logic.cpp Sat Feb 16 15:52:11 2013 -0800 +++ b/core/logic/common_logic.cpp Sat Feb 16 15:57:00 2013 -0800 @@ -41,6 +41,7 @@ #include "ThreadSupport.h" #include "Translator.h" #include "GameConfigs.h" +#include "DebugReporter.h" sm_core_t smcore; IHandleSys *handlesys; @@ -59,6 +60,8 @@ IPlayerManager *playerhelpers; IAdminSystem *adminsys; IGameHelpers *gamehelpers; +ISourcePawnEngine *g_pSourcePawn; +ISourcePawnEngine2 *g_pSourcePawn2; static void AddCorePhraseFile(const char *filename) { @@ -73,6 +76,14 @@ // Defined in smn_filesystem.cpp. extern bool OnLogPrint(const char *msg); +static void GenerateError(IPluginContext *ctx, cell_t idx, int err, const char *msg, ...) +{ + va_list ap; + va_start(ap, msg); + g_DbgReporter.GenerateErrorVA(ctx, idx, err, msg, ap); + va_end(ap); +} + static sm_logic_t logic = { NULL, @@ -86,7 +97,9 @@ UTIL_ReplaceEx, UTIL_DecodeHexString, GetCoreGameConfig, - OnLogPrint + OnLogPrint, + &g_DbgReporter, + GenerateError }; static void logic_init(const sm_core_t* core, sm_logic_t* _logic) @@ -110,6 +123,8 @@ playerhelpers = core->playerhelpers; adminsys = core->adminsys; gamehelpers = core->gamehelpers; + g_pSourcePawn = core->spe1; + g_pSourcePawn2 = core->spe2; } PLATFORM_EXTERN_C ITextParsers *get_textparsers() diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/logic/intercom.h --- a/core/logic/intercom.h Sat Feb 16 15:52:11 2013 -0800 +++ b/core/logic/intercom.h Sat Feb 16 15:57:00 2013 -0800 @@ -42,7 +42,7 @@ * Add 1 to the RHS of this expression to bump the intercom file * This is to prevent mismatching core/logic binaries */ -#define SM_LOGIC_MAGIC (0x0F47C0DE - 17) +#define SM_LOGIC_MAGIC (0x0F47C0DE - 18) #if defined SM_LOGIC class IVEngineServer @@ -99,6 +99,8 @@ IPlayerManager *playerhelpers; IAdminSystem *adminsys; IGameHelpers *gamehelpers; + ISourcePawnEngine *spe1; + ISourcePawnEngine2 *spe2; /* Functions */ void (*AddNatives)(sp_nativeinfo_t* nlist); ConVar * (*FindConVar)(const char*); @@ -111,7 +113,7 @@ bool (*FileExists)(const char *path); const char * (*GetCvarString)(ConVar*); size_t (*Format)(char*, size_t, const char*, ...); - void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...); + size_t (*FormatArgs)(char*, size_t, const char*,va_list ap); bool (*gnprintf)(char *, size_t, const char *, IPhraseCollection *, void **, unsigned int, unsigned int &, size_t *, const char **); size_t (*atcprintf)(char *, size_t, const char *, IPluginContext *, const cell_t *, int *); @@ -141,6 +143,8 @@ size_t (*DecodeHexString)(unsigned char *, size_t, const char *); IGameConfig * (*GetCoreGameConfig)(); bool (*OnLogPrint)(const char *msg); // true to supercede + IDebugListener *debugger; + void (*GenerateError)(IPluginContext *, cell_t, int, const char *, ...); }; typedef void (*LogicInitFunction)(const sm_core_t *core, sm_logic_t *logic); diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/logic/smn_timers.cpp --- a/core/logic/smn_timers.cpp Sat Feb 16 15:52:11 2013 -0800 +++ b/core/logic/smn_timers.cpp Sat Feb 16 15:57:00 2013 -0800 @@ -35,6 +35,7 @@ #include #include #include +#include "DebugReporter.h" using namespace SourceHook; @@ -155,7 +156,7 @@ { if ((herr=handlesys->FreeHandle(usrhndl, &sec)) != HandleError_None) { - smcore.GenerateError(pInfo->pContext, pInfo->Hook->GetFunctionID(), + g_DbgReporter.GenerateError(pInfo->pContext, pInfo->Hook->GetFunctionID(), SP_ERROR_NATIVE, "Invalid data handle %x (error %d) passed during timer end with TIMER_DATA_HNDL_CLOSE", usrhndl, herr); @@ -166,7 +167,7 @@ { if ((herr=handlesys->FreeHandle(pInfo->TimerHandle, &sec)) != HandleError_None) { - smcore.GenerateError(pInfo->pContext, pInfo->Hook->GetFunctionID(), + g_DbgReporter.GenerateError(pInfo->pContext, pInfo->Hook->GetFunctionID(), SP_ERROR_NATIVE, "Invalid timer handle %x (error %d) during timer end, displayed function is timer callback, not the stack trace", pInfo->TimerHandle, herr); diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/logic_bridge.cpp --- a/core/logic_bridge.cpp Sat Feb 16 15:52:11 2013 -0800 +++ b/core/logic_bridge.cpp Sat Feb 16 15:57:00 2013 -0800 @@ -45,7 +45,6 @@ #include "ForwardSys.h" #include "TimerSys.h" #include "logic_bridge.h" -#include "DebugReporter.h" #include "PlayerManager.h" #include "AdminCache.h" #include "HalfLife2.h" @@ -135,15 +134,6 @@ return basefilesystem->FileExists(path); } -static void generate_error(IPluginContext *ctx, cell_t func_idx, int err, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - g_DbgReporter.GenerateErrorVA(ctx, func_idx, err, fmt, ap); - va_end(ap); -} - static const char *get_cvar_string(ConVar* cvar) { return cvar->GetString(); @@ -234,6 +224,8 @@ &g_Players, &g_Admins, &g_HL2, + g_pSourcePawn, + g_pSourcePawn2, /* Functions */ add_natives, find_convar, @@ -246,7 +238,7 @@ file_exists, get_cvar_string, UTIL_Format, - generate_error, + UTIL_FormatArgs, gnprintf, atcprintf, get_game_name, diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/smn_menus.cpp --- a/core/smn_menus.cpp Sat Feb 16 15:52:11 2013 -0800 +++ b/core/smn_menus.cpp Sat Feb 16 15:57:00 2013 -0800 @@ -31,7 +31,6 @@ #include "sm_globals.h" #include -#include "DebugReporter.h" #include "MenuManager.h" #include "MenuStyle_Valve.h" #include "MenuStyle_Radio.h" @@ -44,6 +43,7 @@ #include "Logger.h" #endif #include "ChatTriggers.h" +#include "logic_bridge.h" #if defined CreateMenu #undef CreateMenu @@ -470,7 +470,7 @@ if ((err = pContext->HeapAlloc(client_array_size, &client_array_address, &client_array_base)) != SP_ERROR_NONE) { - g_DbgReporter.GenerateError(pContext, m_fnVoteResult, err, "Menu callback could not allocate %d bytes for client list.", client_array_size * sizeof(cell_t)); + logicore.GenerateError(pContext, m_fnVoteResult, err, "Menu callback could not allocate %d bytes for client list.", client_array_size * sizeof(cell_t)); no_call = true; } else { cell_t target_offs = sizeof(cell_t) * results->num_clients; @@ -503,7 +503,7 @@ if ((err = pContext->HeapAlloc(item_array_size, &item_array_address, &item_array_base)) != SP_ERROR_NONE) { - g_DbgReporter.GenerateError(pContext, m_fnVoteResult, err, "Menu callback could not allocate %d bytes for item list.", item_array_size); + logicore.GenerateError(pContext, m_fnVoteResult, err, "Menu callback could not allocate %d bytes for item list.", item_array_size); no_call = true; } else { cell_t target_offs = sizeof(cell_t) * results->num_items; diff -r 47e1ee9cea86 -r d8a07e40bcb6 core/sourcemod.cpp --- a/core/sourcemod.cpp Sat Feb 16 15:52:11 2013 -0800 +++ b/core/sourcemod.cpp Sat Feb 16 15:57:00 2013 -0800 @@ -45,7 +45,6 @@ #include "ForwardSys.h" #include "TimerSys.h" #include -#include "DebugReporter.h" #include "frame_hooks.h" #include "logic_bridge.h" @@ -242,7 +241,7 @@ return false; } - g_pSourcePawn2->SetDebugListener(&g_DbgReporter); + g_pSourcePawn2->SetDebugListener(logicore.debugger); /* Hook this now so we can detect startup without calling StartSourceMod() */ SH_ADD_HOOK_MEMFUNC(IServerGameDLL, LevelInit, gamedll, this, &SourceModBase::LevelInit, false);