From 8bd4417b2450d15ab6343d0356761416feaba4f7 Mon Sep 17 00:00:00 2001 From: merry Date: Sat, 19 Feb 2022 16:12:19 +0000 Subject: [PATCH] Implement qThreadExtraInfo --- src/ARMeilleure/State/ExecutionContext.cs | 5 +++++ src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs | 3 +++ .../AppleHv/HvExecutionContextShadow.cs | 5 +++++ .../AppleHv/HvExecutionContextVcpu.cs | 5 +++++ .../AppleHv/IHvExecutionContext.cs | 1 + src/Ryujinx.Cpu/IExecutionContext.cs | 3 ++- src/Ryujinx.Cpu/Jit/JitExecutionContext.cs | 3 +++ src/Ryujinx.HLE/Debugger/Debugger.cs | 21 +++++++++++++++++++ .../Kernel/Process/ProcessExecutionContext.cs | 5 +++++ 9 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/ARMeilleure/State/ExecutionContext.cs b/src/ARMeilleure/State/ExecutionContext.cs index e4e9cd0e10..47c864bfe7 100644 --- a/src/ARMeilleure/State/ExecutionContext.cs +++ b/src/ARMeilleure/State/ExecutionContext.cs @@ -185,6 +185,11 @@ namespace ARMeilleure.State _debugHalt.Set(); } + public DebugState GetDebugState() + { + return (DebugState)_debugState; + } + internal void OnBreak(ulong address, int imm) { _breakCallback?.Invoke(this, address, imm); diff --git a/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs b/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs index 77a981b10f..e6e33ea6b1 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs @@ -139,6 +139,9 @@ namespace Ryujinx.Cpu.AppleHv /// public void DebugContinue() => _impl.DebugContinue(); + /// + public DebugState GetDebugState() => _impl.GetDebugState(); + /// public ulong DebugPc { diff --git a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextShadow.cs b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextShadow.cs index 034795f081..24eefc42d6 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextShadow.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextShadow.cs @@ -68,6 +68,11 @@ namespace Ryujinx.Cpu.AppleHv { } + public DebugState GetDebugState() + { + return DebugState.Stopped; + } + public bool GetAndClearInterruptRequested() { return false; diff --git a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs index 690a5f30d9..03d426331f 100644 --- a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs +++ b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs @@ -228,6 +228,11 @@ namespace Ryujinx.Cpu.AppleHv HvApi.hv_vcpu_run(_vcpu); } + public DebugState GetDebugState() + { + return (DebugState)_debugState; + } + public bool GetAndClearInterruptRequested() { return Interlocked.Exchange(ref _interruptRequested, 0) != 0; diff --git a/src/Ryujinx.Cpu/AppleHv/IHvExecutionContext.cs b/src/Ryujinx.Cpu/AppleHv/IHvExecutionContext.cs index 17be8cc45c..f49509db9a 100644 --- a/src/Ryujinx.Cpu/AppleHv/IHvExecutionContext.cs +++ b/src/Ryujinx.Cpu/AppleHv/IHvExecutionContext.cs @@ -47,6 +47,7 @@ namespace Ryujinx.Cpu.AppleHv void DebugStop(); bool DebugStep(); void DebugContinue(); + DebugState GetDebugState(); ulong DebugPc { get; set; } } diff --git a/src/Ryujinx.Cpu/IExecutionContext.cs b/src/Ryujinx.Cpu/IExecutionContext.cs index b44c4f3186..6df28292e0 100644 --- a/src/Ryujinx.Cpu/IExecutionContext.cs +++ b/src/Ryujinx.Cpu/IExecutionContext.cs @@ -118,7 +118,8 @@ namespace Ryujinx.Cpu void DebugStop(); bool DebugStep(); void DebugContinue(); - + DebugState GetDebugState(); + ulong DebugPc { get; set; } } } diff --git a/src/Ryujinx.Cpu/Jit/JitExecutionContext.cs b/src/Ryujinx.Cpu/Jit/JitExecutionContext.cs index 2f3e0d59b2..1a8d54c96d 100644 --- a/src/Ryujinx.Cpu/Jit/JitExecutionContext.cs +++ b/src/Ryujinx.Cpu/Jit/JitExecutionContext.cs @@ -125,6 +125,9 @@ namespace Ryujinx.Cpu.Jit /// public void DebugContinue() => _impl.DebugContinue(); + /// + public DebugState GetDebugState() => _impl.GetDebugState(); + /// public ulong DebugPc { diff --git a/src/Ryujinx.HLE/Debugger/Debugger.cs b/src/Ryujinx.HLE/Debugger/Debugger.cs index d065d4aaa8..00986c3b53 100644 --- a/src/Ryujinx.HLE/Debugger/Debugger.cs +++ b/src/Ryujinx.HLE/Debugger/Debugger.cs @@ -295,6 +295,27 @@ namespace Ryujinx.HLE.Debugger break; } + if (ss.ConsumePrefix("ThreadExtraInfo,")) + { + ulong? threadId = ss.ReadRemainingAsThreadUid(); + if (threadId == null) + { + ReplyError(); + break; + } + + IExecutionContext ctx = GetThread(threadId.Value); + if (ctx.GetDebugState() == DebugState.Stopped) + { + Reply(ToHex("Stopped")); + } + else + { + Reply(ToHex("Not stopped")); + } + break; + } + if (ss.ConsumePrefix("Xfer:features:read:")) { string feature = ss.ReadUntil(':'); diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessExecutionContext.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessExecutionContext.cs index 2cfdbd6873..7dc1178810 100644 --- a/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessExecutionContext.cs +++ b/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessExecutionContext.cs @@ -48,6 +48,11 @@ namespace Ryujinx.HLE.HOS.Kernel.Process { } + public DebugState GetDebugState() + { + return DebugState.Stopped; + } + public void StopRunning() { Running = false;