From 8e941e4a8f5b73878f03fd1a9eca06eaa4defde5 Mon Sep 17 00:00:00 2001 From: Coxxs <58-coxxs@users.noreply.git.ryujinx.app> Date: Thu, 16 Oct 2025 19:53:51 -0500 Subject: [PATCH] gdb: Cleanup (ryubing/ryujinx!171) See merge request ryubing/ryujinx!171 --- src/Ryujinx.HLE/Debugger/BreakpointManager.cs | 33 ++----------------- src/Ryujinx.HLE/Debugger/Debugger.cs | 5 +++ .../Debugger/Gdb/CommandProcessor.cs | 4 +-- .../Debugger/RegisterInformation.cs | 2 +- 4 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/Ryujinx.HLE/Debugger/BreakpointManager.cs b/src/Ryujinx.HLE/Debugger/BreakpointManager.cs index bf462a781..c660b298d 100644 --- a/src/Ryujinx.HLE/Debugger/BreakpointManager.cs +++ b/src/Ryujinx.HLE/Debugger/BreakpointManager.cs @@ -11,12 +11,9 @@ namespace Ryujinx.HLE.Debugger { public byte[] OriginalData { get; } - public bool IsStep { get; } - - public Breakpoint(byte[] originalData, bool isStep) + public Breakpoint(byte[] originalData) { OriginalData = originalData; - IsStep = isStep; } } @@ -44,7 +41,7 @@ namespace Ryujinx.HLE.Debugger /// The length of the instruction to replace. /// Indicates if this is a single-step breakpoint. /// True if the breakpoint was set successfully; otherwise, false. - public bool SetBreakPoint(ulong address, ulong length, bool isStep = false) + public bool SetBreakPoint(ulong address, ulong length) { if (_breakpoints.ContainsKey(address)) { @@ -71,7 +68,7 @@ namespace Ryujinx.HLE.Debugger return false; } - var breakpoint = new Breakpoint(originalInstruction, isStep); + var breakpoint = new Breakpoint(originalInstruction); if (_breakpoints.TryAdd(address, breakpoint)) { Logger.Debug?.Print(LogClass.GdbStub, $"Breakpoint set at 0x{address:X16}"); @@ -124,30 +121,6 @@ namespace Ryujinx.HLE.Debugger Logger.Debug?.Print(LogClass.GdbStub, "All breakpoints cleared."); } - /// - /// Clears all currently set single-step software breakpoints. - /// - public void ClearAllStepBreakpoints() - { - var stepBreakpoints = _breakpoints.Where(p => p.Value.IsStep).ToList(); - - if (stepBreakpoints.Count == 0) - { - return; - } - - foreach (var bp in stepBreakpoints) - { - if (_breakpoints.TryRemove(bp.Key, out Breakpoint removedBreakpoint)) - { - WriteMemory(bp.Key, removedBreakpoint.OriginalData); - } - } - - Logger.Debug?.Print(LogClass.GdbStub, "All step breakpoints cleared."); - } - - private byte[] GetBreakInstruction(ulong length) { if (_debugger.IsProcessAarch32) diff --git a/src/Ryujinx.HLE/Debugger/Debugger.cs b/src/Ryujinx.HLE/Debugger/Debugger.cs index e03f05b7f..cc64a38eb 100644 --- a/src/Ryujinx.HLE/Debugger/Debugger.cs +++ b/src/Ryujinx.HLE/Debugger/Debugger.cs @@ -103,6 +103,10 @@ namespace Ryujinx.HLE.Debugger { Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e); } + catch (ObjectDisposedException e) + { + Logger.Error?.Print(LogClass.GdbStub, "Error while processing GDB messages", e); + } } } @@ -304,6 +308,7 @@ namespace Ryujinx.HLE.Debugger WriteStream = null; ClientSocket.Close(); ClientSocket = null; + CommandProcessor = null; BreakpointManager.ClearAll(); } diff --git a/src/Ryujinx.HLE/Debugger/Gdb/CommandProcessor.cs b/src/Ryujinx.HLE/Debugger/Gdb/CommandProcessor.cs index 19b3b7a2b..e9986647d 100644 --- a/src/Ryujinx.HLE/Debugger/Gdb/CommandProcessor.cs +++ b/src/Ryujinx.HLE/Debugger/Gdb/CommandProcessor.cs @@ -310,7 +310,7 @@ namespace Ryujinx.HLE.Debugger.Gdb switch (type) { case "0": // Software breakpoint - if (!Commands.Debugger.BreakpointManager.SetBreakPoint(addr, len, false)) + if (!Commands.Debugger.BreakpointManager.SetBreakPoint(addr, len)) { Commands.ReplyError(); return; @@ -325,7 +325,7 @@ namespace Ryujinx.HLE.Debugger.Gdb Commands.ReplyError(); return; default: - Commands. ReplyError(); + Commands.ReplyError(); return; } } diff --git a/src/Ryujinx.HLE/Debugger/RegisterInformation.cs b/src/Ryujinx.HLE/Debugger/RegisterInformation.cs index b5fd88ea5..b43899271 100644 --- a/src/Ryujinx.HLE/Debugger/RegisterInformation.cs +++ b/src/Ryujinx.HLE/Debugger/RegisterInformation.cs @@ -17,7 +17,7 @@ namespace Ryujinx.HLE.Debugger private static string GetEmbeddedResourceContent(string resourceName) { - Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.HLE.Debugger.GdbXml." + resourceName); + Stream stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Ryujinx.HLE.Debugger.Gdb.Xml." + resourceName); StreamReader reader = new StreamReader(stream); string result = reader.ReadToEnd(); reader.Dispose();