[PATCH v2 03/20] Avoid using DW_* macros in dwarf2/attribute.c

Tom Tromey tom@tromey.com
Sat Apr 4 14:43:03 GMT 2020


There's no need to use the DW_* accessor macros in dwarf2/attribute.c,
and this is a necessary step toward our goal of removing them
entirely.

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

	* dwarf2/attribute.c (attribute::address): Don't use DW_UNSND or
	DW_ADDR.
	(attribute::string): Don't use DW_STRING.
	(attribute::get_ref_die_offset): Don't use DW_UNSND.
	(attribute::constant_value): Don't use DW_UNSND or DW_SND.
---
 gdb/ChangeLog          |  8 ++++++++
 gdb/dwarf2/attribute.c | 12 ++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/gdb/dwarf2/attribute.c b/gdb/dwarf2/attribute.c
index 65adaf51b61..3acc13ce151 100644
--- a/gdb/dwarf2/attribute.c
+++ b/gdb/dwarf2/attribute.c
@@ -51,10 +51,10 @@ attribute::as_address () const
 	 as well as update callers to pass in at least the CU's DWARF
 	 version.  This is more overhead than what we're willing to
 	 expand for a pretty rare case.  */
-      addr = DW_UNSND (this);
+      addr = u.unsnd;
     }
   else
-    addr = DW_ADDR (this);
+    addr = u.addr;
 
   return addr;
 }
@@ -73,7 +73,7 @@ attribute::as_string () const
       || form == DW_FORM_strx4
       || form == DW_FORM_GNU_str_index
       || form == DW_FORM_GNU_strp_alt)
-    return DW_STRING (this);
+    return u.str;
   return nullptr;
 }
 
@@ -146,7 +146,7 @@ sect_offset
 attribute::get_ref_die_offset () const
 {
   if (form_is_ref ())
-    return (sect_offset) DW_UNSND (this);
+    return (sect_offset) u.unsnd;
 
   complaint (_("unsupported die ref attribute form: '%s'"),
 	     dwarf_form_name (form));
@@ -159,13 +159,13 @@ LONGEST
 attribute::constant_value (int default_value) const
 {
   if (form == DW_FORM_sdata || form == DW_FORM_implicit_const)
-    return DW_SND (this);
+    return u.snd;
   else if (form == DW_FORM_udata
 	   || form == DW_FORM_data1
 	   || form == DW_FORM_data2
 	   || form == DW_FORM_data4
 	   || form == DW_FORM_data8)
-    return DW_UNSND (this);
+    return u.unsnd;
   else
     {
       /* For DW_FORM_data16 see attribute::form_is_constant.  */
-- 
2.17.2



More information about the Gdb-patches mailing list