Memory exception: Add facility to track size

Might theoretically help in tracking some things down.

Not fully utilized yet, the fault handler needs to extract the
information from the faulting instruction. But we can use it for
GetPointerRange etc.
This commit is contained in:
Henrik Rydgård committed 2023-01-01 20:30:29 +01:00
1 parent a4d3e0ead8
commit aa80659530
6 files changed
+27 -18

No files matched your search

+9 -6
View File
@@ -40,7 +40,9 @@ u8 *GetPointerWrite(const u32 address) {
Reporting::ReportMessage("Unknown GetPointerWrite %08x PC %08x LR %08x", address, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
reported = true;
}
Core_MemoryException(address, currentMIPS->pc, MemoryExceptionType::WRITE_BLOCK);
// Size is not known, we pass 0 to signal that.
Core_MemoryException(address, 0, currentMIPS->pc, MemoryExceptionType::WRITE_BLOCK);
return nullptr;
}
}
@@ -57,7 +59,8 @@ const u8 *GetPointer(const u32 address) {
Reporting::ReportMessage("Unknown GetPointer %08x PC %08x LR %08x", address, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
reported = true;
}
Core_MemoryException(address, currentMIPS->pc, MemoryExceptionType::READ_BLOCK);
// Size is not known, we pass 0 to signal that.
Core_MemoryException(address, 0, currentMIPS->pc, MemoryExceptionType::READ_BLOCK);
return nullptr;
}
}
@@ -67,7 +70,7 @@ u8 *GetPointerWriteRange(const u32 address, const u32 size) {
if (ptr) {
if (ValidSize(address, size) != size) {
// That's a memory exception! TODO: Adjust reported address to the end of the range?
Core_MemoryException(address, currentMIPS->pc, MemoryExceptionType::WRITE_BLOCK);
Core_MemoryException(address, size, currentMIPS->pc, MemoryExceptionType::WRITE_BLOCK);
return nullptr;
} else {
return ptr;
@@ -83,7 +86,7 @@ const u8 *GetPointerRange(const u32 address, const u32 size) {
if (ptr) {
if (ValidSize(address, size) != size) {
// That's a memory exception! TODO: Adjust reported address to the end of the range?
Core_MemoryException(address, currentMIPS->pc, MemoryExceptionType::READ_BLOCK);
Core_MemoryException(address, size, currentMIPS->pc, MemoryExceptionType::READ_BLOCK);
return nullptr;
} else {
return ptr;
@@ -115,7 +118,7 @@ inline void ReadFromHardware(T &var, const u32 address) {
Reporting::ReportMessage("ReadFromHardware: Invalid address %08x near PC %08x LR %08x", address, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
reported = true;
}
Core_MemoryException(address, currentMIPS->pc, MemoryExceptionType::READ_WORD);
Core_MemoryException(address, sizeof(T), currentMIPS->pc, MemoryExceptionType::READ_WORD);
var = 0;
}
}
@@ -140,7 +143,7 @@ inline void WriteToHardware(u32 address, const T data) {
Reporting::ReportMessage("WriteToHardware: Invalid address %08x near PC %08x LR %08x", address, currentMIPS->pc, currentMIPS->r[MIPS_REG_RA]);
reported = true;
}
Core_MemoryException(address, currentMIPS->pc, MemoryExceptionType::WRITE_WORD);
Core_MemoryException(address, sizeof(T), currentMIPS->pc, MemoryExceptionType::WRITE_WORD);
}
}