[binutils-gdb] gdb: convert address_class_type_flags to address_class_dwarf_to_id

Tankut Baris Aktemur via Gdb-cvs <[email protected]> Thu, 23 Jul 2026 10:12:44 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D3a9d1daac230=
f3bd6400c3945ed530a5fa6d3202

commit 3a9d1daac230f3bd6400c3945ed530a5fa6d3202
Author: Tankut Baris Aktemur <[email protected]>
Date:   Thu Jul 23 05:04:42 2026 -0500

    gdb: convert address_class_type_flags to address_class_dwarf_to_id
   =20
    The gdbarch method 'address_class_type_flags' is used for letting an
    architecture translate the DW_AT_address_class attribute to an address
    class id.  Make this clear by refactoring the method to return an id,
    instead of a whole type instance flags value.  There is hardcoding of
    "<< 4" left in dwarf/read.c.  This will go away in a future patch.
   =20
    Approved-By: Tom Tromey <[email protected]>

Diff:
---
 gdb/avr-tdep.c            | 17 ++++++++---------
 gdb/dwarf2/read.c         |  8 +++++---
 gdb/ft32-tdep.c           | 15 ++++++++-------
 gdb/gdbarch-gen.c         | 32 ++++++++++++++++----------------
 gdb/gdbarch-gen.h         | 11 +++++++----
 gdb/gdbarch_components.py |  8 ++++++--
 gdb/s390-tdep.c           | 12 ++++++------
 7 files changed, 56 insertions(+), 47 deletions(-)

diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 58330eececd..2191ada4c2e 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -75,8 +75,6 @@
 /* We are assigning the id 1 to the flash address space.  */
=20
 #define AVR_ADDRESS_CLASS_FLASH 1
-#define AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH	\
-  TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
=20
=20
 enum
@@ -1370,20 +1368,20 @@ avr_dwarf_reg_to_regnum (struct gdbarch *gdbarch, i=
nt reg)
   return -1;
 }
=20
-/* Implementation of `address_class_type_flags' gdbarch method.
+/* Implementation of `address_class_dwarf_to_id' gdbarch method.
=20
-   This method maps DW_AT_address_class attributes to a
-   type_instance_flag_value.  */
+   This method maps a DW_AT_address_class attribute to an address
+   class id.  */
=20
-static type_instance_flags
-avr_address_class_type_flags (int byte_size, int dwarf2_addr_class)
+static unsigned int
+avr_address_class_dwarf_to_id (int byte_size, int dwarf2_addr_class)
 {
   /* The value 1 of the DW_AT_address_class attribute corresponds to the
      __flash qualifier.  Note that this attribute is only valid with
      pointer types and therefore the flag is set to the pointer type and
      not its target type.  */
   if (dwarf2_addr_class =3D=3D 1 && byte_size =3D=3D 2)
-    return AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH;
+    return AVR_ADDRESS_CLASS_FLASH;
   return 0;
 }
=20
@@ -1534,7 +1532,8 @@ avr_gdbarch_init (struct gdbarch_info info, struct gd=
barch_list *arches)
   set_gdbarch_unwind_pc (gdbarch, avr_unwind_pc);
   set_gdbarch_unwind_sp (gdbarch, avr_unwind_sp);
