[07/13] Use attribute::unsigned_constant for DW_AT_data_member_location

Message ID 20250320-attribute-madness-v1-7-79d42789f881@adacore.com
State New
Headers
Series More work on DW_FORM_* and sign handling |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 fail Patch failed to apply
linaro-tcwg-bot/tcwg_gdb_build--master-arm fail Patch failed to apply

Commit Message

Tom Tromey March 20, 2025, 7:27 p.m. UTC
  This changes the DWARF reader to use attribute::unsigned_constant for
DW_AT_data_member_location.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32680
---
 gdb/dwarf2/read.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
  

Patch

diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 18f03f0eb7ce552ef5383a34b1112cb12230678d..eabe07107d9ac01c3a4403d45b75f7ebcfd57d78 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -10010,7 +10010,7 @@  handle_member_location (struct die_info *die, struct dwarf2_cu *cu,
 	 so if we see it, we can assume that a constant form is really
 	 a constant and not a section offset.  */
       if (attr->form_is_constant ())
-	*offset = attr->constant_value (0);
+	*offset = attr->unsigned_constant ().value_or (0);
       else if (attr->form_is_section_offset ())
 	dwarf2_complex_location_expr_complaint ();
       else if (attr->form_is_block ()
@@ -10050,7 +10050,7 @@  handle_member_location (struct die_info *die, struct dwarf2_cu *cu,
     {
       if (attr->form_is_constant ())
 	{
-	  LONGEST offset = attr->constant_value (0);
+	  LONGEST offset = attr->unsigned_constant ().value_or (0);
 
 	  /* Work around this GCC 11 bug, where it would erroneously use -1
 	     data member locations, instead of 0:
@@ -12402,7 +12402,7 @@  mark_common_block_symbol_computed (struct symbol *sym,
 
   if (member_loc->form_is_constant ())
     {
-      offset = member_loc->constant_value (0);
+      offset = member_loc->unsigned_constant ().value_or (0);
       baton->size += 1 /* DW_OP_addr */ + cu->header.addr_size;
     }
   else