]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Change die_info methods to check the attribute's form
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:07 +0000 (20:29 -0600)
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.

gdb/ChangeLog
gdb/dwarf2/die.h

index dbbd0caa1467f2648b6c0719d22d4e5b1d86d64e..02f686ea43e9106858261d626ef66175690e952b 100644 (file)
@@ -1,3 +1,8 @@
+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.
index 5522ebdf3114f013b70184811c930db8d90be194..4bc15d631e3ff02c8d708e20a6ab0de3369e0d91 100644 (file)
@@ -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;
   }