mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-04-22 10:50:58 +00:00
start debug server in d_main, add vm_debug
cvars and -debug
CLI arg
This commit is contained in:
parent
009686de5d
commit
0cdd7e9e2e
1 changed files with 52 additions and 1 deletions
|
@ -118,6 +118,7 @@
|
|||
#include "screenjob.h"
|
||||
#include "startscreen.h"
|
||||
#include "shiftstate.h"
|
||||
#include "common/scripting/dap/DebugServer.h"
|
||||
|
||||
#ifdef __unix__
|
||||
#include "i_system.h" // for SHARE_DIR
|
||||
|
@ -130,6 +131,8 @@ EXTERN_CVAR(Int, vr_mode)
|
|||
EXTERN_CVAR(Bool, cl_customizeinvulmap)
|
||||
EXTERN_CVAR(Bool, log_vgafont)
|
||||
EXTERN_CVAR(Bool, dlg_vgafont)
|
||||
EXTERN_CVAR(Bool, vm_jit)
|
||||
EXTERN_CVAR(Bool, vm_jit_aot)
|
||||
CVAR(Int, vid_renderer, 1, 0) // for some stupid mods which threw caution out of the window...
|
||||
|
||||
void DrawHUD();
|
||||
|
@ -334,6 +337,7 @@ extern bool AppActive;
|
|||
bool playedtitlemusic;
|
||||
|
||||
FStartScreen* StartScreen;
|
||||
std::unique_ptr<DebugServer::DebugServer> debugServer;
|
||||
|
||||
cycle_t FrameCycles;
|
||||
|
||||
|
@ -2651,6 +2655,23 @@ CUSTOM_CVAR(Int, mouse_capturemode, 1, CVAR_GLOBALCONFIG | CVAR_ARCHIVE)
|
|||
}
|
||||
}
|
||||
|
||||
CUSTOM_CVAR(Bool, vm_debug, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
{
|
||||
if (vm_debug == false){
|
||||
if (debugServer){
|
||||
debugServer->Stop();
|
||||
debugServer = nullptr;
|
||||
}
|
||||
} else {
|
||||
// TODO: we wouldn't need to do this if we were able to recompile everything when it's enabled?
|
||||
Printf("You must restart " GAMENAME " for this change to take effect.\n");
|
||||
Printf("Note that enabling the debug server will disable JIT compilation.\n");
|
||||
}
|
||||
// TODO: save this to the config file?
|
||||
|
||||
}
|
||||
|
||||
CVAR(Int, vm_debug_port, 19021, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
|
||||
void Mlook_ReleaseHandler()
|
||||
{
|
||||
|
@ -3400,9 +3421,14 @@ static int D_InitGame(const FIWADInfo* iwad_info, std::vector<std::string>& allw
|
|||
M_Init();
|
||||
M_CreateGameMenus();
|
||||
|
||||
bool should_debug = vm_debug.get();
|
||||
if (Args->CheckValue("-debug")) {
|
||||
should_debug = true;
|
||||
}
|
||||
|
||||
// clean up the compiler symbols which are not needed any longer.
|
||||
RemoveUnusedSymbols();
|
||||
if (!should_debug)
|
||||
RemoveUnusedSymbols();
|
||||
|
||||
InitActorNumsFromMapinfo();
|
||||
InitSpawnablesFromMapinfo();
|
||||
|
@ -3702,6 +3728,12 @@ static int D_DoomMain_Internal (void)
|
|||
// Now that we have the IWADINFO, initialize the autoload ini sections.
|
||||
GameConfig->DoAutoloadSetup(iwad_man);
|
||||
|
||||
bool should_debug = vm_debug.get();
|
||||
const char * debug_port_arg = Args->CheckValue("-debug");
|
||||
if (debug_port_arg) {
|
||||
should_debug = true;
|
||||
}
|
||||
|
||||
// reinit from here
|
||||
|
||||
do
|
||||
|
@ -3755,6 +3787,25 @@ static int D_DoomMain_Internal (void)
|
|||
|
||||
D_DoAnonStats();
|
||||
I_UpdateWindowTitle();
|
||||
|
||||
// Launch debug server if enabled
|
||||
if (should_debug) {
|
||||
debugServer = std::make_unique<DebugServer::DebugServer>();
|
||||
int debug_port = vm_debug_port.get()->ToInt();
|
||||
if (should_debug) {
|
||||
if (debug_port_arg) {
|
||||
debug_port = atoi(debug_port_arg);
|
||||
}
|
||||
}
|
||||
if (debug_port > 65535 || debug_port < 0) {
|
||||
I_FatalError("Invalid debug port %d (must be between 0 and 65535)", debug_port);
|
||||
}
|
||||
debugServer->Listen(debug_port);
|
||||
// disable vm_jit and vm_jit_aot when debugging
|
||||
vm_jit = false;
|
||||
vm_jit_aot = false;
|
||||
}
|
||||
|
||||
D_DoomLoop (); // this only returns if a 'restart' CCMD is given.
|
||||
//
|
||||
// Clean up after a restart
|
||||
|
|
Loading…
Reference in a new issue