Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tankut Baris Aktemur <tankutbaris.aktemur@amd.com>
To: <gdb-patches@sourceware.org>
Subject: [PATCH 04/16] gdb: convert address_class_type_flags to address_class_dwarf_to_id
Date: Mon, 13 Jul 2026 09:00:03 -0500	[thread overview]
Message-ID: <20260713-users-aktemur-type-instance-flags-v1-4-779cad0c85ec@amd.com> (raw)
In-Reply-To: <20260713-users-aktemur-type-instance-flags-v1-0-779cad0c85ec@amd.com>

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.
---
 gdb/avr-tdep.c            | 17 ++++++++---------
 gdb/dwarf2/read.c         |  8 +++++---
 gdb/ft32-tdep.c           | 15 ++++++++-------
 gdb/gdbarch-gen.c         | 32 ++++++++++++++++----------------
 gdb/gdbarch-gen.h         |  8 ++++----
 gdb/gdbarch_components.py |  4 ++--
 gdb/s390-tdep.c           | 12 ++++++------
 7 files changed, 49 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.  */
 
 #define AVR_ADDRESS_CLASS_FLASH 1
-#define AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH	\
-  TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1
 
 
 enum
@@ -1370,20 +1368,20 @@ avr_dwarf_reg_to_regnum (struct gdbarch *gdbarch, int reg)
   return -1;
 }
 
-/* Implementation of `address_class_type_flags' gdbarch method.
+/* Implementation of `address_class_dwarf_to_id' gdbarch method.
 
-   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.  */
 
-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 == 1 && byte_size == 2)
-    return AVR_TYPE_INSTANCE_FLAG_ADDRESS_CLASS_FLASH;
+    return AVR_ADDRESS_CLASS_FLASH;
   return 0;
 }
 
@@ -1534,7 +1532,8 @@ avr_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_unwind_pc (gdbarch, avr_unwind_pc);
   set_gdbarch_unwind_sp (gdbarch, avr_unwind_sp);
 
-  set_gdbarch_address_class_type_flags (gdbarch, avr_address_class_type_flags);
+  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, struct dwarf2_cu *cu)
 	  && alignment != TYPE_RAW_ALIGN (type))
       || addr_class != DW_ADDR_none)
     {
-      if (gdbarch_address_class_type_flags_p (gdbarch))
+      if (gdbarch_address_class_dwarf_to_id_p (gdbarch))
 	{
+	  unsigned int aclass
+	    = gdbarch_address_class_dwarf_to_id (gdbarch, byte_size,
+						 addr_class);
 	  type_instance_flags type_flags
-	    = gdbarch_address_class_type_flags (gdbarch, byte_size,
-						addr_class);
+	    = (enum type_instance_flag_value) (aclass << 4);
 	  gdb_assert ((type_flags & ~TYPE_INSTANCE_FLAG_ADDRESS_CLASS_ALL)
 		      == 0);
 	  type = 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;
 }
 
-/* Implementation of `address_class_type_flags' gdbarch method.
+/* Implementation of `address_class_dwarf_to_id' gdbarch method.
 
-   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.  */
 
-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 == 1)
-    return TYPE_INSTANCE_FLAG_ADDRESS_CLASS_1;
+    return 1;
   return 0;
 }
 
@@ -609,7 +609,8 @@ ft32_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   /* Support simple overlay manager.  */
   set_gdbarch_overlay_update (gdbarch, simple_overlay_update);
 
-  set_gdbarch_address_class_type_flags (gdbarch, ft32_address_class_type_flags);
+  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 = default_adjust_dwarf2_line;
   bool cannot_step_breakpoint = false;
   bool have_nonsteppable_watchpoint = false;
