Added preference setting for misaligned memory access

Disabled by default. When enabled misaligned read and writes will be
reported as memory faults
This commit is contained in:
JetSetIlly 2024-04-08 22:19:51 +01:00
parent 110d476389
commit f491504d86
4 changed files with 22 additions and 5 deletions

View file

@ -591,6 +591,11 @@ a memory address that does not exist.
Note that the program will always abort if the access is a PC fetch, even if this option is not set.
Illegal accesses will be logged even if program does not abort.`)
misalignedAccessIsFault := win.img.dbg.VCS().Env.Prefs.ARM.MisalignedAccessIsFault.Get().(bool)
if imgui.Checkbox("Treat Misaligned Accesses as Memory Faults", &misalignedAccessIsFault) {
win.img.dbg.VCS().Env.Prefs.ARM.MisalignedAccessIsFault.Set(misalignedAccessIsFault)
}
}
func (win *winPrefs) drawPlusROMTab() {

View file

@ -219,9 +219,9 @@ type ARM struct {
// prefsPulse ticker slows the rate at which updatePrefs() is called
prefsPulse *time.Ticker
// whether to foce an error on illegal memory access. set from ARM.prefs at
// the start of every arm.Run()
abortOnMemoryFault bool
// read from ARM.prefs every prefsPulse tick
abortOnMemoryFault bool
misalignedAccessIsFault bool
// the speed at which the arm is running at and the required stretching for
// access to flash memory. speed is in MHz. Access latency of Flash memory is
@ -456,8 +456,8 @@ func (arm *ARM) updatePrefs() {
arm.Ncycle = arm.nCycle
}
// memory fault handling
arm.abortOnMemoryFault = arm.prefs.AbortOnMemoryFault.Get().(bool)
arm.misalignedAccessIsFault = arm.prefs.MisalignedAccessIsFault.Get().(bool)
}
func (arm *ARM) String() string {

View file

@ -47,7 +47,9 @@ func (arm *ARM) nullAccess(event string, addr uint32) {
// misalignedAccess is a special condition of illegalAccess()
func (arm *ARM) misalignedAccess(event string, addr uint32) {
arm.memoryFault(event, faults.MisalignedAccess, addr)
if arm.misalignedAccessIsFault {
arm.memoryFault(event, faults.MisalignedAccess, addr)
}
}
func (arm *ARM) read8bit(addr uint32) uint8 {

View file

@ -47,6 +47,11 @@ type ARMPreferences struct {
// abort execution on memory fault (eg. accessing memory that doesn't exist)
AbortOnMemoryFault prefs.Bool
// treat misaligned accesses as a memory fault. (ie. will be reported as a
// memory fault and will cause execution to abort if AbortOnMemoryFault is
// true)
MisalignedAccessIsFault prefs.Bool
// include disassembly and register details when logging memory faults
ExtendedMemoryFaultLogging prefs.Bool
}
@ -87,6 +92,10 @@ func newARMprefrences() (*ARMPreferences, error) {
if err != nil {
return nil, err
}
err = p.dsk.Add("hardware.arm7.MisalignedAccessIsFault", &p.MisalignedAccessIsFault)
if err != nil {
return nil, err
}
err = p.dsk.Add("hardware.arm7.extendedMemoryFaultLogging", &p.ExtendedMemoryFaultLogging)
if err != nil {
return nil, err
@ -107,6 +116,7 @@ func (p *ARMPreferences) SetDefaults() {
p.Immediate.Set(false)
p.MAM.Set(-1)
p.AbortOnMemoryFault.Set(false)
p.MisalignedAccessIsFault.Set(false)
p.ExtendedMemoryFaultLogging.Set(false)
}