Re: RFA/ARM: Switch mode when setting PC

Andrew Cagney
2004-01-16T19:12:21Z

> For example, if the user writes a 32-bit value into the PC, the CPSR state
>> > probably shouldn't be changed (even if the bottom bit is altered) -- this
>> > is how ARM's debuggers behave. However, if the user 'calls' a function
>> > that is in the 'other state', then the CPSR should be updated (and
>> > presumably restored afterwards).
>> >
>> > I'm not sure if GDB has a way of separating these two cases. It's an
>> > interesting problem.
>
>>
>> I believe that this will work at present, because setting $pc will not
>> go through write_pc. There's some blind luck involved in this, though.

Or a lack of design, Arm needs to ensure that it doesn't define PC_REGNUM.

> In the past we've tried to distinguish R15 from PC. This was especially
> useful in the legacy 26-bit mode where the CPSR bits *were* in R15.
>
> This would probably all have been much simpler if I'd been able to
> complete my code for handling the banked register; sadly I never got far
> enough, and I think the code is probably too bit-rotten to be worth trying
> to resurrect directly at this point.

If there's an explicit "set_resume_address", separate to write_pc, this
should happen:

(gdb) set $r15 = 0x123
- target sees:
$r15=0x123
(gdb) call foo() OR (gdb) jump foo
- target, via "set_resume_address", sees:
$r15=&foo
$ps&|=<magic-bits>

and significantly no other write_pc calls.

Andrew