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 ulong ThreadUid { get; set; }
internal ExecutionMode ExecutionMode
{
get

View File

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

View File

@ -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;

View File

@ -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

View File

@ -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);

View File

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

View File

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

View File

@ -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();
}

View File

@ -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];

View File

@ -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}";