This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC] Using values to handle unwinding


On Fri, Oct 19, 2007 at 02:10:07PM +0200, Ulrich Weigand wrote:
> I think this is an excellent idea.  I'm wondering how this plays with
> special conversions needed for certain registers, see e.g. the
> discussion we had last December that led to introduction of the
> value_from_register gdbarch callback.
> 
> For example, while we do have ways of performing special conversions
> on the registers themselves, there is no straightforward way to do so
> for unwound register contents.  Maybe if we're going to using values
> to represent those, we could allow the architecture to perform type-
> specific conversions on those (this should e.g. allow me to eliminate
> a specical pseudo on the SPU that I'm using to hold the properly
> converted unwound stack pointer register contents).

I see we ended up with both "gdbarch_value_from_register" and
"gdbarch_register_to_value".  That's unfortunately confusing :-(

The patch I posted should make things neither better nor worse,
because reading a variable from a register (hardware or saved in a
frame) will still call value_from_register.  We'll get the raw bytes
by using the value method but call gdbarch_value_from_register and
get_frame_register_bytes for the final value.  So everything works
the same as before.

Perhaps we can adjust value_from_register to convert one struct value
* representing a register's contents to another representing its value
in a particular type?  It's a machine-dependent variant of a cast.

> B.t.w. there's another change in the patch: the elimination of the
> prev_pc unwinder method.  Could you explain the reason why this is
> now no longer necessary?

Sorry, I should have separated that out.  There is only one definition
of prev_pc anywhere.  Here it is:

static CORE_ADDR
sentinel_frame_prev_pc (struct frame_info *next_frame,
                        void **this_prologue_cache)
{
  struct gdbarch *gdbarch = get_frame_arch (next_frame);
  return gdbarch_unwind_pc (gdbarch, next_frame);
}

And here's the call, with comments removed for brevity:

      if (this_frame->unwind->prev_pc != NULL)
        /* A per-frame unwinder, prefer it.  */
        pc = this_frame->unwind->prev_pc (this_frame->next,
                                          &this_frame->prologue_cache);
      else if (gdbarch_unwind_pc_p (get_frame_arch (this_frame)))
        pc = gdbarch_unwind_pc (get_frame_arch (this_frame), this_frame);

So, as you can see, there's no longer any need for the hook in current
targets.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]