summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-05-07 11:08:54 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-07 11:32:33 -0400
commit7aa913136675f4b81cd3a548e44bbdab6185abed (patch)
treed047a7bd99cb3ebf0cf0a89f4062aa4c96fc24f5
parent5c54719c22b14f526e72be39a793657ac73d36c5 (diff)
downloadbinutils-gdb-7aa913136675f4b81cd3a548e44bbdab6185abed.tar.gz
gdb: make remove_dyn_prop a method of struct type
Move remove_dyn_prop, currently a free function, to be a method of struct type. gdb/ChangeLog: * gdbtypes.h (struct type) <remove_dyn_prop>: New method. (remove_dyn_prop): Remove. Update all users to use type::remove_dyn_prop. * gdbtypes.c (remove_dyn_prop): Rename to... (type::remove_dyn_prop): ... this.
-rw-r--r--gdb/ChangeLog8
-rw-r--r--gdb/gdbtypes.c15
-rw-r--r--gdb/gdbtypes.h6
-rw-r--r--gdb/value.c2
4 files changed, 19 insertions, 12 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 857897f8f88..f9ebdd01a77 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-07 Simon Marchi <simon.marchi@efficios.com>
+
+ * gdbtypes.h (struct type) <remove_dyn_prop>: New method.
+ (remove_dyn_prop): Remove. Update all users to use
+ type::remove_dyn_prop.
+ * gdbtypes.c (remove_dyn_prop): Rename to...
+ (type::remove_dyn_prop): ... this.
+
2020-05-07 Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
* gdbtypes.h (struct type) <add_dyn_prop>: New method.
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index 1444351c518..d8b723751e1 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -2204,7 +2204,7 @@ resolve_dynamic_array_or_string (struct type *type,
{
if (dwarf2_evaluate_property (prop, NULL, addr_stack, &value))
{
- remove_dyn_prop (DYN_PROP_BYTE_STRIDE, type);
+ type->remove_dyn_prop (DYN_PROP_BYTE_STRIDE);
bit_stride = (unsigned int) (value * 8);
}
else
@@ -2621,7 +2621,7 @@ resolve_dynamic_type_internal (struct type *type,
if (type_length.has_value ())
{
TYPE_LENGTH (resolved_type) = *type_length;
- remove_dyn_prop (DYN_PROP_BYTE_SIZE, resolved_type);
+ resolved_type->remove_dyn_prop (DYN_PROP_BYTE_SIZE);
}
/* Resolve data_location attribute. */
@@ -2683,27 +2683,26 @@ type::add_dyn_prop (dynamic_prop_node_kind prop_kind, dynamic_prop prop)
TYPE_DYN_PROP_LIST (this) = temp;
}
-/* Remove dynamic property from TYPE in case it exists. */
+/* See gdbtypes.h. */
void
-remove_dyn_prop (enum dynamic_prop_node_kind prop_kind,
- struct type *type)
+type::remove_dyn_prop (dynamic_prop_node_kind kind)
{
struct dynamic_prop_list *prev_node, *curr_node;
- curr_node = TYPE_DYN_PROP_LIST (type);
+ curr_node = TYPE_DYN_PROP_LIST (this);
prev_node = NULL;
while (NULL != curr_node)
{
- if (curr_node->prop_kind == prop_kind)
+ if (curr_node->prop_kind == kind)
{
/* Update the linked list but don't free anything.
The property was allocated on objstack and it is not known
if we are on top of it. Nevertheless, everything is released
when the complete objstack is freed. */
if (NULL == prev_node)
- TYPE_DYN_PROP_LIST (type) = curr_node->next;
+ TYPE_DYN_PROP_LIST (this) = curr_node->next;
else
prev_node->next = curr_node->next;
diff --git a/gdb/gdbtypes.h b/gdb/gdbtypes.h
index ef991f3c8da..50a0c135ded 100644
--- a/gdb/gdbtypes.h
+++ b/gdb/gdbtypes.h
@@ -884,6 +884,9 @@ struct type
This function assumes that this type is objfile-owned. */
void add_dyn_prop (dynamic_prop_node_kind kind, dynamic_prop prop);
+ /* * Remove dynamic property of kind KIND from this type, if it exists. */
+ void remove_dyn_prop (dynamic_prop_node_kind kind);
+
/* * Type that is a pointer to this type.
NULL if no such pointer-to type is known yet.
The debugger may add the address of such a type
@@ -2103,9 +2106,6 @@ extern struct type *resolve_dynamic_type
/* * Predicate if the type has dynamic values, which are not resolved yet. */
extern int is_dynamic_type (struct type *type);
-extern void remove_dyn_prop (enum dynamic_prop_node_kind prop_kind,
- struct type *type);
-
extern struct type *check_typedef (struct type *);
extern void check_stub_method_group (struct type *, int);
diff --git a/gdb/value.c b/gdb/value.c
index 7ea39af5551..aafbf0fc06b 100644
--- a/gdb/value.c
+++ b/gdb/value.c
@@ -2291,7 +2291,7 @@ set_internalvar (struct internalvar *var, struct value *val)
when accessing the value.
If we keep it, we would still refer to the origin value.
Remove the location property in case it exist. */
- remove_dyn_prop (DYN_PROP_DATA_LOCATION, value_type (new_data.value));
+ value_type (new_data.value)->remove_dyn_prop (DYN_PROP_DATA_LOCATION);
break;
}