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 <tom@tromey.com>
This commit is contained in:
Simon Marchi
2025-10-23 15:06:58 -04:00
committed by Simon Marchi
parent f9e262e1cb
commit caba95fadd
5 changed files with 39 additions and 51 deletions

View File

@@ -404,7 +404,7 @@ fortran_associated (struct gdbarch *gdbarch, const language_defn *lang,
/* All Fortran pointers should have the associated property, this is /* All Fortran pointers should have the associated property, this is
how we know the pointer is pointing at something or not. */ how we know the pointer is pointing at something or not. */
struct type *pointer_type = check_typedef (pointer->type ()); 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) && pointer_type->code () != TYPE_CODE_PTR)
error (_("ASSOCIATED can only be applied to pointers")); 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 This is probably true for most targets, but might not be true for
everyone. */ everyone. */
if (pointer_type->code () == TYPE_CODE_PTR 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); is_associated = (pointer_addr != 0);
else else
is_associated = !type_not_associated (pointer_type); 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. */ most targets, but might not be true for everyone. */
if (target->lval () != lval_memory if (target->lval () != lval_memory
|| type_not_associated (pointer_type) || 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_type->code () == TYPE_CODE_PTR
&& pointer_addr == 0)) && pointer_addr == 0))
return value_from_longest (result_type, 0); return value_from_longest (result_type, 0);

View File

