diff options
author | Tom Tromey <tom@tromey.com> | 2020-04-24 15:35:01 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2020-04-24 15:35:02 -0600 |
commit | e61108c92d4bc4021ab89671612308c01b18e15d (patch) | |
tree | 02aaf1bc391c6ae0754631220fa0e68e55720ca3 /gdb/dwarf2/attribute.h | |
parent | 8c87a4527f5102b124ad0128894b1195d80eef73 (diff) | |
download | gdb-e61108c92d4bc4021ab89671612308c01b18e15d.zip gdb-e61108c92d4bc4021ab89671612308c01b18e15d.tar.gz gdb-e61108c92d4bc4021ab89671612308c01b18e15d.tar.bz2 |
Add attribute::value_as_string method
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-04-24 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.
Diffstat (limited to 'gdb/dwarf2/attribute.h')
-rw-r--r-- | gdb/dwarf2/attribute.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gdb/dwarf2/attribute.h b/gdb/dwarf2/attribute.h index 69b3351..a9cabd6 100644 --- a/gdb/dwarf2/attribute.h +++ b/gdb/dwarf2/attribute.h @@ -46,6 +46,10 @@ struct attribute attribute's form into account. */ CORE_ADDR value_as_address () const; + /* If the attribute has a string form, return the string value; + otherwise return NULL. */ + const char *value_as_string () const; + /* Return non-zero if ATTR's value is a section offset --- classes lineptr, loclistptr, macptr or rangelistptr --- or zero, otherwise. You may use DW_UNSND (attr) to retrieve such offsets. |