Throughout, call read_encoded_value with ptr_size rather than addr_size.
(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. Set ptr_size dependent
on examined frame section. Add comment to explain why.
* 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.
+2010-08-06 Corinna Vinschen <vinschen@redhat.com>
+
+ * dwarf2-frame.c (struct dwarf2_cie): Add ptr_size member.
+ Throughout, call read_encoded_value with ptr_size rather than addr_size.
+ (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. Set ptr_size dependent
+ on examined frame section. Add comment to explain why.
+ * 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.
+
2010-08-06 Jan Kratochvil <jan.kratochvil@redhat.com>
Code cleanup.
/* Target address size in bytes. */
int addr_size;
+ /* Target pointer size in bytes. */
+ int ptr_size;
+
/* True if a 'z' augmentation existed. */
unsigned char saw_z_augmentation;
{
case DW_CFA_set_loc:
fs->pc = read_encoded_value (fde->cie->unit, fde->cie->encoding,
- fde->cie->addr_size, insn_ptr,
+ fde->cie->ptr_size, insn_ptr,
&bytes_read, fde->initial_location);
/* Apply the objfile offset for relocatable objects. */
fs->pc += ANOFFSET (fde->cie->unit->objfile->section_offsets,
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;
}
else
{
- cie->addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
+ cie->addr_size = gdbarch_dwarf2_addr_size (gdbarch);
cie->segment_size = 0;
}
+ /* Address values in .eh_frame sections are defined to have the
+ target's pointer size. Watchout: This breaks frame info for
+ targets with pointer size < address size, unless a .debug_frame
+ section exists as well. */
+ if (eh_frame_p)
+ cie->ptr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
+ else
+ cie->ptr_size = cie->addr_size;
cie->code_alignment_factor =
read_unsigned_leb128 (unit->abfd, buf, &bytes_read);
{
/* Skip. Avoid indirection since we throw away the result. */
gdb_byte encoding = (*buf++) & ~DW_EH_PE_indirect;
- read_encoded_value (unit, encoding, cie->addr_size,
+ read_encoded_value (unit, encoding, cie->ptr_size,
buf, &bytes_read, 0);
buf += bytes_read;
augmentation++;
gdb_assert (fde->cie != NULL);
fde->initial_location =
- read_encoded_value (unit, fde->cie->encoding, fde->cie->addr_size,
+ read_encoded_value (unit, fde->cie->encoding, fde->cie->ptr_size,
buf, &bytes_read, 0);
buf += bytes_read;
fde->address_range =
read_encoded_value (unit, fde->cie->encoding & 0x0f,
- fde->cie->addr_size, buf, &bytes_read, 0);
+ fde->cie->ptr_size, buf, &bytes_read, 0);
buf += bytes_read;
/* A 'z' augmentation in the CIE implies the presence of an
const struct floatformat ** long_double_format;
int ptr_bit;
int addr_bit;
+ int dwarf2_addr_size;
int char_signed;
gdbarch_read_pc_ftype *read_pc;
gdbarch_write_pc_ftype *write_pc;
0, /* long_double_format */
8 * sizeof (void*), /* ptr_bit */
8 * sizeof (void*), /* addr_bit */
+ sizeof (void*), /* dwarf2_addr_size */
1, /* char_signed */
0, /* read_pc */
0, /* write_pc */
/* Skip verify of ptr_bit, invalid_p == 0 */
if (gdbarch->addr_bit == 0)
gdbarch->addr_bit = gdbarch_ptr_bit (gdbarch);
+ if (gdbarch->dwarf2_addr_size == 0)
+ gdbarch->dwarf2_addr_size = gdbarch_ptr_bit (gdbarch) / TARGET_CHAR_BIT;
if (gdbarch->char_signed == -1)
gdbarch->char_signed = 1;
/* Skip verify of read_pc, has predicate */
fprintf_unfiltered (file,
"gdbarch_dump: dummy_id = <%s>\n",
host_address_to_string (gdbarch->dummy_id));
+ fprintf_unfiltered (file,
+ "gdbarch_dump: dwarf2_addr_size = %s\n",
+ plongest (gdbarch->dwarf2_addr_size));
fprintf_unfiltered (file,
"gdbarch_dump: dwarf2_reg_to_regnum = <%s>\n",
host_address_to_string (gdbarch->dwarf2_reg_to_regnum));
gdbarch->addr_bit = addr_bit;
}
+int
+gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch)
+{
+ gdb_assert (gdbarch != NULL);
+ /* Check variable changed from pre-default. */
+ gdb_assert (gdbarch->dwarf2_addr_size != 0);
+ if (gdbarch_debug >= 2)
+ fprintf_unfiltered (gdb_stdlog, "gdbarch_dwarf2_addr_size called\n");
+ return gdbarch->dwarf2_addr_size;
+}
+
+void
+set_gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch,
+ int dwarf2_addr_size)
+{
+ gdbarch->dwarf2_addr_size = dwarf2_addr_size;
+}
+
int
gdbarch_char_signed (struct gdbarch *gdbarch)
{
/ 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 */
extern int gdbarch_addr_bit (struct gdbarch *gdbarch);
extern void set_gdbarch_addr_bit (struct gdbarch *gdbarch, int addr_bit);
+/* dwarf2_addr_size is the target address size as used in the Dwarf debug
+ info. 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.
+
+ dwarf2_addr_size is not used for .eh_frame FDEs, which are generally
+ defined using the target's pointer size so far.
+
+ 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. */
+
+extern int gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch);
+extern void set_gdbarch_dwarf2_addr_size (struct gdbarch *gdbarch, int dwarf2_addr_size);
+
/* One if `char' acts like `signed char', zero if `unsigned char'. */
extern int gdbarch_char_signed (struct gdbarch *gdbarch);
# / 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 in the Dwarf debug
+# info. 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.
+#
+# dwarf2_addr_size is not used for .eh_frame FDEs, which are generally
+# defined using the target's pointer size so far.
+#
+# 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
#
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);