aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2020-09-29 18:49:08 -0600
committerTom Tromey <tom@tromey.com>2020-09-29 20:29:07 -0600
commit52c14d112840423f0515f7334063f532ec3950b1 (patch)
treed14d72ab4fcd70b11d7ca48a510683ac04aaa47b
parente8e5c1585dc9df0b21ffddd7e6e9053b5512a726 (diff)
downloadbinutils-52c14d112840423f0515f7334063f532ec3950b1.zip
binutils-52c14d112840423f0515f7334063f532ec3950b1.tar.gz
binutils-52c14d112840423f0515f7334063f532ec3950b1.tar.bz2
Change die_info methods to check the attribute's form
This changes two die_info methods to check the form of the attribute before using it. gdb/ChangeLog 2020-09-29 Tom Tromey <tom@tromey.com> * dwarf2/die.h (struct die_info) <addr_base, ranges_base>: Check the attribute's form.
-rw-r--r--gdb/ChangeLog5
-rw-r--r--gdb/dwarf2/die.h22
2 files changed, 22 insertions, 5 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index dbbd0ca..02f686e 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
2020-09-29 Tom Tromey <tom@tromey.com>
+ * dwarf2/die.h (struct die_info) <addr_base, ranges_base>: Check
+ the attribute's form.
+
+2020-09-29 Tom Tromey <tom@tromey.com>
+
* dwarf2/read.c (is_valid_DW_AT_defaulted): Move to attribute.c.
(dwarf2_add_member_fn): Update.
* dwarf2/attribute.h (struct attribute) <defaulted>: Declare.
diff --git a/gdb/dwarf2/die.h b/gdb/dwarf2/die.h
index 5522ebd..4bc15d6 100644
--- a/gdb/dwarf2/die.h
+++ b/gdb/dwarf2/die.h
@@ -20,6 +20,8 @@
#ifndef GDB_DWARF2_DIE_H
#define GDB_DWARF2_DIE_H
+#include "complaints.h"
+
/* This data structure holds a complete die structure. */
struct die_info
{
@@ -40,10 +42,15 @@ struct die_info
{
for (unsigned i = 0; i < num_attrs; ++i)
if (attrs[i].name == DW_AT_addr_base
- || attrs[i].name == DW_AT_GNU_addr_base)
+ || attrs[i].name == DW_AT_GNU_addr_base)
{
- /* If both exist, just use the first one. */
- return DW_UNSND (&attrs[i]);
+ if (attrs[i].form_is_unsigned ())
+ {
+ /* If both exist, just use the first one. */
+ return attrs[i].as_unsigned ();
+ }
+ complaint (_("address base attribute (offset %s) as wrong form"),
+ sect_offset_str (sect_off));
}
return gdb::optional<ULONGEST> ();
}
@@ -57,8 +64,13 @@ struct die_info
if (attrs[i].name == DW_AT_rnglists_base
|| attrs[i].name == DW_AT_GNU_ranges_base)
{
- /* If both exist, just use the first one. */
- return DW_UNSND (&attrs[i]);
+ if (attrs[i].form_is_unsigned ())
+ {
+ /* If both exist, just use the first one. */
+ return attrs[i].as_unsigned ();
+ }
+ complaint (_("ranges base attribute (offset %s) as wrong form"),
+ sect_offset_str (sect_off));
}
return 0;
}