From a8c91db5852926d296d7877dc371af0ce50ffcc5 Mon Sep 17 00:00:00 2001 From: peace-maker Date: Tue, 7 Jan 2025 00:38:55 +0100 Subject: [PATCH] Add "EnableLineDebugging" core.cfg option (#2240) Allow extensions to register a debug break handler in the SourcePawn VM. Enable line debugging support in the VM before any plugin is loaded through a core.cfg option. --- configs/core.cfg | 7 +++++++ core/sourcemod.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/configs/core.cfg b/configs/core.cfg index 0994f1cacc..652ed53756 100644 --- a/configs/core.cfg +++ b/configs/core.cfg @@ -138,4 +138,11 @@ * "jitdump" - Generate extended perf metadata (Linux only - function names, bytecode, and source information) */ "JITMetadata" "default" + + /** + * Setup the SourcePawn VM to enable extensions to use a debugging API to step through + * plugins line by line. This heavily decreases server performance and should NEVER be + * used on a production server, but ONLY during plugin development. + */ + "EnableLineDebugging" "no" } diff --git a/core/sourcemod.cpp b/core/sourcemod.cpp index e27dfbf394..10a13259ae 100644 --- a/core/sourcemod.cpp +++ b/core/sourcemod.cpp @@ -365,6 +365,12 @@ void SourceModBase::StartSourceMod(bool late) g_pSourcePawn2->InstallWatchdogTimer(atoi(timeout) * 1000); } + const char *linedebugger = GetCoreConfigValue("EnableLineDebugging"); + if (linedebugger != NULL && strcasecmp(linedebugger, "yes") == 0) + { + g_pPawnEnv->EnableDebugBreak(); + } + SH_ADD_HOOK(IServerGameDLL, Think, gamedll, SH_MEMBER(logicore.callbacks, &IProviderCallbacks::OnThink), false); }