From caba95fadd6d89ee622715306d418b50166ddb91 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Thu, 23 Oct 2025 15:06:58 -0400 Subject: [PATCH] gdb: remove TYPE_*_PROP macros Remove the macros in favor of using the dyn_prop member function directly. Change-Id: I29758ea408610a2df0a6a226327d1f1af39a178d Approved-By: Tom Tromey --- gdb/f-lang.c | 6 +++--- gdb/f-typeprint.c | 12 ++++++------ gdb/gdbtypes.c | 34 +++++++++++++++++----------------- gdb/gdbtypes.h | 18 +++--------------- gdb/value.c | 20 ++++++++++---------- 5 files changed, 39 insertions(+), 51 deletions(-) diff --git a/gdb/f-lang.c b/gdb/f-lang.c index 1aa9fc497d7..2720373e4f4 100644 --- a/gdb/f-lang.c +++ b/gdb/f-lang.c @@ -404,7 +404,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, /* All Fortran pointers should have the associated property, this is how we know the pointer is pointing at something or not. */ struct type *pointer_type = check_typedef (pointer->type ()); - if (TYPE_ASSOCIATED_PROP (pointer_type) == nullptr + if (pointer_type->dyn_prop (DYN_PROP_ASSOCIATED) == nullptr && pointer_type->code () != TYPE_CODE_PTR) error (_("ASSOCIATED can only be applied to pointers")); @@ -431,7 +431,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, This is probably true for most targets, but might not be true for everyone. */ if (pointer_type->code () == TYPE_CODE_PTR - && TYPE_ASSOCIATED_PROP (pointer_type) == nullptr) + && pointer_type->dyn_prop (DYN_PROP_ASSOCIATED) == nullptr) is_associated = (pointer_addr != 0); else is_associated = !type_not_associated (pointer_type); @@ -469,7 +469,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang, most targets, but might not be true for everyone. */ if (target->lval () != lval_memory || type_not_associated (pointer_type) - || (TYPE_ASSOCIATED_PROP (pointer_type) == nullptr + || (pointer_type->dyn_prop (DYN_PROP_ASSOCIATED) == nullptr && pointer_type->code () == TYPE_CODE_PTR && pointer_addr == 0)) return value_from_longest (result_type, 0); diff --git a/gdb/f-typeprint.c b/gdb/f-typeprint.c index 04eca74fb2b..3d3548475eb 100644 --- a/gdb/f-typeprint.c +++ b/gdb/f-typeprint.c @@ -173,12 +173,12 @@ f_language::f_type_print_varspec_suffix (struct type *type, print_rank_only = true; else if (type_not_allocated (type)) print_rank_only = true; - else if ((TYPE_ASSOCIATED_PROP (type) - && !TYPE_ASSOCIATED_PROP (type)->is_constant ()) - || (TYPE_ALLOCATED_PROP (type) - && !TYPE_ALLOCATED_PROP (type)->is_constant ()) - || (TYPE_DATA_LOCATION (type) - && !TYPE_DATA_LOCATION (type)->is_constant ())) + else if ((type->dyn_prop (DYN_PROP_ASSOCIATED) + && !type->dyn_prop (DYN_PROP_ASSOCIATED)->is_constant ()) + || (type->dyn_prop (DYN_PROP_ALLOCATED) + && !type->dyn_prop (DYN_PROP_ALLOCATED)->is_constant ()) + || (type->dyn_prop (DYN_PROP_DATA_LOCATION) + && !type->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ())) { /* This case exist when we ptype a typename which has the dynamic properties but cannot be resolved as there is no object. */ diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 6c366829eb8..c396d6574d9 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -2072,15 +2072,15 @@ is_dynamic_type_internal (struct type *type, bool top_level) but it makes sense in this context, because the point is to determine whether any part of the type needs to be resolved before it can be exploited. */ - if (TYPE_DATA_LOCATION (type) != NULL + if (type->dyn_prop (DYN_PROP_DATA_LOCATION) != NULL && (TYPE_DATA_LOCATION_KIND (type) == PROP_LOCEXPR || TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST)) return true; - if (TYPE_ASSOCIATED_PROP (type)) + if (type->dyn_prop (DYN_PROP_ASSOCIATED)) return true; - if (TYPE_ALLOCATED_PROP (type)) + if (type->dyn_prop (DYN_PROP_ALLOCATED)) return true; struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS); @@ -2316,7 +2316,7 @@ resolve_dynamic_array_or_string_1 (struct type *type, not allocated/associated, as such we just ignore this property. This is fine as GDB only checks the allocated/associated on the outer most dimension of the array. */ - prop = TYPE_ALLOCATED_PROP (type); + prop = type->dyn_prop (DYN_PROP_ALLOCATED); if (prop != NULL && resolve_p && dwarf2_evaluate_property (prop, frame, addr_stack, &value)) { @@ -2325,7 +2325,7 @@ resolve_dynamic_array_or_string_1 (struct type *type, resolve_p = false; } - prop = TYPE_ASSOCIATED_PROP (type); + prop = type->dyn_prop (DYN_PROP_ASSOCIATED); if (prop != NULL && resolve_p && dwarf2_evaluate_property (prop, frame, addr_stack, &value)) { @@ -2429,7 +2429,7 @@ resolve_dynamic_array_or_string (struct type *type, type = copy_type (type); /* Resolve the rank property to get rank value. */ - struct dynamic_prop *prop = TYPE_RANK_PROP (type); + struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_RANK); if (dwarf2_evaluate_property (prop, frame, addr_stack, &value)) { prop->set_const_val (value); @@ -2889,7 +2889,7 @@ resolve_dynamic_type_internal (struct type *type, return type; std::optional type_length; - prop = TYPE_DYNAMIC_LENGTH (type); + prop = type->dyn_prop (DYN_PROP_BYTE_SIZE); if (prop != NULL && dwarf2_evaluate_property (prop, frame, addr_stack, &value)) type_length = value; @@ -2972,7 +2972,7 @@ resolve_dynamic_type_internal (struct type *type, } /* Resolve data_location attribute. */ - prop = TYPE_DATA_LOCATION (resolved_type); + prop = resolved_type->dyn_prop (DYN_PROP_DATA_LOCATION); if (prop != NULL && dwarf2_evaluate_property (prop, frame, addr_stack, &value)) { @@ -4525,7 +4525,7 @@ types_deeply_equal (struct type *type1, struct type *type2) int type_not_allocated (const struct type *type) { - struct dynamic_prop *prop = TYPE_ALLOCATED_PROP (type); + struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_ALLOCATED); return prop != nullptr && prop->is_constant () && prop->const_val () == 0; } @@ -4536,7 +4536,7 @@ type_not_allocated (const struct type *type) int type_not_associated (const struct type *type) { - struct dynamic_prop *prop = TYPE_ASSOCIATED_PROP (type); + struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_ASSOCIATED); return prop != nullptr && prop->is_constant () && prop->const_val () == 0; } @@ -5367,21 +5367,21 @@ recursive_dump_type (struct type *type, int spaces) } gdb_puts ("\n"); gdb_printf ("%*snfields %d ", spaces, "", type->num_fields ()); - if (TYPE_ASSOCIATED_PROP (type) != nullptr - || TYPE_ALLOCATED_PROP (type) != nullptr) + if (type->dyn_prop (DYN_PROP_ASSOCIATED) != nullptr + || type->dyn_prop (DYN_PROP_ALLOCATED) != nullptr) { gdb_printf ("%*s", spaces, ""); - if (TYPE_ASSOCIATED_PROP (type) != nullptr) + if (type->dyn_prop (DYN_PROP_ASSOCIATED) != nullptr) { gdb_printf ("associated "); - dump_dynamic_prop (*TYPE_ASSOCIATED_PROP (type)); + dump_dynamic_prop (*type->dyn_prop (DYN_PROP_ASSOCIATED)); } - if (TYPE_ALLOCATED_PROP (type) != nullptr) + if (type->dyn_prop (DYN_PROP_ALLOCATED) != nullptr) { - if (TYPE_ASSOCIATED_PROP (type) != nullptr) + if (type->dyn_prop (DYN_PROP_ASSOCIATED) != nullptr) gdb_printf (" "); gdb_printf ("allocated "); - dump_dynamic_prop (*TYPE_ALLOCATED_PROP (type)); + dump_dynamic_prop (*type->dyn_prop (DYN_PROP_ALLOCATED)); } gdb_printf ("\n"); } diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h index 5abca515ac5..820a90bcbab 100644 --- a/gdb/gdbtypes.h +++ b/gdb/gdbtypes.h @@ -1932,24 +1932,12 @@ extern unsigned type_align (struct type *); extern bool set_type_align (struct type *, ULONGEST); /* Property accessors for the type data location. */ -#define TYPE_DATA_LOCATION(thistype) \ - ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION)) #define TYPE_DATA_LOCATION_BATON(thistype) \ - TYPE_DATA_LOCATION (thistype)->data.baton + ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION)->data.baton) #define TYPE_DATA_LOCATION_ADDR(thistype) \ - (TYPE_DATA_LOCATION (thistype)->const_val ()) + ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION)->const_val ()) #define TYPE_DATA_LOCATION_KIND(thistype) \ - (TYPE_DATA_LOCATION (thistype)->kind ()) -#define TYPE_DYNAMIC_LENGTH(thistype) \ - ((thistype)->dyn_prop (DYN_PROP_BYTE_SIZE)) - -/* Property accessors for the type allocated/associated. */ -#define TYPE_ALLOCATED_PROP(thistype) \ - ((thistype)->dyn_prop (DYN_PROP_ALLOCATED)) -#define TYPE_ASSOCIATED_PROP(thistype) \ - ((thistype)->dyn_prop (DYN_PROP_ASSOCIATED)) -#define TYPE_RANK_PROP(thistype) \ - ((thistype)->dyn_prop (DYN_PROP_RANK)) + ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION)->kind ()) /* C++ */ diff --git a/gdb/value.c b/gdb/value.c index ea24275c4f6..7e530757567 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1422,9 +1422,9 @@ value::address () const return 0; if (m_parent != NULL) return m_parent->address () + m_offset; - if (NULL != TYPE_DATA_LOCATION (type ())) + if (NULL != type ()->dyn_prop (DYN_PROP_DATA_LOCATION)) { - gdb_assert (TYPE_DATA_LOCATION (type ())->is_constant ()); + gdb_assert (type ()->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ()); return TYPE_DATA_LOCATION_ADDR (type ()); } @@ -1658,15 +1658,15 @@ value::set_component_location (const struct value *whole) /* If the WHOLE value has a dynamically resolved location property then update the address of the COMPONENT. */ type = whole->type (); - if (NULL != TYPE_DATA_LOCATION (type) - && TYPE_DATA_LOCATION (type)->is_constant ()) + if (NULL != type->dyn_prop (DYN_PROP_DATA_LOCATION) + && type->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ()) set_address (TYPE_DATA_LOCATION_ADDR (type)); /* Similarly, if the COMPONENT value has a dynamically resolved location property then update its address. */ type = this->type (); - if (NULL != TYPE_DATA_LOCATION (type) - && TYPE_DATA_LOCATION (type)->is_constant ()) + if (NULL != type->dyn_prop (DYN_PROP_DATA_LOCATION) + && type->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ()) { /* If the COMPONENT has a dynamic location, and is an lval_internalvar_component, then we change it to a lval_memory. @@ -3107,13 +3107,13 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type) v->set_offset (this->offset ()); v->set_embedded_offset (offset + embedded_offset () + boffset); } - else if (NULL != TYPE_DATA_LOCATION (type)) + else if (NULL != type->dyn_prop (DYN_PROP_DATA_LOCATION)) { /* Field is a dynamic data member. */ gdb_assert (0 == offset); /* We expect an already resolved data location. */ - gdb_assert (TYPE_DATA_LOCATION (type)->is_constant ()); + gdb_assert (type->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ()); /* For dynamic data types defer memory allocation until we actual access the value. */ v = value::allocate_lazy (type); @@ -3683,8 +3683,8 @@ value_from_contents_and_address (struct type *type, v = value::allocate_lazy (resolved_type); else v = value_from_contents (resolved_type, valaddr); - if (TYPE_DATA_LOCATION (resolved_type_no_typedef) != NULL - && TYPE_DATA_LOCATION (resolved_type_no_typedef)->is_constant ()) + if (resolved_type_no_typedef->dyn_prop (DYN_PROP_DATA_LOCATION) != NULL + && resolved_type_no_typedef->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ()) address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef); v->set_lval (lval_memory); v->set_address (address);