From: Tankut Baris Aktemur Date: Thu, 23 Jul 2026 10:04:43 +0000 (-0500) Subject: gdb: convert TYPE_CODE_SPACE macro to type::is_code_space X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=ff546adf577b9c8a2c1bebc2dc50521894c44c6f;p=thirdparty%2Fbinutils-gdb.git gdb: convert TYPE_CODE_SPACE macro to type::is_code_space Convert the TYPE_CODE_SPACE macro to a method of the type class. This is a refactoring. Approved-By: Tom Tromey --- 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