Put ThreadUid in the execution context classes

This commit is contained in:
svc64 2023-08-05 14:25:41 +03:00
parent 54bf7507d7
commit d0fbcced57
10 changed files with 32 additions and 5 deletions

View file

@ -71,6 +71,8 @@ namespace ARMeilleure.State
public bool IsAarch32 { get; set; } public bool IsAarch32 { get; set; }
public ulong ThreadUid { get; set; }
internal ExecutionMode ExecutionMode internal ExecutionMode ExecutionMode
{ {
get get

View file

@ -48,6 +48,13 @@ namespace Ryujinx.Cpu.AppleHv
set => _impl.Fpsr = value; set => _impl.Fpsr = value;
} }
/// <inheritdoc/>
public ulong ThreadUid
{
get => _impl.ThreadUid;
set => _impl.ThreadUid = value;
}
/// <inheritdoc/> /// <inheritdoc/>
public bool IsAarch32 public bool IsAarch32
{ {

View file

@ -18,6 +18,8 @@ namespace Ryujinx.Cpu.AppleHv
public bool IsAarch32 { get; set; } public bool IsAarch32 { get; set; }
public ulong ThreadUid { get; set; }
private readonly ulong[] _x; private readonly ulong[] _x;
private readonly V128[] _v; private readonly V128[] _v;

View file

@ -21,6 +21,8 @@ namespace Ryujinx.Cpu.AppleHv
// This is only valid while debugging is enabled. // This is only valid while debugging is enabled.
public ulong DebugPc { get; set; } public ulong DebugPc { get; set; }
public ulong ThreadUid { get; set; }
static HvExecutionContextVcpu() static HvExecutionContextVcpu()
{ {
// .NET does not support passing vectors by value, so we need to pass a pointer and use a native // .NET does not support passing vectors by value, so we need to pass a pointer and use a native

View file

@ -15,7 +15,7 @@ namespace Ryujinx.Cpu.AppleHv
uint Fpcr { get; set; } uint Fpcr { get; set; }
uint Fpsr { get; set; } uint Fpsr { get; set; }
ulong ThreadUid { get; set; }
ulong GetX(int index); ulong GetX(int index);
void SetX(int index, ulong value); void SetX(int index, ulong value);

View file

@ -46,6 +46,11 @@ namespace Ryujinx.Cpu
/// </summary> /// </summary>
bool IsAarch32 { get; set; } bool IsAarch32 { get; set; }
/// <summary>
/// Thread UID.
/// </summary>
public ulong ThreadUid { get; set; }
/// <summary> /// <summary>
/// Indicates whenever the CPU is still running code. /// Indicates whenever the CPU is still running code.
/// </summary> /// </summary>

View file

@ -53,6 +53,13 @@ namespace Ryujinx.Cpu.Jit
set => _impl.IsAarch32 = value; set => _impl.IsAarch32 = value;
} }
/// <inheritdoc/>
public ulong ThreadUid
{
get => _impl.ThreadUid;
set => _impl.ThreadUid = value;
}
/// <inheritdoc/> /// <inheritdoc/>
public bool Running => _impl.Running; public bool Running => _impl.Running;

View file

@ -45,7 +45,6 @@ namespace Ryujinx.HLE.Debugger
private ulong[] GetThreadIds() => Device.System.DebugGetApplicationProcess().DebugGetThreadUids(); private ulong[] GetThreadIds() => Device.System.DebugGetApplicationProcess().DebugGetThreadUids();
private Ryujinx.Cpu.IExecutionContext GetThread(ulong threadUid) => Device.System.DebugGetApplicationProcess().DebugGetThreadContext(threadUid); private Ryujinx.Cpu.IExecutionContext GetThread(ulong threadUid) => Device.System.DebugGetApplicationProcess().DebugGetThreadContext(threadUid);
private Ryujinx.Cpu.IExecutionContext[] GetThreads() => GetThreadIds().Select(x => GetThread(x)).ToArray(); 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 IVirtualMemoryManager GetMemory() => Device.System.DebugGetApplicationProcess().CpuMemory;
private void InvalidateCacheRegion(ulong address, ulong size) => private void InvalidateCacheRegion(ulong address, ulong size) =>
Device.System.DebugGetApplicationProcess().InvalidateCacheRegion(address, size); Device.System.DebugGetApplicationProcess().InvalidateCacheRegion(address, size);
@ -394,7 +393,7 @@ namespace Ryujinx.HLE.Debugger
{ {
if (threadId == 0) if (threadId == 0)
{ {
threadId = GetThreadUid(GetThreads().First()); threadId = GetThreads().First().ThreadUid;
} }
switch (op) switch (op)
@ -502,12 +501,12 @@ namespace Ryujinx.HLE.Debugger
} }
ctx.DebugStep(); ctx.DebugStep();
Reply($"T00thread:{GetThreadUid(ctx):x};"); Reply($"T00thread:{ctx.ThreadUid:x};");
} }
private void CommandIsAlive(ulong? threadId) private void CommandIsAlive(ulong? threadId)
{ {
if (GetThreads().Any(x => GetThreadUid(x) == threadId)) if (GetThreads().Any(x => x.ThreadUid == threadId))
{ {
ReplyOK(); ReplyOK();
} }

View file

@ -17,6 +17,8 @@ namespace Ryujinx.HLE.HOS.Kernel.Process
public bool IsAarch32 { get => false; set { } } public bool IsAarch32 { get => false; set { } }
public ulong ThreadUid { get; set; }
public bool Running { get; private set; } = true; public bool Running { get; private set; } = true;
private readonly ulong[] _x = new ulong[32]; private readonly ulong[] _x = new ulong[32];

View file

@ -204,6 +204,7 @@ namespace Ryujinx.HLE.HOS.Kernel.Threading
Context.TpidrroEl0 = (long)_tlsAddress; Context.TpidrroEl0 = (long)_tlsAddress;
ThreadUid = KernelContext.NewThreadUid(); ThreadUid = KernelContext.NewThreadUid();
Context.ThreadUid = ThreadUid;
HostThread.Name = customThreadStart != null ? $"HLE.OsThread.{ThreadUid}" : $"HLE.GuestThread.{ThreadUid}"; HostThread.Name = customThreadStart != null ? $"HLE.OsThread.{ThreadUid}" : $"HLE.GuestThread.{ThreadUid}";