[PATCH v2 12/17] gdb: convert TYPE_CODE_SPACE macro to type::is_code_space
Tankut Baris Aktemur <[email protected]> Wed, 22 Jul 2026 05:42:01 -0500
| Newsgroups | gmane.comp.gdb.patches |
|---|---|
| Message-ID | <20260722-users-aktemur-type-instance-flags-v2-12-d60dcbc2a76f@amd.com> |
Convert the TYPE_CODE_SPACE macro to a method of the type class. This
is a refactoring.
---
gdb/avr-tdep.c | 2 +-
gdb/c-typeprint.c | 2 +-
gdb/gdbtypes.c | 6 ++----
gdb/gdbtypes.h | 9 ++++++---
gdb/iq2000-tdep.c | 2 +-
gdb/rl78-tdep.c | 2 +-
6 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/gdb/avr-tdep.c b/gdb/avr-tdep.c
index 2191ada4c2e..26b786c68b7 100644
--- a/gdb/avr-tdep.c
+++ b/gdb/avr-tdep.c
@@ -345,7 +345,7 @@ avr_pointer_to_address (struct gdbarch *gdbarch,
/* Is it a code address? */
else if (type->target_type ()->code () == TYPE_CODE_FUNC
|| type->target_type ()->code () == TYPE_CODE_METHOD
- || TYPE_CODE_SPACE (type->target_type ()))
+ || type->target_type ()->is_code_space ())
{
/* A code pointer is word (16 bits) addressed so we shift it up
by 1 bit to convert it to an address. */
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index fb8b228ea38..a8927e0ac43 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -485,7 +485,7 @@ c_type_print_modifier (struct type *type, struct ui_file *stream,
address_space_id = nullptr;
- if (TYPE_CODE_SPACE (type))
+ if (type->is_code_space ())
address_space_id = "code";
else if (TYPE_DATA_SPACE (type))
address_space_id = "data";
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 1019f02e2e1..465af4790fd 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -5025,10 +5025,8 @@ recursive_dump_type (struct type *type, int spaces)
gdb_puts (" TYPE_CONST");
if (type->is_volatile ())
gdb_puts (" TYPE_VOLATILE");
- if (TYPE_CODE_SPACE (type))
- {
- gdb_puts (" TYPE_CODE_SPACE");
- }
+ if (type->is_code_space ())
+ gdb_puts (" TYPE_CODE_SPACE");
if (TYPE_DATA_SPACE (type))
{
gdb_puts (" TYPE_DATA_SPACE");
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index 6a8bc425d45..d9988312e1b 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -189,9 +189,6 @@ struct type_instance_flags
(((t)->dyn_prop (DYN_PROP_BYTE_SIZE) != nullptr) \
|| ((t)->dyn_prop (DYN_PROP_BIT_SIZE) != nullptr))
-#define TYPE_CODE_SPACE(t) \
- (((t)->instance_flags ()).harvard_aspace == HARVARD_ASPACE_CODE)
-
#define TYPE_DATA_SPACE(t) \
(((t)->instance_flags ()).harvard_aspace == HARVARD_ASPACE_DATA)
@@ -1216,6 +1213,12 @@ struct type
return this->m_instance_flags.is_volatile;
}
+ /* Return if this type is in the code space. */
+ bool is_code_space () const
+ {
+ return this->m_instance_flags.harvard_aspace == HARVARD_ASPACE_CODE;
+ }
+
/* Get the bounds bounds of this type. The type must be a range type. */
range_bounds *bounds () const
{
diff --git a/gdb/iq2000-tdep.c b/gdb/iq2000-tdep.c
index 32e3750aca4..783e1720a02 100644
--- a/gdb/iq2000-tdep.c
+++ b/gdb/iq2000-tdep.c
@@ -95,7 +95,7 @@ iq2000_pointer_to_address (struct gdbarch *gdbarch,
if (target == TYPE_CODE_FUNC
|| target == TYPE_CODE_METHOD
- || TYPE_CODE_SPACE (type->target_type ()))
+ || type->target_type ()->is_code_space ())
addr = insn_addr_from_ptr (addr);
return addr;
diff --git a/gdb/rl78-tdep.c b/gdb/rl78-tdep.c
index 0de2fceb795..4204ce5c8cb 100644
--- a/gdb/rl78-tdep.c
+++ b/gdb/rl78-tdep.c
@@ -1052,7 +1052,7 @@ rl78_pointer_to_address (struct gdbarch *gdbarch,
/* Is it a code address? */
if (type->target_type ()->code () == TYPE_CODE_FUNC
|| type->target_type ()->code () == TYPE_CODE_METHOD
- || TYPE_CODE_SPACE (type->target_type ())
+ || type->target_type ()->is_code_space ()
|| type->length () == 4)
return rl78_make_instruction_address (addr);
else
--
2.34.1