-  gdbarch_address_class_type_flags_ftype *address_class_type_flags = nullptr;
+  gdbarch_address_class_dwarf_to_id_ftype *address_class_dwarf_to_id = nullptr;
   gdbarch_address_class_id_to_name_ftype *address_class_id_to_name = nullptr;
   gdbarch_execute_dwarf_cfa_vendor_op_ftype *execute_dwarf_cfa_vendor_op = default_execute_dwarf_cfa_vendor_op;
   gdbarch_address_class_name_to_id_ftype *address_class_name_to_id = nullptr;
@@ -418,7 +418,7 @@ verify_gdbarch (struct gdbarch *gdbarch)
   /* Skip verify of adjust_dwarf2_line, invalid_p == 0.  */
   /* Skip verify of cannot_step_breakpoint, invalid_p == 0.  */
   /* Skip verify of have_nonsteppable_watchpoint, invalid_p == 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 == 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 = %s\n",
 	      plongest (gdbarch->have_nonsteppable_watchpoint));
   gdb_printf (file,
-	      "gdbarch_dump: gdbarch_address_class_type_flags_p() = %d\n",
-	      gdbarch_address_class_type_flags_p (gdbarch));
+	      "gdbarch_dump: gdbarch_address_class_dwarf_to_id_p() = %d\n",
+	      gdbarch_address_class_dwarf_to_id_p (gdbarch));
   gdb_printf (file,
-	      "gdbarch_dump: address_class_type_flags = <%s>\n",
-	      host_address_to_string (gdbarch->address_class_type_flags));
+	      "gdbarch_dump: address_class_dwarf_to_id = <%s>\n",
+	      host_address_to_string (gdbarch->address_class_dwarf_to_id));
   gdb_printf (file,
 	      "gdbarch_dump: gdbarch_address_class_id_to_name_p() = %d\n",
 	      gdbarch_address_class_id_to_name_p (gdbarch));
@@ -3496,27 +3496,27 @@ set_gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch,
 }
 
 bool
-gdbarch_address_class_type_flags_p (struct gdbarch *gdbarch)
+gdbarch_address_class_dwarf_to_id_p (struct gdbarch *gdbarch)
 {
   gdb_assert (gdbarch != nullptr);
-  return gdbarch->address_class_type_flags != nullptr;
+  return gdbarch->address_class_dwarf_to_id != nullptr;
 }
 
-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 != nullptr);
-  gdb_assert (gdbarch->address_class_type_flags != nullptr);
+  gdb_assert (gdbarch->address_class_dwarf_to_id != nullptr);
   if (gdbarch_debug >= 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);
 }
 
 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 = address_class_type_flags;
+  gdbarch->address_class_dwarf_to_id = address_class_dwarf_to_id;
 }
 
 bool
diff --git a/gdb/gdbarch-gen.h b/gdb/gdbarch-gen.h
index 1e413796e11..34a106a9631 100644
--- a/gdb/gdbarch-gen.h
+++ b/gdb/gdbarch-gen.h
@@ -896,11 +896,11 @@ void set_gdbarch_cannot_step_breakpoint (struct gdbarch *gdbarch, bool cannot_st
 bool gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch);
 void set_gdbarch_have_nonsteppable_watchpoint (struct gdbarch *gdbarch, bool have_nonsteppable_watchpoint);
 
-bool gdbarch_address_class_type_flags_p (struct gdbarch *gdbarch);
+bool gdbarch_address_class_dwarf_to_id_p (struct gdbarch *gdbarch);
 
-using gdbarch_address_class_type_flags_ftype = type_instance_flags (int byte_size, int dwarf2_addr_class);
-type_instance_flags gdbarch_address_class_type_flags (struct gdbarch *gdbarch, int byte_size, int dwarf2_addr_class);
-void set_gdbarch_address_class_type_flags (struct gdbarch *gdbarch, gdbarch_address_class_type_flags_ftype *address_class_type_flags);
+using gdbarch_address_class_dwarf_to_id_ftype = unsigned int (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);
+void set_gdbarch_address_class_dwarf_to_id (struct gdbarch *gdbarch, gdbarch_address_class_dwarf_to_id_ftype *address_class_dwarf_to_id);
 
 bool gdbarch_address_class_id_to_name_p (struct gdbarch *gdbarch);
 
diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py
index da2dbd75c4d..812854afc4d 100644
--- a/gdb/gdbarch_components.py
+++ b/gdb/gdbarch_components.py
@@ -1539,8 +1539,8 @@ non-steppable watchpoints.
 )
 
 Function(
-    type="type_instance_flags",
-    name="address_class_type_flags",
+    type="unsigned int",
+    name="address_class_dwarf_to_id",
     params=[("int", "byte_size"), ("int", "dwarf2_addr_class")],
     predicate=True,
 )
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, CORE_ADDR addr)
   return addr & 0x7fffffff;
 }
 
-/* Implement addr_class_type_flags gdbarch method.
+/* Implement addr_class_dwarf_to_id gdbarch method.
    Only used for ABI_LINUX_ZSERIES.  */
 
