mirror of
https://git.naxdy.org/Mirror/Ryujinx.git
synced 2024-12-30 20:43:05 +00:00
Re-add cpu tracing
This commit is contained in:
parent
c88e942362
commit
19f89abe69
4 changed files with 72 additions and 4 deletions
|
@ -1,8 +1,10 @@
|
||||||
using ChocolArm64.Decoder;
|
using ChocolArm64.Decoder;
|
||||||
|
using ChocolArm64.Events;
|
||||||
using ChocolArm64.Instruction;
|
using ChocolArm64.Instruction;
|
||||||
using ChocolArm64.Memory;
|
using ChocolArm64.Memory;
|
||||||
using ChocolArm64.State;
|
using ChocolArm64.State;
|
||||||
using ChocolArm64.Translation;
|
using ChocolArm64.Translation;
|
||||||
|
using System;
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
using System.Reflection.Emit;
|
using System.Reflection.Emit;
|
||||||
|
|
||||||
|
@ -12,6 +14,10 @@ namespace ChocolArm64
|
||||||
{
|
{
|
||||||
private ConcurrentDictionary<long, ATranslatedSub> CachedSubs;
|
private ConcurrentDictionary<long, ATranslatedSub> CachedSubs;
|
||||||
|
|
||||||
|
public event EventHandler<ACpuTraceEventArgs> CpuTrace;
|
||||||
|
|
||||||
|
public bool EnableCpuTrace { get; set; }
|
||||||
|
|
||||||
public ATranslator()
|
public ATranslator()
|
||||||
{
|
{
|
||||||
CachedSubs = new ConcurrentDictionary<long, ATranslatedSub>();
|
CachedSubs = new ConcurrentDictionary<long, ATranslatedSub>();
|
||||||
|
@ -50,6 +56,11 @@ namespace ChocolArm64
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
if (EnableCpuTrace)
|
||||||
|
{
|
||||||
|
CpuTrace?.Invoke(this, new ACpuTraceEventArgs(Position));
|
||||||
|
}
|
||||||
|
|
||||||
if (!CachedSubs.TryGetValue(Position, out ATranslatedSub Sub))
|
if (!CachedSubs.TryGetValue(Position, out ATranslatedSub Sub))
|
||||||
{
|
{
|
||||||
Sub = TranslateTier0(State, Memory, Position);
|
Sub = TranslateTier0(State, Memory, Position);
|
||||||
|
|
14
ChocolArm64/Events/ACpuTraceEventArgs.cs
Normal file
14
ChocolArm64/Events/ACpuTraceEventArgs.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ChocolArm64.Events
|
||||||
|
{
|
||||||
|
public class ACpuTraceEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public long Position { get; private set; }
|
||||||
|
|
||||||
|
public ACpuTraceEventArgs(long Position)
|
||||||
|
{
|
||||||
|
this.Position = Position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -197,7 +197,7 @@ namespace Ryujinx.HLE.OsHle
|
||||||
throw new ObjectDisposedException(nameof(Process));
|
throw new ObjectDisposedException(nameof(Process));
|
||||||
}
|
}
|
||||||
|
|
||||||
AThread CpuThread = new AThread(new ATranslator(), Memory, EntryPoint);
|
AThread CpuThread = new AThread(GetTranslator(), Memory, EntryPoint);
|
||||||
|
|
||||||
KThread Thread = new KThread(CpuThread, this, ProcessorId, Priority);
|
KThread Thread = new KThread(CpuThread, this, ProcessorId, Priority);
|
||||||
|
|
||||||
|
@ -239,6 +239,49 @@ namespace Ryujinx.HLE.OsHle
|
||||||
throw new UndefinedInstructionException(e.Position, e.RawOpCode);
|
throw new UndefinedInstructionException(e.Position, e.RawOpCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void EnableCpuTracing()
|
||||||
|
{
|
||||||
|
Translator.EnableCpuTrace = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisableCpuTracing()
|
||||||
|
{
|
||||||
|
Translator.EnableCpuTrace = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CpuTraceHandler(object sender, ACpuTraceEventArgs e)
|
||||||
|
{
|
||||||
|
Executable Exe = GetExecutable(e.Position);
|
||||||
|
|
||||||
|
if (Exe == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!TryGetSubName(Exe, e.Position, out string SubName))
|
||||||
|
{
|
||||||
|
SubName = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
long Offset = e.Position - Exe.ImageBase;
|
||||||
|
|
||||||
|
string ExeNameWithAddr = $"{Exe.Name}:0x{Offset:x8}";
|
||||||
|
|
||||||
|
Ns.Log.PrintDebug(LogClass.Cpu, ExeNameWithAddr + " " + SubName);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ATranslator GetTranslator()
|
||||||
|
{
|
||||||
|
if (Translator == null)
|
||||||
|
{
|
||||||
|
Translator = new ATranslator();
|
||||||
|
|
||||||
|
Translator.CpuTrace += CpuTraceHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Translator;
|
||||||
|
}
|
||||||
|
|
||||||
public void PrintStackTrace(AThreadState ThreadState)
|
public void PrintStackTrace(AThreadState ThreadState)
|
||||||
{
|
{
|
||||||
StringBuilder Trace = new StringBuilder();
|
StringBuilder Trace = new StringBuilder();
|
||||||
|
@ -265,9 +308,9 @@ namespace Ryujinx.HLE.OsHle
|
||||||
|
|
||||||
long Offset = Position - Exe.ImageBase;
|
long Offset = Position - Exe.ImageBase;
|
||||||
|
|
||||||
string ExeNameWithAddr = $"{Exe.Name}:{Offset:x8}";
|
string ExeNameWithAddr = $"{Exe.Name}:0x{Offset:x8}";
|
||||||
|
|
||||||
Trace.AppendLine(" " + SubName + " (" + ExeNameWithAddr + ")");
|
Trace.AppendLine(" " + ExeNameWithAddr + " " + SubName);
|
||||||
}
|
}
|
||||||
|
|
||||||
long FramePointer = (long)ThreadState.X29;
|
long FramePointer = (long)ThreadState.X29;
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
Enable_Memory_Checks = false
|
Enable_Memory_Checks = false
|
||||||
|
|
||||||
#Enable print debug logs
|
#Enable print debug logs
|
||||||
Logging_Enable_Debug = false
|
Logging_Enable_Debug = true
|
||||||
|
|
||||||
#Enable print stubbed calls logs
|
#Enable print stubbed calls logs
|
||||||
Logging_Enable_Stub = true
|
Logging_Enable_Stub = true
|
||||||
|
|
Loading…
Reference in a new issue