diff --git a/src/ARMeilleure/State/ExecutionContext.cs b/src/ARMeilleure/State/ExecutionContext.cs
index 2d57df725d..e4e9cd0e10 100644
--- a/src/ARMeilleure/State/ExecutionContext.cs
+++ b/src/ARMeilleure/State/ExecutionContext.cs
@@ -71,6 +71,8 @@ namespace ARMeilleure.State
public bool IsAarch32 { get; set; }
+ public ulong ThreadUid { get; set; }
+
internal ExecutionMode ExecutionMode
{
get
diff --git a/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs b/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs
index 63b4b2edcf..33549237fc 100644
--- a/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs
+++ b/src/Ryujinx.Cpu/AppleHv/HvExecutionContext.cs
@@ -48,6 +48,13 @@ namespace Ryujinx.Cpu.AppleHv
set => _impl.Fpsr = value;
}
+ ///
+ public ulong ThreadUid
+ {
+ get => _impl.ThreadUid;
+ set => _impl.ThreadUid = value;
+ }
+
///
public bool IsAarch32
{
diff --git a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextShadow.cs b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextShadow.cs
index b9cc08fb2f..034795f081 100644
--- a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextShadow.cs
+++ b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextShadow.cs
@@ -18,6 +18,8 @@ namespace Ryujinx.Cpu.AppleHv
public bool IsAarch32 { get; set; }
+ public ulong ThreadUid { get; set; }
+
private readonly ulong[] _x;
private readonly V128[] _v;
diff --git a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs
index c581698b97..690a5f30d9 100644
--- a/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs
+++ b/src/Ryujinx.Cpu/AppleHv/HvExecutionContextVcpu.cs
@@ -21,6 +21,8 @@ namespace Ryujinx.Cpu.AppleHv
// This is only valid while debugging is enabled.
public ulong DebugPc { get; set; }
+ public ulong ThreadUid { get; set; }
+
static HvExecutionContextVcpu()
{
// .NET does not support passing vectors by value, so we need to pass a pointer and use a native
diff --git a/src/Ryujinx.Cpu/AppleHv/IHvExecutionContext.cs b/src/Ryujinx.Cpu/AppleHv/IHvExecutionContext.cs
index f12ba9dfcd..17be8cc45c 100644
--- a/src/Ryujinx.Cpu/AppleHv/IHvExecutionContext.cs
+++ b/src/Ryujinx.Cpu/AppleHv/IHvExecutionContext.cs
@@ -15,7 +15,7 @@ namespace Ryujinx.Cpu.AppleHv
uint Fpcr { get; set; }
uint Fpsr { get; set; }
-
+ ulong ThreadUid { get; set; }
ulong GetX(int index);
void SetX(int index, ulong value);
diff --git a/src/Ryujinx.Cpu/IExecutionContext.cs b/src/Ryujinx.Cpu/IExecutionContext.cs
index 927ba120d7..b44c4f3186 100644
--- a/src/Ryujinx.Cpu/IExecutionContext.cs
+++ b/src/Ryujinx.Cpu/IExecutionContext.cs
@@ -46,6 +46,11 @@ namespace Ryujinx.Cpu
///
bool IsAarch32 { get; set; }
+ ///
+ /// Thread UID.
+ ///
+ public ulong ThreadUid { get; set; }
+
///
/// Indicates whenever the CPU is still running code.
///
diff --git a/src/Ryujinx.Cpu/Jit/JitExecutionContext.cs b/src/Ryujinx.Cpu/Jit/JitExecutionContext.cs
index fda9e54cb1..2f3e0d59b2 100644
--- a/src/Ryujinx.Cpu/Jit/JitExecutionContext.cs
+++ b/src/Ryujinx.Cpu/Jit/JitExecutionContext.cs
@@ -53,6 +53,13 @@ namespace Ryujinx.Cpu.Jit
set => _impl.IsAarch32 = value;
}
+ ///
+ public ulong ThreadUid
+ {
+ get => _impl.ThreadUid;
+ set => _impl.ThreadUid = value;
+ }
+
///
public bool Running => _impl.Running;
diff --git a/src/Ryujinx.HLE/Debugger/Debugger.cs b/src/Ryujinx.HLE/Debugger/Debugger.cs
index 0a2c43b162..63e540b2ac 100644
--- a/src/Ryujinx.HLE/Debugger/Debugger.cs
+++ b/src/Ryujinx.HLE/Debugger/Debugger.cs
@@ -45,7 +45,6 @@ namespace Ryujinx.HLE.Debugger
private ulong[] GetThreadIds() => Device.System.DebugGetApplicationProcess().DebugGetThreadUids();
private Ryujinx.Cpu.IExecutionContext GetThread(ulong threadUid) => Device.System.DebugGetApplicationProcess().DebugGetThreadContext(threadUid);
private Ryujinx.Cpu.IExecutionContext[] GetThreads() => GetThreadIds().Select(x => GetThread(x)).ToArray();
- private ulong? GetThreadUid(Ryujinx.Cpu.IExecutionContext thread) => GetThreadIds().Where(x => GetThread(x) == thread).First();
private IVirtualMemoryManager GetMemory() => Device.System.DebugGetApplicationProcess().CpuMemory;
private void InvalidateCacheRegion(ulong address, ulong size) =>
Device.System.DebugGetApplicationProcess().InvalidateCacheRegion(address, size);
@@ -394,7 +393,7 @@ namespace Ryujinx.HLE.Debugger
{
if (threadId == 0)
{
- threadId = GetThreadUid(GetThreads().First());
+ threadId = GetThreads().First().ThreadUid;
}
switch (op)
@@ -502,12 +501,12 @@ namespace Ryujinx.HLE.Debugger
}
ctx.DebugStep();
- Reply($"T00thread:{GetThreadUid(ctx):x};");
+ Reply($"T00thread:{ctx.ThreadUid:x};");
}
private void CommandIsAlive(ulong? threadId)
{
- if (GetThreads().Any(x => GetThreadUid(x) == threadId))
+ if (GetThreads().Any(x => x.ThreadUid == threadId))
{
ReplyOK();
}
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessExecutionContext.cs b/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessExecutionContext.cs
index f9718280e3..2cfdbd6873 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessExecutionContext.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/Process/ProcessExecutionContext.cs
@@ -17,6 +17,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public bool IsAarch32 { get => false; set { } }
+ public ulong ThreadUid { get; set; }
+
public bool Running { get; private set; } = true;
private readonly ulong[] _x = new ulong[32];
diff --git a/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs b/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
index 835bf5d405..4e71faf01a 100644
--- a/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
+++ b/src/Ryujinx.HLE/HOS/Kernel/Threading/KThread.cs
@@ -204,6 +204,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
Context.TpidrroEl0 = (long)_tlsAddress;
ThreadUid = KernelContext.NewThreadUid();
+ Context.ThreadUid = ThreadUid;
HostThread.Name = customThreadStart != null ? $"HLE.OsThread.{ThreadUid}" : $"HLE.GuestThread.{ThreadUid}";