diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2017-12-05 16:30:24 -0500 |
---|---|---|
committer | Simon Marchi <simon.marchi@ericsson.com> | 2017-12-05 16:30:24 -0500 |
commit | f65ff9f9a4add415e5ae332a094b2134c1625517 (patch) | |
tree | 79a62aa6683804272c88cec43b87cef4e4f439b6 | |
parent | 3eea796c5daeb7b60531fc3d707470fa91a86e11 (diff) | |
download | gdb-f65ff9f9a4add415e5ae332a094b2134c1625517.zip gdb-f65ff9f9a4add415e5ae332a094b2134c1625517.tar.gz gdb-f65ff9f9a4add415e5ae332a094b2134c1625517.tar.bz2 |
Make tdesc_feature::name an std::string
... so we don't have to manually free it in ~tdesc_feature.
gdb/ChangeLog:
* target-descriptions.c (tdesc_feature) <name>: Change type to
std::string.
<~tdesc_feature>: Don't manually free name.
<operator==>: Adjust.
(tdesc_find_feature): Adjust.
(tdesc_feature_name): Adjust.
(class print_c_tdesc) <visit_pre>: Adjust.
(class print_c_feature) <visit_pre>: Adjust.
-rw-r--r-- | gdb/ChangeLog | 11 | ||||
-rw-r--r-- | gdb/target-descriptions.c | 18 |
2 files changed, 19 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 36aa114..e3c1cbf 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,16 @@ 2017-12-05 Simon Marchi <simon.marchi@polymtl.ca> + * target-descriptions.c (tdesc_feature) <name>: Change type to + std::string. + <~tdesc_feature>: Don't manually free name. + <operator==>: Adjust. + (tdesc_find_feature): Adjust. + (tdesc_feature_name): Adjust. + (class print_c_tdesc) <visit_pre>: Adjust. + (class print_c_feature) <visit_pre>: Adjust. + +2017-12-05 Simon Marchi <simon.marchi@polymtl.ca> + * target-descriptions.c (tdesc_feature_p): Remove typedef. (DEF_VEC_P (tdesc_feature_p)): Remove. (struct target_desc) <features>: Change type to std::vector. diff --git a/gdb/target-descriptions.c b/gdb/target-descriptions.c index c669b70..eda46a5 100644 --- a/gdb/target-descriptions.c +++ b/gdb/target-descriptions.c @@ -281,8 +281,8 @@ DEF_VEC_P(tdesc_type_p); struct tdesc_feature : tdesc_element { - tdesc_feature (const char *name_) - : name (xstrdup (name_)) + tdesc_feature (const std::string &name_) + : name (name_) {} virtual ~tdesc_feature () @@ -298,15 +298,13 @@ struct tdesc_feature : tdesc_element for (ix = 0; VEC_iterate (tdesc_type_p, types, ix, type); ix++) delete type; VEC_free (tdesc_type_p, types); - - xfree (name); } DISABLE_COPY_AND_ASSIGN (tdesc_feature); /* The name of this feature. It may be recognized by the architecture support code. */ - char *name; + std::string name; /* The registers associated with this feature. */ VEC(tdesc_reg_p) *registers = NULL; @@ -338,7 +336,7 @@ struct tdesc_feature : tdesc_element bool operator== (const tdesc_feature &other) const { - if (strcmp (name, other.name) != 0) + if (name != other.name) return false; if (VEC_length (tdesc_reg_p, registers) @@ -741,7 +739,7 @@ tdesc_find_feature (const struct target_desc *target_desc, const char *name) { for (const tdesc_feature_up &feature : target_desc->features) - if (strcmp (feature->name, name) == 0) + if (feature->name == name) return feature.get (); return NULL; @@ -752,7 +750,7 @@ tdesc_find_feature (const struct target_desc *target_desc, const char * tdesc_feature_name (const struct tdesc_feature *feature) { - return feature->name; + return feature->name.c_str (); } /* Predefined types. */ @@ -1925,7 +1923,7 @@ public: void visit_pre (const tdesc_feature *e) override { printf_unfiltered ("\n feature = tdesc_create_feature (result, \"%s\");\n", - e->name); + e->name.c_str ()); } void visit_post (const tdesc_feature *e) override @@ -2143,7 +2141,7 @@ public: printf_unfiltered ("\n feature = tdesc_create_feature (result, \"%s\", \"%s\");\n", - e->name, lbasename (m_filename_after_features.c_str ())); + e->name.c_str (), lbasename (m_filename_after_features.c_str ())); } void visit_post (const tdesc_feature *e) override |