@@ -173,12 +173,12 @@ f_language::f_type_print_varspec_suffix (struct type *type,
print_rank_only = true; print_rank_only = true;
else if (type_not_allocated (type)) else if (type_not_allocated (type))
print_rank_only = true; print_rank_only = true;
else if ((TYPE_ASSOCIATED_PROP (type) else if ((type->dyn_prop (DYN_PROP_ASSOCIATED)
&& !TYPE_ASSOCIATED_PROP (type)->is_constant ()) && !type->dyn_prop (DYN_PROP_ASSOCIATED)->is_constant ())
|| (TYPE_ALLOCATED_PROP (type) || (type->dyn_prop (DYN_PROP_ALLOCATED)
&& !TYPE_ALLOCATED_PROP (type)->is_constant ()) && !type->dyn_prop (DYN_PROP_ALLOCATED)->is_constant ())
|| (TYPE_DATA_LOCATION (type) || (type->dyn_prop (DYN_PROP_DATA_LOCATION)
&& !TYPE_DATA_LOCATION (type)->is_constant ())) && !type->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ()))
{ {
/* This case exist when we ptype a typename which has the dynamic /* This case exist when we ptype a typename which has the dynamic
properties but cannot be resolved as there is no object. */ properties but cannot be resolved as there is no object. */

View File

@@ -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 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 whether any part of the type needs to be resolved before it can
be exploited. */ 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_LOCEXPR
|| TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST)) || TYPE_DATA_LOCATION_KIND (type) == PROP_LOCLIST))
return true; return true;
if (TYPE_ASSOCIATED_PROP (type)) if (type->dyn_prop (DYN_PROP_ASSOCIATED))
return true; return true;
if (TYPE_ALLOCATED_PROP (type)) if (type->dyn_prop (DYN_PROP_ALLOCATED))
return true; return true;
struct dynamic_prop *prop = type->dyn_prop (DYN_PROP_VARIANT_PARTS); 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 not allocated/associated, as such we just ignore this property. This
is fine as GDB only checks the allocated/associated on the outer most is fine as GDB only checks the allocated/associated on the outer most
dimension of the array. */ dimension of the array. */
prop = TYPE_ALLOCATED_PROP (type); prop = type->dyn_prop (DYN_PROP_ALLOCATED);
if (prop != NULL && resolve_p if (prop != NULL && resolve_p
&& dwarf2_evaluate_property (prop, frame, addr_stack, &value)) && dwarf2_evaluate_property (prop, frame, addr_stack, &value))
{ {
@@ -2325,7 +2325,7 @@ resolve_dynamic_array_or_string_1 (struct type *type,
resolve_p = false; resolve_p = false;
} }
prop = TYPE_ASSOCIATED_PROP (type); prop = type->dyn_prop (DYN_PROP_ASSOCIATED);
if (prop != NULL && resolve_p if (prop != NULL && resolve_p
&& dwarf2_evaluate_property (prop, frame, addr_stack, &value)) && dwarf2_evaluate_property (prop, frame, addr_stack, &value))
{ {
@@ -2429,7 +2429,7 @@ resolve_dynamic_array_or_string (struct type *type,
type = copy_type (type); type = copy_type (type);
/* Resolve the rank property to get rank value. */ /* 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)) if (dwarf2_evaluate_property (prop, frame, addr_stack, &value))
{ {
prop->set_const_val (value); prop->set_const_val (value);
@@ -2889,7 +2889,7 @@ resolve_dynamic_type_internal (struct type *type,
return type; return type;
std::optional<CORE_ADDR> type_length; std::optional<CORE_ADDR> type_length;
prop = TYPE_DYNAMIC_LENGTH (type); prop = type->dyn_prop (DYN_PROP_BYTE_SIZE);
if (prop != NULL if (prop != NULL
&& dwarf2_evaluate_property (prop, frame, addr_stack, &value)) && dwarf2_evaluate_property (prop, frame, addr_stack, &value))
type_length = value; type_length = value;
@@ -2972,7 +2972,7 @@ resolve_dynamic_type_internal (struct type *type,
} }
/* Resolve data_location attribute. */ /* Resolve data_location attribute. */
prop = TYPE_DATA_LOCATION (resolved_type); prop = resolved_type->dyn_prop (DYN_PROP_DATA_LOCATION);
if (prop != NULL if (prop != NULL
&& dwarf2_evaluate_property (prop, frame, addr_stack, &value)) && dwarf2_evaluate_property (prop, frame, addr_stack, &value))
{ {
@@ -4525,7 +4525,7 @@ types_deeply_equal (struct type *type1, struct type *type2)
int int
type_not_allocated (const struct type *type) 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; return prop != nullptr && prop->is_constant () && prop->const_val () == 0;
} }
@@ -4536,7 +4536,7 @@ type_not_allocated (const struct type *type)
int int
type_not_associated (const struct type *type) 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; 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_puts ("\n");
gdb_printf ("%*snfields %d ", spaces, "", type->num_fields ()); gdb_printf ("%*snfields %d ", spaces, "", type->num_fields ());
if (TYPE_ASSOCIATED_PROP (type) != nullptr if (type->dyn_prop (DYN_PROP_ASSOCIATED) != nullptr
|| TYPE_ALLOCATED_PROP (type) != nullptr) || type->dyn_prop (DYN_PROP_ALLOCATED) != nullptr)
{ {
gdb_printf ("%*s", spaces, ""); gdb_printf ("%*s", spaces, "");
if (TYPE_ASSOCIATED_PROP (type) != nullptr) if (type->dyn_prop (DYN_PROP_ASSOCIATED) != nullptr)
{ {
gdb_printf ("associated "); 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 (" ");
gdb_printf ("allocated "); gdb_printf ("allocated ");
dump_dynamic_prop (*TYPE_ALLOCATED_PROP (type)); dump_dynamic_prop (*type->dyn_prop (DYN_PROP_ALLOCATED));
} }
gdb_printf ("\n"); gdb_printf ("\n");
} }

View File

@@ -1932,24 +1932,12 @@ extern unsigned type_align (struct type *);
extern bool set_type_align (struct type *, ULONGEST); extern bool set_type_align (struct type *, ULONGEST);
/* Property accessors for the type data location. */ /* 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) \ #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) \ #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) \ #define TYPE_DATA_LOCATION_KIND(thistype) \
(TYPE_DATA_LOCATION (thistype)->kind ()) ((thistype)->dyn_prop (DYN_PROP_DATA_LOCATION)->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))
/* C++ */ /* C++ */

View File

@@ -1422,9 +1422,9 @@ value::address () const
return 0; return 0;
if (m_parent != NULL) if (m_parent != NULL)
return m_parent->address () + m_offset; 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 ()); 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 /* If the WHOLE value has a dynamically resolved location property then
update the address of the COMPONENT. */ update the address of the COMPONENT. */
type = whole->type (); type = whole->type ();
if (NULL != TYPE_DATA_LOCATION (type) if (NULL != type->dyn_prop (DYN_PROP_DATA_LOCATION)
&& TYPE_DATA_LOCATION (type)->is_constant ()) && type->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ())
set_address (TYPE_DATA_LOCATION_ADDR (type)); set_address (TYPE_DATA_LOCATION_ADDR (type));
/* Similarly, if the COMPONENT value has a dynamically resolved location /* Similarly, if the COMPONENT value has a dynamically resolved location
property then update its address. */ property then update its address. */
type = this->type (); type = this->type ();
if (NULL != TYPE_DATA_LOCATION (type) if (NULL != type->dyn_prop (DYN_PROP_DATA_LOCATION)
&& TYPE_DATA_LOCATION (type)->is_constant ()) && type->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ())
{ {
/* If the COMPONENT has a dynamic location, and is an /* If the COMPONENT has a dynamic location, and is an
lval_internalvar_component, then we change it to a lval_memory. 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_offset (this->offset ());
v->set_embedded_offset (offset + embedded_offset () + boffset); 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. */ /* Field is a dynamic data member. */
gdb_assert (0 == offset); gdb_assert (0 == offset);
/* We expect an already resolved data location. */ /* 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 /* For dynamic data types defer memory allocation
until we actual access the value. */ until we actual access the value. */
v = value::allocate_lazy (type); v = value::allocate_lazy (type);
@@ -3683,8 +3683,8 @@ value_from_contents_and_address (struct type *type,
v = value::allocate_lazy (resolved_type); v = value::allocate_lazy (resolved_type);
else else
v = value_from_contents (resolved_type, valaddr); v = value_from_contents (resolved_type, valaddr);
if (TYPE_DATA_LOCATION (resolved_type_no_typedef) != NULL if (resolved_type_no_typedef->dyn_prop (DYN_PROP_DATA_LOCATION) != NULL
&& TYPE_DATA_LOCATION (resolved_type_no_typedef)->is_constant ()) && resolved_type_no_typedef->dyn_prop (DYN_PROP_DATA_LOCATION)->is_constant ())
address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef); address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef);
v->set_lval (lval_memory); v->set_lval (lval_memory);
v->set_address (address); v->set_address (address);