[hatari-devel] Catching trap exit?
Nicolas Pomarède
npomarede at corp.free.fr
Mon Oct 18 20:33:11 CEST 2010
Le 18/10/2010 20:01, Eero Tamminen a écrit :
> Hi,
>
> EmuTOS has bug in regards to setting colors with VDI on TT& Falcon and
> I'd like to debug this.
>
> The problem is that current breakpoints break when trap is being entered,
> but the information given to the function is processed after the instruction
> is handled and the effects of the trap function (changed HW registers etc)
> are visible only when the function completes...
>
> So, I'd like to catch trap exit. Any advice how?
>
> (Once I have this, I can chain the breakpoints so that specific trap
> function sets up the exit trap and showing the information + changing
> back to the trap function breakpoint. )
>
One solution could be to add a breakpoint when pc=current_pc + length of
current opcode. This breakpoint would be automatically added when
detecting a breakpoint for a trap for example.
This way, you can add a breakpoint that triggers after a jsr, a bsr or a
trap. This would work whether the routines returns with a rts or a rte.
This requires to compute the number of bytes of current opcode ; I
haven't looked into it, but I think it could be determined by calling
the disassembler routine and see how many bytes were used.
Only false positive could be if the 68000 code decides to change the
stack to change the return address.
example that wouldn't work :
start:
bsr routine
...
...
direct:
nop
...
routine:
...
move.l #direct,(a7)
rts
In that case, return would not be correctly detected, as PC would not be
set to start+4 after reaching the rts.
But I think this use case is rare, and in 99% this approach would work
as expected (and it doesn't require to modify the cpu core)
Nicolas
More information about the hatari-devel
mailing list