This is the mail archive of the gdb-patches@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: [rfa] frame address size incorrect if address size != ptr size


On Aug  5 16:07, Ulrich Weigand wrote:
> Corinna Vinschen wrote:
> > [...]
> > If not, I would prefer a solution like this:
> > 
> >   - If version > 4, use addr_size from .debug_frame section
> >   - Otherwise, if we can fetch the target address size from the CU
> >     header, use it.
> >   - Otherwise, if the target defined gdbarch_dwarf2_addr_size, use it.
> >   - Otherwise, default to gdbarch_addr_bit for .debug_frame sections
> >     and to gdbarch_ptr_bit for .eh_frame sections.
> 
> As I said, finding the .debug_info may be difficult.  Also, I'd really
> avoid getting another dependency on gdbarch_addr_bit in there; the point
> of having a new callback is exactly to avoid overloading addr_bit with
> more and more (possibly) different meanings.
> 
> I'd rather just have gdbarch_dwarf2_addr_size default unconditionally
> to gdbarch_ptr_bit.  In dwarf2-frame we'd then simply use the embedded
> addr_size if version >= 4, and gdbarch_dwarf2_addr_size otherwise.
> Platforms where ptr_bit is not appropriate simply need to define
> gdbarch_dwarf2_addr_size -- since this list is very short, and defining
> gdbarch_dwarf2_addr_size correctly is very simple (you just need to look
> at the definition of DWARF2_ADDR_SIZE in the corresponding GCC back-end),
> that doesn't seem like an unreasonable restriction to me ...
> 
> > > As a side note, it seems odd that add_size is set in those two
> > > different locations here.  The first one is always overwritten
> > > by the second one anyway, isn't it?
> > 
> > There's an early return statement after checking the version number.
> > That indicates a failure anyway, so it might be ok to set addr_size
> > only once, at the second spot (lines 1779ff).
> 
> Yes, that sounds right to me.

Ok, I agree with all you say above.

I'm going to create a patch which defines and uses a new
gdbarch_dwarf2_addr_size function.  It will be defined as a variable
like this in gdbarch.sh:

  v:int:dwarf2_addr_size:::sizeof (void*):0:gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT:

Given that, and also given that I will remove the redundant setting of
cie->addr_size in decode_frame_entry_1, I have one question left.

What about that comment in decode_frame_entry_1?

If we only use either the V4 addr_size, or the gdbarch_dwarf2_addr_size
function, then the comment really doesn't make much sense anymore in that
spot.  I'm wondering if it should be moved to the gdbarch.sh file.  What
do you think?


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


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