aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2read.c
diff options
context:
space:
mode:
authorJan Kratochvil <jan.kratochvil@redhat.com>2009-08-28 10:49:06 +0000
committerJan Kratochvil <jan.kratochvil@redhat.com>2009-08-28 10:49:06 +0000
commitd4b96c9a787ed13b0b9367b5fedb96a4746a5c9d (patch)
treefaed0eb7803149e34aadfca246afe0f26431d60b /gdb/dwarf2read.c
parent12b1a97932e2ae3112bbb389c81e4c80fff86c90 (diff)
downloadgdb-d4b96c9a787ed13b0b9367b5fedb96a4746a5c9d.zip
gdb-d4b96c9a787ed13b0b9367b5fedb96a4746a5c9d.tar.gz
gdb-d4b96c9a787ed13b0b9367b5fedb96a4746a5c9d.tar.bz2
gdb/
Support constant DW_AT_data_member_location by GCC PR debug/40659. * dwarf2read.c (dwarf2_add_field <DW_TAG_member> <DW_AT_data_member_location>): Initialize BYTE_OFFSET to 0 by default. Explicitly check if attr_form_is_block. (dwarf2_add_field <DW_TAG_inheritance> <DW_AT_data_member_location>) (read_common_block <DW_AT_data_member_location>): New variable byte_offset. Fix crash on non-DW_BLOCK ATTR values. gdb/testsuite/ Support constant DW_AT_data_member_location by GCC PR debug/40659. * gdb.dwarf2/dw2-inheritance.exp, gdb.dwarf2/dw2-inheritance.S: New.
Diffstat (limited to 'gdb/dwarf2read.c')
-rw-r--r--gdb/dwarf2read.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index 445bab8..7f04427 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4385,17 +4385,16 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
attr = dwarf2_attr (die, DW_AT_data_member_location, cu);
if (attr)
{
- int byte_offset;
+ int byte_offset = 0;
if (attr_form_is_section_offset (attr))
- {
- dwarf2_complex_location_expr_complaint ();
- byte_offset = 0;
- }
+ dwarf2_complex_location_expr_complaint ();
else if (attr_form_is_constant (attr))
byte_offset = dwarf2_get_attr_constant_value (attr, 0);
- else
+ else if (attr_form_is_block (attr))
byte_offset = decode_locdesc (DW_BLOCK (attr), cu);
+ else
+ dwarf2_complex_location_expr_complaint ();
SET_FIELD_BITPOS (*fp, byte_offset * bits_per_byte);
}
@@ -4490,8 +4489,20 @@ dwarf2_add_field (struct field_info *fip, struct die_info *die,
/* C++ base class field. */
attr = dwarf2_attr (die, DW_AT_data_member_location, cu);
if (attr)
- SET_FIELD_BITPOS (*fp, decode_locdesc (DW_BLOCK (attr), cu)
- * bits_per_byte);
+ {
+ int byte_offset = 0;
+
+ if (attr_form_is_section_offset (attr))
+ dwarf2_complex_location_expr_complaint ();
+ else if (attr_form_is_constant (attr))
+ byte_offset = dwarf2_get_attr_constant_value (attr, 0);
+ else if (attr_form_is_block (attr))
+ byte_offset = decode_locdesc (DW_BLOCK (attr), cu);
+ else
+ dwarf2_complex_location_expr_complaint ();
+
+ SET_FIELD_BITPOS (*fp, byte_offset * bits_per_byte);
+ }
FIELD_BITSIZE (*fp) = 0;
FIELD_TYPE (*fp) = die_type (die, cu);
FIELD_NAME (*fp) = type_name_no_tag (fp->type);
@@ -5438,8 +5449,18 @@ read_common_block (struct die_info *die, struct dwarf2_cu *cu)
attr = dwarf2_attr (child_die, DW_AT_data_member_location, cu);
if (attr)
{
- SYMBOL_VALUE_ADDRESS (sym) =
- base + decode_locdesc (DW_BLOCK (attr), cu);
+ CORE_ADDR byte_offset = 0;
+
+ if (attr_form_is_section_offset (attr))
+ dwarf2_complex_location_expr_complaint ();
+ else if (attr_form_is_constant (attr))
+ byte_offset = dwarf2_get_attr_constant_value (attr, 0);
+ else if (attr_form_is_block (attr))
+ byte_offset = decode_locdesc (DW_BLOCK (attr), cu);
+ else
+ dwarf2_complex_location_expr_complaint ();
+
+ SYMBOL_VALUE_ADDRESS (sym) = base + byte_offset;
add_symbol_to_list (sym, &global_symbols);
}
child_die = sibling_die (child_die);