From 663c44ac4d4336e99c282705b1d289b365b273d3 Mon Sep 17 00:00:00 2001 From: Jan Kratochvil Date: Thu, 24 Aug 2017 16:39:11 +0200 Subject: [PATCH] DWARF-5 Fix DW_FORM_implicit_const -gdwarf-4: ptype logical type = const char [2] (gdb) PASS: gdb.base/constvars.exp: ptype logical -gdwarf-5: ptype logical type = const char [] (gdb) FAIL: gdb.base/constvars.exp: ptype logical <2><2fc>: Abbrev Number: 1 (DW_TAG_variable) <2fd> DW_AT_name : (indirect string, offset: 0x2eb): logical <301> DW_AT_decl_file : 1 1 DW_TAG_variable [no children] DW_AT_name DW_FORM_strp DW_AT_decl_file DW_FORM_implicit_const: 1 During symbol reading, invalid attribute class or form for 'DW_FORM_implicit_const' in '(null)'. gdb/ChangeLog 2017-08-24 Jan Kratochvil PR symtab/22003 * dwarf2read.c (dwarf2_const_value_attr, dump_die_shallow) (dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes) (skip_form_bytes, attr_form_is_constant): Handle DW_FORM_implicit_const. --- gdb/ChangeLog | 7 +++++++ gdb/dwarf2read.c | 12 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 5dba51dce4a..ff402163deb 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,10 @@ +2017-08-24 Jan Kratochvil + + PR symtab/22003 + * dwarf2read.c (dwarf2_const_value_attr, dump_die_shallow) + (dwarf2_get_attr_constant_value, dwarf2_fetch_constant_bytes) + (skip_form_bytes, attr_form_is_constant): Handle DW_FORM_implicit_const. + 2017-08-24 Jan Kratochvil * dwarf2read.c (build_type_psymtabs_reader): New prototype. diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c index 483d8eac48d..ead4f3ca350 100644 --- a/gdb/dwarf2read.c +++ b/gdb/dwarf2read.c @@ -19522,6 +19522,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, break; case DW_FORM_sdata: + case DW_FORM_implicit_const: *value = DW_SND (attr); break; @@ -20515,6 +20516,10 @@ dump_die_shallow (struct ui_file *f, int indent, struct die_info *die) fprintf_unfiltered (f, "unexpected attribute form: DW_FORM_indirect"); break; + case DW_FORM_implicit_const: + fprintf_unfiltered (f, "constant: %s", + plongest (DW_SND (&die->attrs[i]))); + break; default: fprintf_unfiltered (f, "unsupported attribute form: %d.", die->attrs[i].form); @@ -20606,7 +20611,7 @@ dwarf2_get_ref_die_offset (const struct attribute *attr) static LONGEST dwarf2_get_attr_constant_value (const struct attribute *attr, int default_value) { - if (attr->form == DW_FORM_sdata) + if (attr->form == DW_FORM_sdata || attr->form == DW_FORM_implicit_const) return DW_SND (attr); else if (attr->form == DW_FORM_udata || attr->form == DW_FORM_data1 @@ -20941,6 +20946,7 @@ dwarf2_fetch_constant_bytes (sect_offset sect_off, break; case DW_FORM_sdata: + case DW_FORM_implicit_const: type = die_type (die, cu); result = write_constant_as_bytes (obstack, byte_order, type, DW_SND (attr), len); @@ -21877,6 +21883,9 @@ skip_form_bytes (bfd *abfd, const gdb_byte *bytes, const gdb_byte *buffer_end, } break; + case DW_FORM_implicit_const: + break; + default: { complain: @@ -22518,6 +22527,7 @@ attr_form_is_constant (const struct attribute *attr) case DW_FORM_data2: case DW_FORM_data4: case DW_FORM_data8: + case DW_FORM_implicit_const: return 1; default: return 0; -- 2.30.2