Compare commits

..

25 commits

Author SHA1 Message Date
Coxxs
5b642172e4 Merge branch 'gdb-stub' into 'master'
Add GDB Stub

See merge request [ryubing/ryujinx!71](https://git.ryujinx.app/ryubing/ryujinx/-/merge_requests/71)
2025-06-23 14:52:41 -05:00
Coxxs
8fa675de7b gdb: Adjust Settings UI 2025-06-23 17:59:53 +08:00
Coxxs
2a392add61 gdb: Fix single-stepping of branch instructions 2025-06-23 07:05:45 +08:00
Coxxs
91e95f49e8 gdb: Allow PTC cache when GDB Stub is enabled 2025-06-23 07:04:20 +08:00
Coxxs
106d528ad0 gdb: Invalidate PTC cache when GDB Stub is enabled/disabled 2025-06-23 07:03:40 +08:00
Coxxs
9a67734ea7 gdb: Support precise tracking of PC value when GDB Stub is enabled 2025-06-23 07:00:48 +08:00
Coxxs
8ab9d71931 gdb: Implement QRcmd (monitor) commands
monitor backtrace (mo bt)
monitor registers (mo reg)
monitor get info
2025-06-23 06:18:34 +08:00
Coxxs
6b50663e99 gdb: Revert ExecutionContext for now
Pc isn't reliable either
2025-06-22 05:28:40 +08:00
Coxxs
29f2481213 gdb: Implement z0/Z0 software breakpoints 2025-06-22 05:28:31 +08:00
Coxxs
ee947ae592 gdb: Implement vCont to support step on AArch32 2025-06-22 02:31:04 +08:00
Coxxs
6afce6308c gdb: Do not use LightningJitEngine when GDB Stub is enabled 2025-06-21 15:38:32 +08:00
Coxxs
55a43dea45 gdb: Fix ExecutionContext 2025-06-21 14:31:00 +08:00
Coxxs
92d8f0eb1c gdb: Show thread names
Reference: d8a37b4b71/libraries/libstratosphere/source/osdbg/impl/osdbg_thread_type.os.horizon.hpp
2025-06-21 12:54:39 +08:00
Coxxs
9552cafaaa gdb: Set correct gThread and cThread when break 2025-06-21 12:54:39 +08:00
Coxxs
066a3c9e56 gdb: Update DebugPc during SVC call and break 2025-06-21 12:54:39 +08:00
Coxxs
eb8b35b170 gdb: Fix crash when gdb client disconnected in some cases 2025-06-21 12:54:39 +08:00
Coxxs
a2b35ecce3 gdb: Add timeout to prevent deadlock in DebugStep
Deadlock can happen when step at some svc instructions.
2025-06-21 12:54:39 +08:00
Coxxs
9c5d81201d gdb: Fix GdbWriteRegister endianness 2025-06-21 12:54:39 +08:00
Coxxs
16ad91d05e gdb: Fix crash on stop emulation if gdb stub is enabled with app running 2025-06-21 12:54:39 +08:00
Coxxs
2a85bfd28a gdb: Remove unused using 2025-06-21 12:54:39 +08:00
Coxxs
b94c083b1a gdb: Add notice when application is suspended on start 2025-06-21 12:54:39 +08:00
Coxxs
fceff066c5 gdb: Wait for the application to start if user connect gdb too early 2025-06-21 12:54:39 +08:00
Coxxs
2cf9c53c05 gdb: Fix crash on exit when not using Debugger 2025-06-21 12:54:39 +08:00
Coxxs
6d583862c1 gdb: Remove redundant log 2025-06-21 12:54:39 +08:00
Coxxs
a553958479 Add GDB Stub
Author: merry, svc64
2025-06-21 12:54:39 +08:00

View file

@ -32,7 +32,6 @@ namespace Ryujinx.HLE.Debugger
private Thread DebuggerThread;
private Thread MessageHandlerThread;
private bool _shuttingDown = false;
private ManualResetEventSlim _breakHandlerEvent = new ManualResetEventSlim(false);
private ulong? cThread;
private ulong? gThread;
@ -238,7 +237,6 @@ namespace Ryujinx.HLE.Debugger
case ThreadBreakMessage { Context: var ctx }:
DebugProcess.DebugStop();
gThread = cThread = ctx.ThreadUid;
_breakHandlerEvent.Set();
Reply($"T05thread:{ctx.ThreadUid:x};");
break;
@ -862,9 +860,6 @@ namespace Ryujinx.HLE.Debugger
}
catch (InvalidMemoryRegionException)
{
// InvalidAccessHandler will show an error message, we log it again to tell user the error is from GDB (which can be ignored)
// TODO: Do not let InvalidAccessHandler show the error message
Logger.Notice.Print(LogClass.GdbStub, $"GDB failed to read memory at 0x{addr:X16}");
ReplyError();
}
}
@ -1271,20 +1266,15 @@ namespace Ryujinx.HLE.Debugger
Messages.Add(new KillMessage());
MessageHandlerThread.Join();
Messages.Dispose();
_breakHandlerEvent.Dispose();
}
}
public void BreakHandler(IExecutionContext ctx, ulong address, int imm)
{
DebugProcess.DebugInterruptHandler(ctx);
_breakHandlerEvent.Reset();
Messages.Add(new ThreadBreakMessage(ctx, address, imm));
// Messages.Add can block, so we log it after adding the message to make sure user can see the log at the same time GDB receives the break message
Logger.Notice.Print(LogClass.GdbStub, $"Break hit on thread {ctx.ThreadUid} at pc {address:x016}");
// Wait for the process to stop before returning to avoid BreakHander being called multiple times from the same breakpoint
_breakHandlerEvent.Wait(5000);
Messages.Add(new ThreadBreakMessage(ctx, address, imm));
DebugProcess.DebugInterruptHandler(ctx);
}
public void StepHandler(IExecutionContext ctx)