Re: [RFC] Don't allow setting register in non-innermost frame

Doug Evans
2012-08-20T20:19:54Z

On Thu, Aug 16, 2012 at 7:20 PM, Yao Qi <yao@codesourcery.com> wrote:
> Hi,
> When playing with 'set $reg=0xXXX', I am thinking about the expected
> behaviour of setting register when the frame is not innermost. Current
> GDB will invalidate regcaches and reinit frache_caches for any register
> changes (on innermost and non-innermost frame). However, the semantics
> of 'setting register on non-innermost frame' is tricky. On innermost
> frame, 'setting register' means writing something to register in cpu,
> while on non-innermost frame, it means writing something to either
> real register (regcache) or memory (frame). On the other head, I am
> trying to figure out a situation that user has to set register on
> non-innermost frame. Why does this user have to do that?
>
> Literally, IMO, 'set $reg=0xXXXX' means 'setting the cpu register $reg
> to value 0xXXX', which is simple and clear. I propose to restrict
> setting register in innermost frame only. WDYT?
>
> Regression tested on x86_64-linux. Surprisingly, we don't have a test
> case for 'set register', so I add one. In the future, I plan to add
> more tests here for 'set register', such as 'set some bits of a register'
> and 'set multiple registers in one time', to cover the different
> paths in value_assign for 'lval_register'.

I wonder if there'll be a bit of a gnome vs kde battle here. :-)
[the analogy isn't entirely accurate, but it's the best one I could think of]

fwiw, I've been able to work around corrupt, or otherwise not
completely useful, core files by setting registers in non-innermost
frames.
Granted, I knew what was happening underneath the covers, so to speak,
and I could have done things differently, but I like this capability.

If gdb had started out disallowing changing registers in non-innermost
frames, we mightn't be thinking of restricting it now.
"It's easier to relax restrictions than it is to impose them after the fact."
I'd like to hear more justification for this change.
I *could* accept a warning when changing a register in a non-innermost
frame, fwiw.