mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-19 01:19:41 +08:00
Add dynamic_prop::is_constant
I noticed many spots checking whether a dynamic property's kind is PROP_CONST. Some spots, I think, are doing a slightly incorrect check -- checking for != PROP_UNDEFINED where == PROP_CONST is actually required, the key thing being that const_val may only be called for PROP_CONST properties. This patch adds dynamic::is_constant and then updates these checks to use it. Regression tested on x86-64 Fedora 36.
This commit is contained in:
10
gdb/value.c
10
gdb/value.c
@@ -1362,7 +1362,7 @@ value::address () const
|
||||
return m_parent->address () + m_offset;
|
||||
if (NULL != TYPE_DATA_LOCATION (type ()))
|
||||
{
|
||||
gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (type ()));
|
||||
gdb_assert (TYPE_DATA_LOCATION (type ())->is_constant ());
|
||||
return TYPE_DATA_LOCATION_ADDR (type ());
|
||||
}
|
||||
|
||||
@@ -1612,14 +1612,14 @@ value::set_component_location (const struct value *whole)
|
||||
update the address of the COMPONENT. */
|
||||
type = whole->type ();
|
||||
if (NULL != TYPE_DATA_LOCATION (type)
|
||||
&& TYPE_DATA_LOCATION_KIND (type) == PROP_CONST)
|
||||
&& TYPE_DATA_LOCATION (type)->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_KIND (type) == PROP_CONST)
|
||||
&& TYPE_DATA_LOCATION (type)->is_constant ())
|
||||
{
|
||||
/* If the COMPONENT has a dynamic location, and is an
|
||||
lval_internalvar_component, then we change it to a lval_memory.
|
||||
@@ -3005,7 +3005,7 @@ value::primitive_field (LONGEST offset, int fieldno, struct type *arg_type)
|
||||
|
||||
gdb_assert (0 == offset);
|
||||
/* We expect an already resolved data location. */
|
||||
gdb_assert (PROP_CONST == TYPE_DATA_LOCATION_KIND (type));
|
||||
gdb_assert (TYPE_DATA_LOCATION (type)->is_constant ());
|
||||
/* For dynamic data types defer memory allocation
|
||||
until we actual access the value. */
|
||||
v = value::allocate_lazy (type);
|
||||
@@ -3558,7 +3558,7 @@ value_from_contents_and_address (struct type *type,
|
||||
else
|
||||
v = value_from_contents (resolved_type, valaddr);
|
||||
if (TYPE_DATA_LOCATION (resolved_type_no_typedef) != NULL
|
||||
&& TYPE_DATA_LOCATION_KIND (resolved_type_no_typedef) == PROP_CONST)
|
||||
&& TYPE_DATA_LOCATION (resolved_type_no_typedef)->is_constant ())
|
||||
address = TYPE_DATA_LOCATION_ADDR (resolved_type_no_typedef);
|
||||
v->set_lval (lval_memory);
|
||||
v->set_address (address);
|
||||
|
||||
Reference in New Issue
Block a user