=20
-  set_gdbarch_address_class_type_flags (gdbarch, avr_address_class_type_fl=
ags);
+  set_gdbarch_address_class_dwarf_to_id
+    (gdbarch, avr_address_class_dwarf_to_id);
   set_gdbarch_address_class_name_to_id
     (gdbarch, avr_address_class_name_to_id);
   set_gdbarch_address_class_id_to_name
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 114c608fde3..3671e39daa2 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -12051,11 +12051,13 @@ read_tag_pointer_type (struct die_info *die, stru=
ct dwarf2_cu *cu)
 	  && alignment !=3D TYPE_RAW_ALIGN (type))
       || addr_class !=3D DW_ADDR_none)
     {
-      if (gdbarch_address_class_type_flags_p (gdbarch))
+      if (gdbarch_address_class_dwarf_to_id_p (gdbarch))
 	{
+	  unsigned int aclass
+	    =3D gdbarch_address_class_dwarf_to_id (gdbarch, byte_size,
+						 addr_class);
 	  type_instance_flags type_flags
-	    =3D gdbarch_address_class_type_flags (gdbarch, byte_size,
-						addr_class);
+	    =3D (enum type_instance_flag_value) (aclass << 4);
 	  gdb_assert ((type_flags & ~TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
 		      =3D=3D 0);
 	  type =3D make_type_with_address_space (type, type_flags);
diff --git a/gdb/ft32-tdep.c b/gdb/ft32-tdep.c
index 8906a09b0b6..476e79355c7 100644
--- a/gdb/ft32-tdep.c
+++ b/gdb/ft32-tdep.c
@@ -338,19 +338,19 @@ ft32_pointer_to_address (struct gdbarch *gdbarch,
     return addr | RAM_BIAS;
 }
=20
-/* Implementation of `address_class_type_flags' gdbarch method.
+/* Implementation of `address_class_dwarf_to_id' gdbarch method.
=20
-   This method maps DW_AT_address_class attributes to a
-   type_instance_flag_value.  */
+   This method maps a DW_AT_address_class attribute to an address
+   class id.  */
=20
-static type_instance_flags
-ft32_address_class_type_flags (int byte_size, int dwarf2_addr_class)
+static unsigned int
+ft32_address_class_dwarf_to_id (int byte_size, int dwarf2_addr_class)
 {
   /* The value 1 of the DW_AT_address_class attribute corresponds to the
      __flash__ qualifier, meaning pointer to data in FT32 program memory.
    */
   if (dwarf2_addr_class =3D=3D 1)
-    return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
+    return 1;
   return 0;
 }
=20
@@ -609,7 +609,8 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdb=
arch_list *arches)
   /* Support simple overlay manager.  */
   set_gdbarch_overlay_update (gdbarch, simple_overlay_update);
=20
-  set_gdbarch_address_class_type_flags (gdbarch, ft32_address_class_type_f=
lags);
+  set_gdbarch_address_class_dwarf_to_id
+    (gdbarch, ft32_address_class_dwarf_to_id);
   set_gdbarch_address_class_name_to_id
     (gdbarch, ft32_address_class_name_to_id);
   set_gdbarch_address_class_id_to_name
diff --git a/gdb/gdbarch-gen.c b/gdb/gdbarch-gen.c
index 980682e1bfb..6008003466c 100644
--- a/gdb/gdbarch-gen.c
+++ b/gdb/gdbarch-gen.c
@@ -163,7 +163,7 @@ struct gdbarch
   gdbarch_adjust_dwarf2_line_ftype *adjust_dwarf2_line =3D default_adjust_=
dwarf2_line;
   bool cannot_step_breakpoint =3D false;
   bool have_nonsteppable_watchpoint =3D false;
-  gdbarch_address_class_type_flags_ftype *address_class_type_flags =3D nul=
lptr;
+  gdbarch_address_class_dwarf_to_id_ftype *address_class_dwarf_to_id =3D n=
ullptr;
   gdbarch_address_class_id_to_name_ftype *address_class_id_to_name =3D nul=
lptr;
   gdbarch_execute_dwarf_cfa_vendor_op_ftype *execute_dwarf_cfa_vendor_op =
=3D default_execute_dwarf_cfa_vendor_op;
   gdbarch_address_class_name_to_id_ftype *address_class_name_to_id =3D nul=
lptr;
@@ -418,7 +418,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of adjust_dwarf2_line, invalid_p =3D=3D 0.  */
   /* Skip verify of cannot_step_breakpoint, invalid_p =3D=3D 0.  */
   /* Skip verify of have_nonsteppable_watchpoint, invalid_p =3D=3D 0.  */
-  /* Skip verify of address_class_type_flags, has predicate.  */
+  /* Skip verify of address_class_dwarf_to_id, has predicate.  */
   /* Skip verify of address_class_id_to_name, has predicate.  */
   /* Skip verify of execute_dwarf_cfa_vendor_op, invalid_p =3D=3D 0.  */
   /* Skip verify of address_class_name_to_id, has predicate.  */
@@ -959,11 +959,11 @@ gdbarch_dump (struct gdbarch *gdbarch, struct ui_file=
 *file)
 	      "gdbarch_dump: have_nonsteppable_watchpoint =3D %s\n",
 	      plongest (gdbarch->have_nonsteppable_watchpoint));
   gdb_printf (file,
-	      "gdbarch_dump: gdbarch_address_class_type_flags_p() =3D %d\n",
-	      gdbarch_address_class_type_flags_p (gdbarch));
+	      "gdbarch_dump: gdbarch_address_class_dwarf_to_id_p() =3D %d\n",
+	      gdbarch_address_class_dwarf_to_id_p (gdbarch));
   gdb_printf (file,
-	      "gdbarch_dump: address_class_type_flags =3D <%s>\n",
-	      host_address_to_string (gdbarch->address_class_type_flags));
+	      "gdbarch_dump: address_class_dwarf_to_id =3D <%s>\n",
+	      host_address_to_string (gdbarch->address_class_dwarf_to_id));
   gdb_printf (file,
 	      "gdbarch_dump: gdbarch_address_class_id_to_name_p() =3D %d\n",
 	      gdbarch_address_class_id_to_name_p (gdbarch));
