GDB (Linux)

Install gdbserver on PATH (and gdb for the MCP tools below). -S enables the native-code stub on loopback port 1234 (the QEMU default port). The game runs until a debugger connects. -s enables the stub and waits before runtime initialization. It implies -S.

./build/scarletnx -s "Game.xci"
# Or: recompiled/<id>/<id> -Hs

In GDB, load the deployed executable's symbols and connect:

file recompiled/Game/Game
tar rem :1234
continue

The launcher prints a connection hint before waiting. A separate helper keeps accepting connections while the game is stopped, then delegates the remote protocol to gdbserver. The stub debugs host/native registers and code, not an emulated ARM64 CPU. It supports one connection per run. Local ptrace permissions must allow attachment. Binding failures and missing gdbserver are reported instead of silently running without a debugger. No debugger flags or combined short flags are supported on Windows.

The recompiled game module is a shared library with a symbol for each function, so GDB names game frames as it loads. A 64-bit game's functions are F_<address>, and a 32-bit game's blocks are A_<address> (A32) and T_<address> (Thumb). Code the JIT compiles at run time lives in an anonymous code arena. With --gdb-jit=1 (the [Debug] setting gdb_jit) and the stub (-S or -s), the runtime hands each compile to GDB through its JIT interface, with its symbols. A 32-bit game's are a32_<address>_<thumb>. GDB stops the whole game to read each compile while it is attached, and again for each at the game's end. That slows a 32-bit game (its blocks compile one at a time) to a crawl, so it is off by default. Without the stub the setting does nothing.

The runtime handles SIGSEGV and SIGBUS itself: memory it moves while a thread writes to it stops that thread on a fault, and a crash's fault writes the crash report. Tell GDB handle SIGSEGV SIGBUS nostop noprint pass and break on crash_report to stop only at a crash. A SIGSEGV or SIGBUS another process sends (kill -SEGV, or GDB's signal SIGSEGV) is not a crash. The runtime prints a line saying so and runs on.

GDB through the MCP server

An agent can drive GDB through the MCP server (scarletnx --mcp). It needs gdb (9 or later) on PATH as well as gdbserver, and a runtime with its debug information (the default RelWithDebInfo build, not one built with -g0).


Made from docs/user/usage.md at 69237645142c. GPL-3.0-or-later.