From 55a43dea456e1da01c24266d62f7d7130fa41575 Mon Sep 17 00:00:00 2001 From: Coxxs <58-coxxs@users.noreply.git.ryujinx.app> Date: Sat, 21 Jun 2025 14:31:00 +0800 Subject: [PATCH 1/2] gdb: Fix ExecutionContext --- src/ARMeilleure/State/ExecutionContext.cs | 6 +++--- .../LightningJit/State/ExecutionContext.cs | 13 ++++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ARMeilleure/State/ExecutionContext.cs b/src/ARMeilleure/State/ExecutionContext.cs index c44c6e062..fa1a4a032 100644 --- a/src/ARMeilleure/State/ExecutionContext.cs +++ b/src/ARMeilleure/State/ExecutionContext.cs @@ -153,7 +153,7 @@ namespace ARMeilleure.State public void StepHandler() { - _stepCallback.Invoke(this); + _stepCallback?.Invoke(this); } public void RequestDebugStep() @@ -166,7 +166,7 @@ namespace ARMeilleure.State { if (Optimizations.EnableDebugging) { - DebugPc = Pc; // TODO: Is this the best place to update DebugPc? + DebugPc = Pc; } _breakCallback?.Invoke(this, address, imm); @@ -176,7 +176,7 @@ namespace ARMeilleure.State { if (Optimizations.EnableDebugging) { - DebugPc = Pc; // TODO: Is this the best place to update DebugPc? + DebugPc = Pc; } _supervisorCallback?.Invoke(this, address, imm); diff --git a/src/Ryujinx.Cpu/LightningJit/State/ExecutionContext.cs b/src/Ryujinx.Cpu/LightningJit/State/ExecutionContext.cs index fc75e5185..cb3c6c2af 100644 --- a/src/Ryujinx.Cpu/LightningJit/State/ExecutionContext.cs +++ b/src/Ryujinx.Cpu/LightningJit/State/ExecutionContext.cs @@ -1,3 +1,4 @@ +using ARMeilleure; using ARMeilleure.Memory; using ARMeilleure.State; using System; @@ -127,7 +128,7 @@ namespace Ryujinx.Cpu.LightningJit.State public void StepHandler() { - _stepCallback.Invoke(this); + _stepCallback?.Invoke(this); } public void RequestDebugStep() @@ -138,11 +139,21 @@ namespace Ryujinx.Cpu.LightningJit.State internal void OnBreak(ulong address, int imm) { + if (Optimizations.EnableDebugging) + { + DebugPc = Pc; + } + _breakCallback?.Invoke(this, address, imm); } internal void OnSupervisorCall(ulong address, int imm) { + if (Optimizations.EnableDebugging) + { + DebugPc = Pc; + } + _supervisorCallback?.Invoke(this, address, imm); } From 6afce6308cbb9833afcd8f5d7067ae00a419141e Mon Sep 17 00:00:00 2001 From: Coxxs <58-coxxs@users.noreply.git.ryujinx.app> Date: Sat, 21 Jun 2025 15:38:32 +0800 Subject: [PATCH 2/2] gdb: Do not use LightningJitEngine when GDB Stub is enabled --- src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs b/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs index 759780c42..28f7ef25f 100644 --- a/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs +++ b/src/Ryujinx.HLE/HOS/ArmProcessContextFactory.cs @@ -69,7 +69,7 @@ namespace Ryujinx.HLE.HOS mode = MemoryManagerMode.SoftwarePageTable; } - ICpuEngine cpuEngine = isArm64Host && (mode == MemoryManagerMode.HostMapped || mode == MemoryManagerMode.HostMappedUnsafe) + ICpuEngine cpuEngine = isArm64Host && (mode == MemoryManagerMode.HostMapped || mode == MemoryManagerMode.HostMappedUnsafe) && !context.Device.Configuration.EnableGdbStub ? new LightningJitEngine(_tickSource) : new JitEngine(_tickSource);