DWARF-5 Fix DW_FORM_implicit_const
authorJan Kratochvil <jan.kratochvil@redhat.com>
Thu, 24 Aug 2017 14:39:11 +0000 (16:39 +0200)
committerJan Kratochvil <jan.kratochvil@redhat.com>
Thu, 24 Aug 2017 14:39:11 +0000 (16:39 +0200)
-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  <jan.kratochvil@redhat.com>

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
gdb/dwarf2read.c

index 5dba51dce4af927ad5501e3701f447829d33205c..ff402163debc572c4bb58137c713dc4c035b6b58 100644 (file)
@@ -1,3 +1,10 @@
+2017-08-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+       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  <jan.kratochvil@redhat.com>
 
        * dwarf2read.c (build_type_psymtabs_reader): New prototype.
index 483d8eac48d9f9c2a712f50799107b892101bb79..ead4f3ca350a113675b0ecf9f428ae6e0e526773 100644 (file)
@@ -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;