This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: find_saved_register(frame) -> next/prev frame?
- To: Andrew Cagney <ac131313 at cygnus dot com>
- Subject: Re: find_saved_register(frame) -> next/prev frame?
- From: Elena Zannoni <ezannoni at cygnus dot com>
- Date: Fri, 21 Jul 2000 12:57:09 -0400 (EDT)
- Cc: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- References: <39694282.8066451A@cygnus.com>
Andrew Cagney writes:
> Hello,
>
> The function find_saved_register() uses:
>
> /* Note that this next routine assumes that registers used in
> frame x will be saved only in the frame that x calls and
> frames interior to it. This is not true on the sparc, but the
> above macro takes care of it, so we should be all right. */
> while (1)
> {
> QUIT;
> frame1 = get_prev_frame (frame1);
> if (frame1 == 0 || frame1 == frame)
> break;
> FRAME_INIT_SAVED_REGS (frame1);
> if (frame1->saved_regs[regnum])
> addr = frame1->saved_regs[regnum];
> }
>
> find the frame that contains a registers value. I'm right now very
> confused as I think it is looking in the wrong direction.
>
> Consider the stack:
>
> main()
> -> outer ()
> saves r1, r2
> -> middle ()
> saves r2, r3
> -> inner()
> saves r1, r3
>
> lets assume that we've just selected the frame for middle(). I think we
> should find register values at:
>
> r1: in inner()' stack frame
> r2: in the register cache
> r3: in inner()'s stack frame
>
> Looking at the above implementation. My understanding of
> ``get_prev_frame()'' is that it goes to the next _outer_ frame. It
> should be calling get_next_frame() going to the next inner frame. It
> also appears to contract the comment attatched to the code.
>
> Can I rename get_next_frame() to get_inner_frame() and get_prev_frame()
> to get_outer_frame() :-)
>
> Andrew
>
> PS: I should note that this code has remained largely unchanged since
> '91 (which is as far back as CVS history goes!) so either something
> really wierd is going on or I'm missing something obvious - I guess we
> suspect the latter.
It seems that find_saved_register is called only by mips_get_saved_register()
and default_get_saved_register().
There is another function, generic_get_saved_register() in
blockframe.c which is basically identical to
default_get_saved_register and which doesn't call
find_saved_register(). Maybe the author realized that
find_saved_register() was wrong, but didn't want to touch the exisitng
code.
Probably we should switch the macro GET_SAVED_REGISTER to be
generic_get_saved_register instead of default_get_saved_register and
see what happens.
Elena