I understand this is not a bug in the "core" gdb code but anyway...

Version: gdb-4.18

File: gdb-4.18/sim/arm/armsupp.c, line 226

Function: ARMul_FixSPSR

Comment: This function emulates ARM's "msr spsr_xx, xx" opcode. When the
case is "msr spsr_all, xx", we want to transfer "xx" to the *entire*
spsr (see for example, "ARM7TDMI Data Sheet", p. 4-22) while the
simulator masks out the undefined bits (this is not surely correct, but
does not affect real code) and the thumb bit (this is *bad*). This makes
impossible to correctly restore the thumb bit in the saved psr register.
It is surely a very unusual situation that occurs only in low level code
(a context switch, for example). I have cross-checked the above with an
"official" Armulator.

Proposed fix: Change line 226 from
    if (BITS(16,19)==9) SETPSR(state->Spsr[state->Bank],rhs) ;
to a simple
    if (BITS(16,19)==9) state->Spsr[state->Bank] = rhs ;

Best regards,
Demetres Hanos

Reply via email to