Print stack trace on invalid memory accesses
This commit is contained in:
parent
76330b10b4
commit
d6fa0e1771
3 changed files with 37 additions and 1 deletions
14
ChocolArm64/Events/AInvalidAccessEventArgs.cs
Normal file
14
ChocolArm64/Events/AInvalidAccessEventArgs.cs
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace ChocolArm64.Events
|
||||||
|
{
|
||||||
|
public class AInvalidAccessEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public long Position { get; private set; }
|
||||||
|
|
||||||
|
public AInvalidAccessEventArgs(long Position)
|
||||||
|
{
|
||||||
|
this.Position = Position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
using ChocolArm64.Events;
|
||||||
using ChocolArm64.Exceptions;
|
using ChocolArm64.Exceptions;
|
||||||
using ChocolArm64.State;
|
using ChocolArm64.State;
|
||||||
using System;
|
using System;
|
||||||
|
@ -51,6 +52,8 @@ namespace ChocolArm64.Memory
|
||||||
|
|
||||||
private byte*** PageTable;
|
private byte*** PageTable;
|
||||||
|
|
||||||
|
public event EventHandler<AInvalidAccessEventArgs> InvalidAccess;
|
||||||
|
|
||||||
public AMemory(IntPtr Ram)
|
public AMemory(IntPtr Ram)
|
||||||
{
|
{
|
||||||
Monitors = new Dictionary<int, ArmMonitor>();
|
Monitors = new Dictionary<int, ArmMonitor>();
|
||||||
|
@ -512,6 +515,8 @@ Unmapped:
|
||||||
return (byte*)Ptr + (Position & PageMask);
|
return (byte*)Ptr + (Position & PageMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvalidAccess?.Invoke(this, new AInvalidAccessEventArgs(Position));
|
||||||
|
|
||||||
throw new VmmPageFaultException(Position);
|
throw new VmmPageFaultException(Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,6 +565,8 @@ Unmapped:
|
||||||
return (byte*)Ptr + (Position & PageMask);
|
return (byte*)Ptr + (Position & PageMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InvalidAccess?.Invoke(this, new AInvalidAccessEventArgs(Position));
|
||||||
|
|
||||||
throw new VmmPageFaultException(Position);
|
throw new VmmPageFaultException(Position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,8 @@ namespace Ryujinx.HLE.HOS
|
||||||
|
|
||||||
Memory = new AMemory(Device.Memory.RamPointer);
|
Memory = new AMemory(Device.Memory.RamPointer);
|
||||||
|
|
||||||
|
Memory.InvalidAccess += CpuInvalidAccessHandler;
|
||||||
|
|
||||||
MemoryManager = new KMemoryManager(this);
|
MemoryManager = new KMemoryManager(this);
|
||||||
|
|
||||||
TlsPages = new List<KTlsPageManager>();
|
TlsPages = new List<KTlsPageManager>();
|
||||||
|
@ -96,7 +98,7 @@ namespace Ryujinx.HLE.HOS
|
||||||
|
|
||||||
Executables = new List<Executable>();
|
Executables = new List<Executable>();
|
||||||
|
|
||||||
ImageBase = MemoryManager.CodeRegionStart;
|
ImageBase = 0x8000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadProgram(IExecutable Program)
|
public void LoadProgram(IExecutable Program)
|
||||||
|
@ -334,6 +336,19 @@ namespace Ryujinx.HLE.HOS
|
||||||
return Translator;
|
return Translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CpuInvalidAccessHandler(object sender, AInvalidAccessEventArgs e)
|
||||||
|
{
|
||||||
|
foreach (KThread Thread in Threads.Values)
|
||||||
|
{
|
||||||
|
if (Thread.Thread.IsCurrentThread())
|
||||||
|
{
|
||||||
|
PrintStackTrace(Thread.Thread.ThreadState);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void PrintStackTrace(AThreadState ThreadState)
|
public void PrintStackTrace(AThreadState ThreadState)
|
||||||
{
|
{
|
||||||
StringBuilder Trace = new StringBuilder();
|
StringBuilder Trace = new StringBuilder();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue