[PR #1192] [CLOSED] GDB server stub for remote debugging #380

Open
opened 2026-01-29 19:07:38 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/stenzek/duckstation/pull/1192
Author: @boricj
Created: 12/10/2020
Status: Closed

Base: masterHead: gdbserver


📝 Commits (7)

  • 2bfe6fd StringUtil: Add base support and hexadecimal functions
  • e7effa4 Settings: Add GDB server settings
  • fcf76e6 Bus: Add peek/poke functions
  • fde0f4c Core: Add debug notifications to host interface
  • 9476bfd Core: Add CPU debug instrumentation
  • 9f783de Core: Implement GDB protocol
  • 3156f13 Qt: Implement GDB debug server

📊 Changes

23 files changed (+941 additions, -26 deletions)

View changed files

📝 src/common/string_util.cpp (+27 -0)
📝 src/common/string_util.h (+11 -5)
📝 src/core/CMakeLists.txt (+2 -0)
📝 src/core/bus.cpp (+63 -0)
📝 src/core/bus.h (+4 -0)
📝 src/core/cpu_core.cpp (+114 -21)
📝 src/core/cpu_core.h (+24 -0)
📝 src/core/cpu_core_private.h (+56 -0)
src/core/gdb_protocol.cpp (+394 -0)
src/core/gdb_protocol.h (+10 -0)
📝 src/core/host_interface.cpp (+4 -0)
📝 src/core/host_interface.h (+4 -0)
📝 src/core/settings.cpp (+2 -0)
📝 src/core/settings.h (+3 -0)
📝 src/duckstation-qt/CMakeLists.txt (+4 -0)
src/duckstation-qt/gdbconnection.cpp (+69 -0)
src/duckstation-qt/gdbconnection.h (+26 -0)
src/duckstation-qt/gdbserver.cpp (+45 -0)
src/duckstation-qt/gdbserver.h (+27 -0)
📝 src/duckstation-qt/mainwindow.cpp (+28 -0)

...and 3 more files

📄 Description

I'm currently in the process of reverse-engineering a PS1 game and I need a good, modern PS1 emulator with a decent debugger. This is surprisingly hard to come by, so I've settled for a good, modern PS1 emulator and stick a GDB stub in it.

To use this, you need a GDB with MIPS support (I use gdb-multiarch with set architecture mips:3000). Enable the GDB server in the settings file, start the Qt frontend, boot something and connect to the server with target remote :1234.

Settings to enable the GDB server:

[Debug]
EnableGDBServer = true
GDBServerPort = 1234

This is extremely bare-bones at the moment, but it can peek/poke memory. My main concern so far is handling instruction-level breakpoints/watchpoints, since it appears the emulator can only be paused at frame intervals (which would be a couple million instructions too late).

TODO:

  • GDB server settings in configuration file
  • GDB server settings in Qt UI
  • GDB server for Qt frontend
  • GDB server for SDL frontend
  • Basic GDB server infrastructure
  • Read/write memory
  • Read/write general registers
  • Hackish frame-level interrupt/continue
  • Proper instruction-level interrupt/continue
  • Instruction step
  • Breakpoints
  • Watchpoints

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/stenzek/duckstation/pull/1192 **Author:** [@boricj](https://github.com/boricj) **Created:** 12/10/2020 **Status:** ❌ Closed **Base:** `master` ← **Head:** `gdbserver` --- ### 📝 Commits (7) - [`2bfe6fd`](https://github.com/stenzek/duckstation/commit/2bfe6fd4a76fc0050d56052d1fef3172f6429839) StringUtil: Add base support and hexadecimal functions - [`e7effa4`](https://github.com/stenzek/duckstation/commit/e7effa4e51be1b40a39343333875632990ee969f) Settings: Add GDB server settings - [`fcf76e6`](https://github.com/stenzek/duckstation/commit/fcf76e6c450adf28d6dc88c2cc88cf73c516a487) Bus: Add peek/poke functions - [`fde0f4c`](https://github.com/stenzek/duckstation/commit/fde0f4c988af0cbe4557eef32307e3d4d70874a0) Core: Add debug notifications to host interface - [`9476bfd`](https://github.com/stenzek/duckstation/commit/9476bfd9fe1afcd7997c2f504cfb2710a8add630) Core: Add CPU debug instrumentation - [`9f783de`](https://github.com/stenzek/duckstation/commit/9f783de9d6dbc747bd16ba7687b133e63afc73e2) Core: Implement GDB protocol - [`3156f13`](https://github.com/stenzek/duckstation/commit/3156f1318e6decdf8655e56139c3778279fa7b71) Qt: Implement GDB debug server ### 📊 Changes **23 files changed** (+941 additions, -26 deletions) <details> <summary>View changed files</summary> 📝 `src/common/string_util.cpp` (+27 -0) 📝 `src/common/string_util.h` (+11 -5) 📝 `src/core/CMakeLists.txt` (+2 -0) 📝 `src/core/bus.cpp` (+63 -0) 📝 `src/core/bus.h` (+4 -0) 📝 `src/core/cpu_core.cpp` (+114 -21) 📝 `src/core/cpu_core.h` (+24 -0) 📝 `src/core/cpu_core_private.h` (+56 -0) ➕ `src/core/gdb_protocol.cpp` (+394 -0) ➕ `src/core/gdb_protocol.h` (+10 -0) 📝 `src/core/host_interface.cpp` (+4 -0) 📝 `src/core/host_interface.h` (+4 -0) 📝 `src/core/settings.cpp` (+2 -0) 📝 `src/core/settings.h` (+3 -0) 📝 `src/duckstation-qt/CMakeLists.txt` (+4 -0) ➕ `src/duckstation-qt/gdbconnection.cpp` (+69 -0) ➕ `src/duckstation-qt/gdbconnection.h` (+26 -0) ➕ `src/duckstation-qt/gdbserver.cpp` (+45 -0) ➕ `src/duckstation-qt/gdbserver.h` (+27 -0) 📝 `src/duckstation-qt/mainwindow.cpp` (+28 -0) _...and 3 more files_ </details> ### 📄 Description I'm currently in the process of reverse-engineering a PS1 game and I need a good, modern PS1 emulator with a decent debugger. This is surprisingly hard to come by, so I've settled for a good, modern PS1 emulator and stick a GDB stub in it. To use this, you need a GDB with MIPS support (I use gdb-multiarch with `set architecture mips:3000`). Enable the GDB server in the settings file, start the Qt frontend, boot something and connect to the server with `target remote :1234`. Settings to enable the GDB server: ``` [Debug] EnableGDBServer = true GDBServerPort = 1234 ``` This is extremely bare-bones at the moment, but it can peek/poke memory. My main concern so far is handling instruction-level breakpoints/watchpoints, since it appears the emulator can only be paused at frame intervals (which would be a couple million instructions too late). TODO: - [X] GDB server settings in configuration file - [ ] GDB server settings in Qt UI - [X] GDB server for Qt frontend - [ ] GDB server for SDL frontend - [X] Basic GDB server infrastructure - [X] Read/write memory - [X] Read/write general registers - [X] Hackish frame-level interrupt/continue - [x] Proper instruction-level interrupt/continue - [ ] Instruction step - [x] Breakpoints - [ ] Watchpoints --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-29 19:07:38 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/duckstation#380