-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 == 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 gdbarch_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,

-- 
2.34.1


  parent reply	other threads:[~2026-07-13 14:01 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-13 13:59 [PATCH 00/16] Rewrite type instance flags as a struct with bitfields Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 01/16] gdb: use type instance macros to query const, volatile, restrict Tankut Baris Aktemur
2026-07-21 17:52   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 02/16] gdb: convert address_class_type_flags_to_name to address_class_id_to_name Tankut Baris Aktemur
2026-07-21 18:03   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 03/16] gdb: convert address_class_name_to_type_flags to address_class_name_to_id Tankut Baris Aktemur
2026-07-21 18:10   ` Tom Tromey
2026-07-13 14:00 ` Tankut Baris Aktemur [this message]
2026-07-21 18:19   ` [PATCH 04/16] gdb: convert address_class_type_flags to address_class_dwarf_to_id Tom Tromey
2026-07-13 14:00 ` [PATCH 05/16] gdb: inline address_space_{name, type_instance_flags}_to_{type_instance_flags, name} Tankut Baris Aktemur
2026-07-21 18:29   ` Tom Tromey
2026-07-22 10:29     ` Aktemur, Baris
2026-07-22 13:38       ` Tom Tromey
2026-07-13 14:00 ` [PATCH 06/16] gdb: split make_type_with_address_space Tankut Baris Aktemur
2026-07-21 18:49   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 07/16] gdb: convert type instance flags to bitfields Tankut Baris Aktemur
2026-07-21 19:13   ` Tom Tromey
2026-07-22 10:29     ` Aktemur, Baris
2026-07-13 14:00 ` [PATCH 08/16] gdb: convert TYPE_NOTTEXT macro to type::is_nottext Tankut Baris Aktemur
2026-07-21 18:39   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 09/16] gdb: convert TYPE_CONST macro to type::is_const Tankut Baris Aktemur
2026-07-21 18:40   ` Tom Tromey
2026-07-13 14:00 ` [PATCH 10/16] gdb: convert TYPE_VOLATILE macro to type::is_volatile Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 11/16] gdb: convert TYPE_CODE_SPACE macro to type::is_code_space Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 12/16] gdb: convert TYPE_DATA_SPACE macro to type::is_data_space Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 13/16] gdb: convert TYPE_RESTRICT macro to type::is_restrict Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 14/16] gdb: convert TYPE_ATOMIC macro to type::is_atomic Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 15/16] gdb: convert TYPE_ADDRESS_CLASS macro to type::address_class Tankut Baris Aktemur
2026-07-13 14:00 ` [PATCH 16/16] gdb: remove unnecessary braces in recursive_dump_type Tankut Baris Aktemur
2026-07-21 18:45   ` Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260713-users-aktemur-type-instance-flags-v1-4-779cad0c85ec@amd.com \
    --to=tankutbaris.aktemur@amd.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox