Add an option to run gdbserver when starting noita. Havent figured out how to make use of it yet given that it has to go through a couple wrappers before actually starting noita tho.

This commit is contained in:
IQuant 2025-11-17 17:40:55 +03:00
parent d5e5646847
commit b59eed0158
4 changed files with 23 additions and 1 deletions

View file

@ -51,6 +51,9 @@ flamegraph: add_dylib_debug
run: add_dylib_debug build_ext
cd noita-proxy && NP_SKIP_MOD_CHECK=1 cargo run
run-w-gdb: add_dylib_debug build_ext
cd noita-proxy && NP_SKIP_MOD_CHECK=1 cargo run -- --run-noita-with-gdb --launch-cmd "wine noita.exe"
run2: add_dylib_debug build_ext
cd noita-proxy && NP_SKIP_MOD_CHECK=1 cargo run -- --launch-cmd "wine noita.exe -gamemode 0"

View file

@ -1,6 +1,7 @@
use crate::steam_helper::SteamState;
use std::fs::File;
use std::io::{BufRead, BufReader};
use std::mem;
use std::{
ffi::OsString,
path::{Path, PathBuf},
@ -47,6 +48,7 @@ impl NoitaLauncher {
pub fn new(
game_exe_path: &Path,
start_args: Option<&str>,
run_with_gdb: bool,
steam_state: Option<&mut SteamState>,
) -> Self {
let game_dir_path = game_exe_path
@ -71,7 +73,19 @@ impl NoitaLauncher {
.and_then(shlex::split)
.map(|v| v.into_iter().map(OsString::from).collect::<Vec<_>>())
.and_then(|args| NoitaStartCmd::from_full_args(&args));
let start_args = start_args.or(default_start_args);
let mut start_args = start_args.or(default_start_args);
if let Some(start_args) = start_args.as_mut()
&& run_with_gdb
{
info!("Extending start cmd to run gdbserver");
start_args.args.insert(
0,
mem::replace(&mut start_args.executable, "gdbserver".into()),
);
start_args.args.insert(0, "--".into());
start_args.args.insert(0, "localhost:4123".into());
}
Self {
game_dir_path,

View file

@ -1549,6 +1549,7 @@ impl App {
noita_launcher: NoitaLauncher::new(
&self.modmanager_settings.game_exe_path,
self.args.launch_cmd.as_deref(),
self.args.run_noita_with_gdb,
self.steam_state.as_mut().ok(),
),
};

View file

@ -33,6 +33,10 @@ pub struct Args {
/// used internally.
#[argh(option)]
pub auto_connect_to: Option<LobbyCode>,
/// also run gdbserver when starting noita. Used for development.
#[argh(switch)]
pub run_noita_with_gdb: bool,
}
impl FromArgValue for LobbyKind {