@@ -3496,27 +3496,27 @@ set_gdbarch_have_nonsteppable_watchpoint (struct gd=
barch *gdbarch,
 }
=20
 bool
-gdbarch_address_class_type_flags_p (struct gdbarch *gdbarch)
+gdbarch_address_class_dwarf_to_id_p (struct gdbarch *gdbarch)
 {
   gdb_assert (gdbarch !=3D nullptr);
-  return gdbarch->address_class_type_flags !=3D nullptr;
+  return gdbarch->address_class_dwarf_to_id !=3D nullptr;
 }
=20
-type_instance_flags
-gdbarch_address_class_type_flags (struct gdbarch *gdbarch, int byte_size, =
int dwarf2_addr_class)
+unsigned int
+gdbarch_address_class_dwarf_to_id (struct gdbarch *gdbarch, int byte_size,=
 int dwarf2_addr_class)
 {
   gdb_assert (gdbarch !=3D nullptr);
-  gdb_assert (gdbarch->address_class_type_flags !=3D nullptr);
+  gdb_assert (gdbarch->address_class_dwarf_to_id !=3D nullptr);
   if (gdbarch_debug >=3D 2)
-    gdb_printf (gdb_stdlog, "gdbarch_address_class_type_flags called\n");
-  return gdbarch->address_class_type_flags (byte_size, dwarf2_addr_class);
+    gdb_printf (gdb_stdlog, "gdbarch_address_class_dwarf_to_id called\n");
+  return gdbarch->address_class_dwarf_to_id (byte_size, dwarf2_addr_class);
 }
=20
 void
-set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch,
-				      gdbarch_address_class_type_flags_ftype address_class_type_flags)
+set_gdbarch_address_class_dwarf_to_id (struct gdbarch *gdbarch,
+				       gdbarch_address_class_dwarf_to_id_ftype address_class_dwarf_to_=
id)
 {
-  gdbarch->address_class_type_flags =3D address_class_type_flags;
+  gdbarch->address_class_dwarf_to_id =3D address_class_dwarf_to_id;
 }
=20
 bool
diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
index 05b1656a511..6eda8693d58 100644
--- a/gdb/gdbarch-gen.h
+++ b/gdb/gdbarch-gen.h
@@ -896,11 +896,14 @@ void set_gdbarch_cannot_step_breakpoint (struct gdbar=
ch *gdbarch, bool cannot_st
 bool gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch);
 void set_gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch, bo=
ol have_nonsteppable_watchpoint);
=20
-bool gdbarch_address_class_type_flags_p (struct gdbarch *gdbarch);
+/* Given the DWARF identifier for an architecture-specific address class,
+   return the id of that address class. */
=20
-using gdbarch_address_class_type_flags_ftype =3D type_instance_flags (int =
byte_size, int dwarf2_addr_class);
-type_instance_flags gdbarch_address_class_type_flags (struct gdbarch *gdba=
rch, int byte_size, int dwarf2_addr_class);
-void set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, gdbarc=
h_address_class_type_flags_ftype *address_class_type_flags);
+bool gdbarch_address_class_dwarf_to_id_p (struct gdbarch *gdbarch);
+
+using gdbarch_address_class_dwarf_to_id_ftype =3D unsigned int (int byte_s=
ize, int dwarf2_addr_class);
+unsigned int gdbarch_address_class_dwarf_to_id (struct gdbarch *gdbarch, i=
nt byte_size, int dwarf2_addr_class);
+void set_gdbarch_address_class_dwarf_to_id (struct gdbarch *gdbarch, gdbar=
ch_address_class_dwarf_to_id_ftype *address_class_dwarf_to_id);
=20
 /* Given an architecture-specific address class identifier, return the
    name of that address class. */
diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
index d5d5a6d4fe3..d8b2d114909 100644
--- a/gdb/gdbarch_components.py
+++ b/gdb/gdbarch_components.py
@@ -1539,8 +1539,12 @@ non-steppable watchpoints.
 )
=20
 Function(
-    type=3D"type_instance_flags",
-    name=3D"address_class_type_flags",
+    comment=3D"""
+Given the DWARF identifier for an architecture-specific address class,
+return the id of that address class.
+""",
+    type=3D"unsigned int",
+    name=3D"address_class_dwarf_to_id",
     params=3D[("int", "byte_size"), ("int", "dwarf2_addr_class")],
     predicate=3DTrue,
 )
diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c
index 1aebdfa46d3..1155b8dd648 100644
--- a/gdb/s390-tdep.c
+++ b/gdb/s390-tdep.c
@@ -1607,14 +1607,14 @@ s390_addr_bits_remove (struct gdbarch *gdbarch, COR=
E_ADDR addr)
   return addr & 0x7fffffff;
 }
=20
-/* Implement addr_class_type_flags gdbarch method.
+/* Implement addr_class_dwarf_to_id gdbarch method.
    Only used for ABI_LINUX_ZSERIES.  */
=20
-static type_instance_flags
-s390_address_class_type_flags (int byte_size, int dwarf2_addr_class)
+static unsigned int
+s390_address_class_dwarf_to_id (int byte_size, int dwarf2_addr_class)
 {
   if (byte_size =3D=3D 4)
-    return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
+    return 1;
   else
     return 0;
 }
@@ -7355,8 +7355,8 @@ s390_gdbarch_init (struct gdbarch_info info, struct g=
dbarch_list *arches)
       set_gdbarch_long_bit (gdbarch, 64);
       set_gdbarch_long_long_bit (gdbarch, 64);
       set_gdbarch_ptr_bit (gdbarch, 64);
-      set_gdbarch_address_class_type_flags (gdbarch,
-					    s390_address_class_type_flags);
+      set_gdbarch_address_class_dwarf_to_id (gdbarch,
+					     s390_address_class_dwarf_to_id);
       set_gdbarch_address_class_id_to_name (gdbarch,
 					    s390_address_class_id_to_name);
       set_gdbarch_address_class_name_to_id (gdbarch,