Add attribute::value_as_string method
authorTom Tromey <tom@tromey.com>
Wed, 30 Sep 2020 00:49:08 +0000 (18:49 -0600)
committerTom Tromey <tom@tromey.com>
Wed, 30 Sep 2020 02:29:06 +0000 (20:29 -0600)
The full DIE reader checks that an attribute has a "string" form in
some spots, but the partial DIE reader does not.  This patch brings
the two readers in sync for one specific case, namely when examining
the linkage name.  This avoids regressions in an existing DWARF test
case.

A full fix for this problem would be preferable.  An accessor like
DW_STRING should always check the form.  However, I haven't attempted
that in this series.

Also the fact that the partial and full readers can disagree like this
is a design flaw.

gdb/ChangeLog
2020-09-29  Tom Tromey  <tom@tromey.com>

* dwarf2/read.c (partial_die_info::read) <case
DW_AT_linkage_name>: Use value_as_string.
(dwarf2_string_attr): Use value_as_string.
* dwarf2/attribute.h (struct attribute) <value_as_string>: Declare
method.
* dwarf2/attribute.c (attribute::value_as_string): New method.

gdb/ChangeLog
gdb/dwarf2/read.c

index 28e34fba04fa65f51d2d3f67ba7aeb8615a1b491..cd5958ccc4459fed0bac8c0cff5ea775693800bd 100644 (file)
@@ -1,3 +1,12 @@
+2020-09-29  Tom Tromey  <tom@tromey.com>
+
+       * dwarf2/read.c (partial_die_info::read) <case
+       DW_AT_linkage_name>: Use value_as_string.
+       (dwarf2_string_attr): Use value_as_string.
+       * dwarf2/attribute.h (struct attribute) <value_as_string>: Declare
+       method.
+       * dwarf2/attribute.c (attribute::value_as_string): New method.
+
 2020-09-29  Pedro Alves  <pedro@palves.net>
 
        * unittests/enum-flags-selftests.c: Check whether __GNUC__ is
index 977bdb856893b7794d4c32b1b97aef5a157aa9df..3a2a918f4ed42fbc9587355ec7a8e5d90fbd650f 100644 (file)
@@ -19031,11 +19031,6 @@ partial_die_info::read (const struct die_reader_specs *reader,
             assume they will be the same, and we only store the last
             one we see.  */
          linkage_name = attr.value_as_string ();
-         /* rustc emits invalid values for DW_AT_linkage_name.  Ignore these.
-            See https://github.com/rust-lang/rust/issues/32925.  */
-         if (cu->language == language_rust && linkage_name != NULL
-             && strchr (linkage_name, '{') != NULL)
-           linkage_name = NULL;
          break;
        case DW_AT_low_pc:
          has_low_pc_attr = 1;