This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [rfa] frame address size incorrect if address size != ptr size
On Aug 5 16:58, Ulrich Weigand wrote:
> Corinna Vinschen wrote:
>
> > 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:
>
> Looks good, thanks.
>
> > 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?
>
> I agree. In fact, the comment in gdbarch.sh could even be expanded to
> say that gdbarch_dwarf2_addr_size needs to be defined if and only if the
> platform GCC back-end defines a non-default DWARF2_ADDR_SIZE (and is only
> necessary if Dwarf versions < 4 need to be supported).
Yes, that makes sense. See the patch below. It contains all the generic
parts as well as the patch to xstormy16-tdep.c which I used to verify that
the new function works fine, and that the dwarf2_frame_find_fde function
works as advertised now on XStormy16.
Is the generic part ok to apply?
Thanks,
Corinna
* dwarf2-frame.c (decode_frame_entry_1): Remove redundant setting of
addr_size. Call gdbarch_dwarf2_addr_size rather than gdbarch_ptr_bit
to determine addr_size in Dwarf versions < 4.
* gdbarch.sh (dwarf2_addr_size): Define as variable. Add lengthy
comment to explain usage.
* gdbarch.c: Regenerate.
* gdbarch.h: Regenerate.
* xstormy16-tdep.c (xstormy16_gdbarch_init): Set dwarf2_addr_size to 4.
Index: dwarf2-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
retrieving revision 1.114
diff -u -p -r1.114 dwarf2-frame.c
--- dwarf2-frame.c 7 Jul 2010 17:26:38 -0000 1.114
+++ dwarf2-frame.c 5 Aug 2010 15:25:27 -0000
@@ -1732,13 +1732,6 @@ decode_frame_entry_1 (struct comp_unit *
depends on the target address size. */
cie->encoding = DW_EH_PE_absptr;
- /* The target address size. For .eh_frame FDEs this is considered
- equal to the size of a target pointer. For .dwarf_frame FDEs,
- this is supposed to be the target address size from the associated
- CU header. FIXME: We do not have a good way to determine the
- latter. Always use the target pointer size for now. */
- cie->addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
-
/* We'll determine the final value later, but we need to
initialize it conservatively. */
cie->signal_frame = 0;
@@ -1779,7 +1772,7 @@ decode_frame_entry_1 (struct comp_unit *
}
else
{
- cie->addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
+ cie->addr_size = gdbarch_dwarf2_addr_size (gdbarch);
cie->segment_size = 0;
}
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.514
diff -u -p -r1.514 gdbarch.sh
--- gdbarch.sh 19 Jul 2010 17:51:23 -0000 1.514
+++ gdbarch.sh 5 Aug 2010 15:25:28 -0000
@@ -384,14 +384,27 @@ v:const struct floatformat **:long_doubl
# / addr_bit will be set from it.
#
# If gdbarch_ptr_bit and gdbarch_addr_bit are different, you'll probably
-# also need to set gdbarch_pointer_to_address and gdbarch_address_to_pointer
-# as well.
+# also need to set gdbarch_dwarf2_addr_size, gdbarch_pointer_to_address and
+# gdbarch_address_to_pointer as well.
#
# ptr_bit is the size of a pointer on the target
v:int:ptr_bit:::8 * sizeof (void*):gdbarch->int_bit::0
# addr_bit is the size of a target address as represented in gdb
v:int:addr_bit:::8 * sizeof (void*):0:gdbarch_ptr_bit (gdbarch):
#
+# dwarf2_addr_size is the target address size as used int the Dwarf debug
+# info. For .eh_frame FDEs this is considered equal to the size of a target
+# pointer. For .debug_frame FDEs, this is supposed to be the target address
+# size from the associated CU header, and which is equivalent to the
+# DWARF2_ADDR_SIZE as defined by the target specific GCC back-end.
+# Unfortunately there is no good way to determine this value. Therefore
+# dwarf2_addr_size simply defaults to the target pointer size.
+#
+# Note that dwarf2_addr_size only needs to be redefined by a target if the
+# GCC back-end defines a DWARF2_ADDR_SIZE other than the target pointer size,
+# and if Dwarf versions < 4 need to be supported.
+v:int:dwarf2_addr_size:::sizeof (void*):0:gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT:
+#
# One if \`char' acts like \`signed char', zero if \`unsigned char'.
v:int:char_signed:::1:-1:1
#
Index: xstormy16-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/xstormy16-tdep.c,v
retrieving revision 1.110
diff -u -p -r1.110 xstormy16-tdep.c
--- xstormy16-tdep.c 1 Jan 2010 07:31:46 -0000 1.110
+++ xstormy16-tdep.c 5 Aug 2010 15:25:28 -0000
@@ -809,6 +809,7 @@ xstormy16_gdbarch_init (struct gdbarch_i
set_gdbarch_ptr_bit (gdbarch, 2 * TARGET_CHAR_BIT);
set_gdbarch_addr_bit (gdbarch, 4 * TARGET_CHAR_BIT);
+ set_gdbarch_dwarf2_addr_size (gdbarch, 4);
set_gdbarch_address_to_pointer (gdbarch, xstormy16_address_to_pointer);
set_gdbarch_pointer_to_address (gdbarch, xstormy16_pointer_to_address);
--
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat