Re: [PATCH] Remove bogosities from dwarf2cfi.c:cfi_pop_frame()

Andrew Cagney
2002-07-10T16:18:00Z

> Mark
>> >
>> > Index: ChangeLog
>> > from Mark Kettenis <kettenis@gnu.org>
>> >
>> > * dwarf2cfi.c (cfi_pop_frame): Use alloca() for regbuf.
>> > Don't call get_current_frame().
>> >
>
>>
>> Heads up,
>>
>> I think the write_register_bytes() call should be replaced by
>> regcache_register_write(current_regcache, ). This is new code so it
>> doesn't need to go through any of that nasty write_register_bytes() stuff.
>>
>> Andrew
>>
>>
>
>
> Why is this code trying to poke directly into the regcache at all? AFAICT
> it should be operating on the pseudo registers not the cache.

[cooked]

Hmm, yes, good point. It should at least use regcache_cpy() so that it
is ``bug compatible'' with generic_pop_dummy_frame()(1).

At present GDB saves/restores registers in a confused sort of way.
Firstly, the save/restore operation (see regcache_cpy):

- for old targets it iterates over 0..NUM_REGS (the full raw register
space) using write_register_bytes() to restore the registers.

- for new targets it iterates over 0..NUM_REGS (the full raw register
space) using regcache_write() to directly transfer the raw registers.

It then uses this single mechanism(2) to handle two orthogonal
situtations, and that is the problem:

- saving / restoring a raw register cache before / after an inferior
function call. Here, a select list of raw registers should be transfered.

- unwinding a stack frame, storing those unwound register values, and
hence having the effect of poping one or more frames. Here, a select
list of cooked registers should be stored.

Andrew

(1) I also suspect that some cleanups would let the function in question
be eliminated from dwarf2cfi but that is another story.

(2) I believe the regcache changes were ``bug compatible''.