gdb: Support precise tracking of PC value when GDB Stub is enabled

This commit is contained in:
Coxxs 2025-06-23 07:00:48 +08:00
parent 009d319bc2
commit 838296ccb6
3 changed files with 43 additions and 0 deletions

View file

@ -22,6 +22,11 @@ namespace ARMeilleure.State
public ulong ExclusiveValueHigh;
public int Running;
public long Tpidr2El0;
/// <summary>
/// This is only set when Optimizations.EnableDebugging is true.
/// </summary>
public ulong CurrentPc;
}
private static NativeCtxStorage _dummyStorage = new();
@ -39,6 +44,11 @@ namespace ARMeilleure.State
public ulong GetPc()
{
if (Optimizations.EnableDebugging)
{
return GetStorage().CurrentPc;
}
// TODO: More precise tracking of PC value.
return GetStorage().DispatchAddress;
}
@ -268,6 +278,11 @@ namespace ARMeilleure.State
return StorageOffset(ref _dummyStorage, ref _dummyStorage.Running);
}
public static int GetCurrentPcOffset()
{
return StorageOffset(ref _dummyStorage, ref _dummyStorage.CurrentPc);
}
private static int StorageOffset<T>(ref NativeCtxStorage storage, ref T target)
{
return (int)Unsafe.ByteOffset(ref Unsafe.As<NativeCtxStorage, T>(ref storage), ref target);