Skip to content

GDB server

The GDB server allows you to set breakpoints and control your PSX program's execution from your gdb compatible IDE.

Enabling the GDB server

Enable gdb server

In PCSX-Redux: Configuration > Emulation > Enable GDB server.

Make sure the debugger is also enabled.

enable debugger/gdb

GDB setup

You need gdb-multiarch on your system :

Windows

Download a pre-compiled version from here : https://static.grumpycoder.net/pixel/gdb-multiarch-windows/

GNU/Linux

Install via your package manager :

1
2
3
4
5
# Debian derivative; Ubuntu, Mint...
sudo apt install gdb-multiarch
# Arch derivative; Manjaro
# 'gdb-multiarch' is available in aur : https://aur.archlinux.org/packages/gdb-multiarch/
sudo trizen -S gdb-multiarch

IDE setup

MS VScode

VScode native debg extension

  • Adapt your launch.json file to your environment :
    A sample lanuch.json file is available here.
    This should go in your-project/.vscode/.

You need to adapt the values of "executable", "gdbpath" and "autorun" according to your system :

executable

This is the path to your .elf executable :

1
   "executable": "HelloWorld.elf",
https://github.com/grumpycoders/pcsx-redux/blob/a3bebd490388130e924124cdfeff3bc46b6149d9/.vscode/launch.json#L153

gdbpath

This the path to the gdb-multiarch executable:

1
   "gdbpath": "/usr/bin/gdb-multiarch",
https://github.com/grumpycoders/pcsx-redux/blob/a3bebd490388130e924124cdfeff3bc46b6149d9/.vscode/launch.json#L154-L157

autorun

1
2
3
4
   "autorun": [
    "monitor reset shellhalt",
    [...]
    "load your-file.elf",

Make sure that "load your-file.elf" corresponds to the "target" value.

https://github.com/grumpycoders/pcsx-redux/blob/a3bebd490388130e924124cdfeff3bc46b6149d9/.vscode/launch.json#L159-L165

By default, using localhost should work, but if encountering trouble, try using your computer's local IP (e.g; 192.168.x.x, 10.0.x.x, etc.)

https://github.com/grumpycoders/pcsx-redux/blob/a3bebd490388130e924124cdfeff3bc46b6149d9/.vscode/launch.json#L150

gdb debugging

Geany

Make sure you installed the official plugins and enable the Scope debugger.

To enable the plugin, open Geany, go to Tools > Plugin manager and enable Scope Debugger.

You can find the debugging facilities in the Debug menu ;

geany program setup

You can find the plugin's documentation here : https://plugins.geany.org/scope.html

.gdbinit

Create a .gdbinit file at the root of your project with the following content, adapting the path to your elf file and the gdb server's ip.

1
2
3
4
target remote localhost:3333
symbol-file load /path/to/your/executable.elf
monitor reset shellhalt
load /path/to/your/executable.elf

Plugin configuration

In Geany : Debug > Setup Program :

geany program setup

CLion

Open the Run/Debug Configurations menu, which you can find here:

run/debug configurations menu

Then, add a new Remote Debug configuration:

add new remote debug

Finally, set your new configuration up:

config set up

.gdbinit

Create a .gdbinit file at the root of your project with the following content, adapting the path to your elf file.

1
2
3
4
5
6
define target remote
target extended-remote $arg0
symbol-file /path/to/your/executable.elf
monitor reset shellhalt
load /path/to/your/executable.elf
end

Beginning Debugging

Launch pcsx-redux, then run the debugger from your IDE. It should load the elf file, and execute until the next breakpoint.

Starting debugging in Geany

Source :
https://archive.org/details/pcsx_redux_geany_gdb

Additional tools

https://github.com/cyrus-and/gdb-dashboard/