Add GDB Stub
GDB Stub cherry picked manually from Ryujinx#5804 (Author: merry, svc64)
I modified some code to make it compatible with the latest Ryujinx and my device. I also made some improvements / changes to make it more usable:
- Thread names will now be displayed in gdb and
GetGuestStackTrace
- Fixed breakpoints/stepping for AArch32 applications
- Fixed stepping of branch instructions
- When using
si
in gdb, gdb should correctly enterbl
and other branch instructions now.
- When using
- Support precise tracking of PC value when GDB Stub is enabled
- This is done by inserting an instruction before each instruction to set the current PC to the NativeContext.
- This will affect performance, so it's only enabled when GDB Stub is enabled in Settings.
- This also means when GDB Stub is enabled, the PC value in crash logs will be more accurate.
- Added some
monitor
command in gdb-
monitor help
- list all available monitor commands -
monitor backtrace
(mo bt
) - show stack trace for the current thread, use RyujinxGetGuestStackTrace
-
monitor registers
(mo reg
) - display register values for the current thread, use RyujinxGetCpuRegisterPrintout
-
monitor get info
- show process information like memory layout and loaded modules
-
- On Windows arm64, when GDB Stub is enabled, Ryujinx will now use
Ryujinx.Cpu.Jit
(ARMeilleure) instead ofRyujinx.Cpu.LightningJit
, because debugging support was not added toRyujinx.Cpu.LightningJit
.- I did not test this part.
- On macOS, Ryujinx uses
Ryujinx.Cpu.AppleHv
.- Debugging support was added to
Ryujinx.Cpu.AppleHv
in the original pull request (Ryujinx#5804). I did not test this part.
- Debugging support was added to
I'm using it on Windows x64, It wasn't tested on other platforms: e.g. macOS, Windows arm64. (I don't have these devices, and issues on these platform will probably be too difficult for me to fix...)
If anyone is interested, feel free to fork and improve it.
Edited by Coxxs