mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-30 00:52:16 +08:00
Make target_desc::properties an std::vector
This patch changes target_desc::properties to be a vector of property objects. This way, we don't need to manually free the property members as well as the property objects themselves. gdb/ChangeLog: * target-descriptions.c (property_s): Remove typedef. (DEF_VEC_O (property_s)): Remove. (struct target_desc) <properties>: Make an std::vector. <~target_desc>: Don't manually free properties. (tdesc_property): Adjust. (set_tdesc_property): Adjust. (class print_c_tdesc) <visit_pre>: Adjust.
This commit is contained in:

committed by
Simon Marchi

parent
ed9376bd95
commit
129c10bcb9
@ -1,3 +1,13 @@
|
|||||||
|
2017-12-05 Simon Marchi <simon.marchi@polymtl.ca>
|
||||||
|
|
||||||
|
* target-descriptions.c (property_s): Remove typedef.
|
||||||
|
(DEF_VEC_O (property_s)): Remove.
|
||||||
|
(struct target_desc) <properties>: Make an std::vector.
|
||||||
|
<~target_desc>: Don't manually free properties.
|
||||||
|
(tdesc_property): Adjust.
|
||||||
|
(set_tdesc_property): Adjust.
|
||||||
|
(class print_c_tdesc) <visit_pre>: Adjust.
|
||||||
|
|
||||||
2017-12-05 Simon Marchi <simon.marchi@ericsson.com>
|
2017-12-05 Simon Marchi <simon.marchi@ericsson.com>
|
||||||
|
|
||||||
* common/gdb_assert.h (gdb_static_assert): Redefine using
|
* common/gdb_assert.h (gdb_static_assert): Redefine using
|
||||||
|
@ -61,12 +61,15 @@ public:
|
|||||||
|
|
||||||
/* Types. */
|
/* Types. */
|
||||||
|
|
||||||
typedef struct property
|
struct property
|
||||||
{
|
{
|
||||||
char *key;
|
property (const std::string &key_, const std::string &value_)
|
||||||
char *value;
|
: key (key_), value (value_)
|
||||||
} property_s;
|
{}
|
||||||
DEF_VEC_O(property_s);
|
|
||||||
|
std::string key;
|
||||||
|
std::string value;
|
||||||
|
};
|
||||||
|
|
||||||
/* An individual register from a target description. */
|
/* An individual register from a target description. */
|
||||||
|
|
||||||
@ -397,7 +400,6 @@ struct target_desc : tdesc_element
|
|||||||
virtual ~target_desc ()
|
virtual ~target_desc ()
|
||||||
{
|
{
|
||||||
struct tdesc_feature *feature;
|
struct tdesc_feature *feature;
|
||||||
struct property *prop;
|
|
||||||
int ix;
|
int ix;
|
||||||
|
|
||||||
for (ix = 0;
|
for (ix = 0;
|
||||||
@ -406,15 +408,6 @@ struct target_desc : tdesc_element
|
|||||||
delete feature;
|
delete feature;
|
||||||
VEC_free (tdesc_feature_p, features);
|
VEC_free (tdesc_feature_p, features);
|
||||||
|
|
||||||
for (ix = 0;
|
|
||||||
VEC_iterate (property_s, properties, ix, prop);
|
|
||||||
ix++)
|
|
||||||
{
|
|
||||||
xfree (prop->key);
|
|
||||||
xfree (prop->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
VEC_free (property_s, properties);
|
|
||||||
VEC_free (arch_p, compatible);
|
VEC_free (arch_p, compatible);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +425,7 @@ struct target_desc : tdesc_element
|
|||||||
VEC(arch_p) *compatible = NULL;
|
VEC(arch_p) *compatible = NULL;
|
||||||
|
|
||||||
/* Any architecture-specific properties specified by the target. */
|
/* Any architecture-specific properties specified by the target. */
|
||||||
VEC(property_s) *properties = NULL;
|
std::vector<property> properties;
|
||||||
|
|
||||||
/* The features associated with this target. */
|
/* The features associated with this target. */
|
||||||
VEC(tdesc_feature_p) *features = NULL;
|
VEC(tdesc_feature_p) *features = NULL;
|
||||||
@ -726,13 +719,9 @@ tdesc_compatible_p (const struct target_desc *target_desc,
|
|||||||
const char *
|
const char *
|
||||||
tdesc_property (const struct target_desc *target_desc, const char *key)
|
tdesc_property (const struct target_desc *target_desc, const char *key)
|
||||||
{
|
{
|
||||||
struct property *prop;
|
for (const property &prop : target_desc->properties)
|
||||||
int ix;
|
if (prop.key == key)
|
||||||
|
return prop.value.c_str ();
|
||||||
for (ix = 0; VEC_iterate (property_s, target_desc->properties, ix, prop);
|
|
||||||
ix++)
|
|
||||||
if (strcmp (prop->key, key) == 0)
|
|
||||||
return prop->value;
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -1800,20 +1789,13 @@ void
|
|||||||
set_tdesc_property (struct target_desc *target_desc,
|
set_tdesc_property (struct target_desc *target_desc,
|
||||||
const char *key, const char *value)
|
const char *key, const char *value)
|
||||||
{
|
{
|
||||||
struct property *prop, new_prop;
|
|
||||||
int ix;
|
|
||||||
|
|
||||||
gdb_assert (key != NULL && value != NULL);
|
gdb_assert (key != NULL && value != NULL);
|
||||||
|
|
||||||
for (ix = 0; VEC_iterate (property_s, target_desc->properties, ix, prop);
|
if (tdesc_property (target_desc, key) != NULL)
|
||||||
ix++)
|
|
||||||
if (strcmp (prop->key, key) == 0)
|
|
||||||
internal_error (__FILE__, __LINE__,
|
internal_error (__FILE__, __LINE__,
|
||||||
_("Attempted to add duplicate property \"%s\""), key);
|
_("Attempted to add duplicate property \"%s\""), key);
|
||||||
|
|
||||||
new_prop.key = xstrdup (key);
|
target_desc->properties.emplace_back (key, value);
|
||||||
new_prop.value = xstrdup (value);
|
|
||||||
VEC_safe_push (property_s, target_desc->properties, &new_prop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* See arch/tdesc.h. */
|
/* See arch/tdesc.h. */
|
||||||
@ -1986,12 +1968,10 @@ public:
|
|||||||
if (ix)
|
if (ix)
|
||||||
printf_unfiltered ("\n");
|
printf_unfiltered ("\n");
|
||||||
|
|
||||||
for (ix = 0; VEC_iterate (property_s, e->properties, ix, prop);
|
for (const property &prop : e->properties)
|
||||||
ix++)
|
|
||||||
{
|
|
||||||
printf_unfiltered (" set_tdesc_property (result, \"%s\", \"%s\");\n",
|
printf_unfiltered (" set_tdesc_property (result, \"%s\", \"%s\");\n",
|
||||||
prop->key, prop->value);
|
prop.key.c_str (), prop.value.c_str ());
|
||||||
}
|
|
||||||
printf_unfiltered (" struct tdesc_feature *feature;\n");
|
printf_unfiltered (" struct tdesc_feature *feature;\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user