From 12f43b5508d2ed2a410292c40b82c37b0de6bbda Mon Sep 17 00:00:00 2001 From: AffectedArc07 <25063394+AffectedArc07@users.noreply.github.com> Date: Fri, 22 Jan 2021 14:25:05 +0000 Subject: [PATCH] Updates the vscode debugger engine (#15328) --- SpacemanDMM.toml | 3 +++ code/__HELPERS/debugger.dm | 22 ++++++++++++++++++++++ code/game/world.dm | 13 ++++--------- paradise.dme | 1 + 4 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 code/__HELPERS/debugger.dm diff --git a/SpacemanDMM.toml b/SpacemanDMM.toml index 81aff0d5576..b1c71c30062 100644 --- a/SpacemanDMM.toml +++ b/SpacemanDMM.toml @@ -7,3 +7,6 @@ disallow_relative_proc_definitions = true [dmdoc] use_typepath_names = true + +[debugger] +engine = "auxtools" diff --git a/code/__HELPERS/debugger.dm b/code/__HELPERS/debugger.dm new file mode 100644 index 00000000000..e68b49e60db --- /dev/null +++ b/code/__HELPERS/debugger.dm @@ -0,0 +1,22 @@ +// All the stuff in here is related to the auxtools debugger, supplied as part of the DM Language Server VSCode extension +// These procs are named EXACTLY as they are since the debugger itself will hook into these procs internally +// Do not change these names. Please. -aa + +/proc/auxtools_stack_trace(msg) + CRASH(msg) + +/proc/enable_debugging(mode, port) + CRASH("auxtools not loaded") + +// Called in world/New() +/world/proc/enable_auxtools_debugger() + var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") + if (debug_server) + call(debug_server, "auxtools_init")() + enable_debugging() + +// Called in world/Del(). This is VERY important, otherwise you get phantom threads which try to lookup RAM they arent allowed to +/world/proc/disable_auxtools_debugger() + var/debug_server = world.GetConfig("env", "AUXTOOLS_DEBUG_DLL") + if (debug_server) + call(debug_server, "auxtools_shutdown")() diff --git a/code/game/world.dm b/code/game/world.dm index d2fb442c5f9..eeca8b321ba 100644 --- a/code/game/world.dm +++ b/code/game/world.dm @@ -5,10 +5,12 @@ GLOBAL_LIST_INIT(map_transition_config, MAP_TRANSITION_CONFIG) // If you do any SQL operations inside this proc, they must ***NOT*** be ran async. Otherwise players can join mid query // This is BAD. + // Right off the bat + enable_auxtools_debugger() + //temporary file used to record errors with loading config and the database, moved to log directory once logging is set up GLOB.config_error_log = GLOB.world_game_log = GLOB.world_runtime_log = GLOB.sql_log = "data/logs/config_error.log" load_configuration() - enable_debugger() // Enable the extools debugger // Right off the bat, load up the DB SSdbcore.CheckSchemaVersion() // This doesnt just check the schema version, it also connects to the db! This needs to happen super early! I cannot stress this enough! @@ -268,14 +270,7 @@ GLOBAL_LIST_EMPTY(world_topic_handlers) fdel(F) F << GLOB.log_directory -// Proc to enable the extools debugger, which allows breakpoints, live var checking, and many other useful tools -// The DLL is injected into the env by visual studio code. If not running VSCode, the proc will not call the initialization -/world/proc/enable_debugger() - var/dll = world.GetConfig("env", "EXTOOLS_DLL") - if (dll) - call(dll, "debug_initialize")() - - /world/Del() rustg_close_async_http_client() // Close the HTTP client. If you dont do this, youll get phantom threads which can crash DD from memory access violations + disable_auxtools_debugger() // Disables the debugger if running. See above comment ..() diff --git a/paradise.dme b/paradise.dme index 7d4a10a0129..1a7844d3ab6 100644 --- a/paradise.dme +++ b/paradise.dme @@ -94,6 +94,7 @@ #include "code\__HELPERS\AnimationLibrary.dm" #include "code\__HELPERS\cmp.dm" #include "code\__HELPERS\constants.dm" +#include "code\__HELPERS\debugger.dm" #include "code\__HELPERS\experimental.dm" #include "code\__HELPERS\files.dm" #include "code\__HELPERS\game.dm"