From: Simon Marchi <simon.marchi@ericsson.com>
To: <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@polymtl.ca>
Subject: [PATCH 2/3] Use std::vector and std::string instead of VEC(char_ptr) in gdbserver tdesc
Date: Wed, 21 Mar 2018 21:25:00 -0000 [thread overview]
Message-ID: <1521667509-303-2-git-send-email-simon.marchi@ericsson.com> (raw)
In-Reply-To: <1521667509-303-1-git-send-email-simon.marchi@ericsson.com>
From: Simon Marchi <simon.marchi@polymtl.ca>
This is a straightforward replacement, no change in behavior are
intended/expected.
gdb/gdbserver/ChangeLog:
* tdesc.h (struct target_desc) <features>: Change type to
std::vector<std::string>.
* tdesc.c (tdesc_get_features_xml): Adjust to std::vector
changes.
(tdesc_create_feature): Likewise.
---
gdb/gdbserver/tdesc.c | 7 +++----
gdb/gdbserver/tdesc.h | 8 +-------
2 files changed, 4 insertions(+), 11 deletions(-)
diff --git a/gdb/gdbserver/tdesc.c b/gdb/gdbserver/tdesc.c
index 00a5e8d..3a932e6 100644
--- a/gdb/gdbserver/tdesc.c
+++ b/gdb/gdbserver/tdesc.c
@@ -91,7 +91,7 @@ tdesc_get_features_xml (target_desc *tdesc)
{
/* Either .xmltarget or .features is not NULL. */
gdb_assert (tdesc->xmltarget != NULL
- || (tdesc->features != NULL
+ || (!tdesc->features.empty ()
&& tdesc->arch != NULL));
if (tdesc->xmltarget == NULL)
@@ -111,9 +111,8 @@ tdesc_get_features_xml (target_desc *tdesc)
buffer += "</osabi>";
}
- char *xml;
- for (int i = 0; VEC_iterate (char_ptr, tdesc->features, i, xml); i++)
+ for (const std::string &xml : tdesc->features)
{
buffer += "<xi:include href=\"";
buffer += xml;
@@ -139,7 +138,7 @@ tdesc_create_feature (struct target_desc *tdesc, const char *name,
const char *xml)
{
#ifndef IN_PROCESS_AGENT
- VEC_safe_push (char_ptr, tdesc->features, xstrdup (xml));
+ tdesc->features.emplace_back (xml);
#endif
return tdesc;
}
diff --git a/gdb/gdbserver/tdesc.h b/gdb/gdbserver/tdesc.h
index d21574c..e501257 100644
--- a/gdb/gdbserver/tdesc.h
+++ b/gdb/gdbserver/tdesc.h
@@ -54,7 +54,7 @@ struct target_desc : tdesc_feature
const char *xmltarget = NULL;
/* XML features in this target description. */
- VEC (char_ptr) *features = NULL;
+ std::vector<std::string> features;
/* The value of <architecture> element in the XML, replying GDB. */
const char *arch = NULL;
@@ -76,12 +76,6 @@ public:
xfree ((char *) arch);
xfree ((char *) osabi);
-
- char *f;
-
- for (i = 0; VEC_iterate (char_ptr, features, i, f); i++)
- xfree (f);
- VEC_free (char_ptr, features);
}
bool operator== (const target_desc &other) const
--
2.7.4
next prev parent reply other threads:[~2018-03-21 21:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 21:25 [PATCH 1/3] Use std::vector in uploaded_tp Simon Marchi
2018-03-21 21:25 ` [PATCH 3/3] Remove usage of VEC(char_ptr) in gdbscm_parse_function_args Simon Marchi
2018-04-01 16:29 ` Tom Tromey
2018-04-01 18:25 ` Simon Marchi
2018-04-02 2:23 ` Tom Tromey
2018-03-21 21:25 ` Simon Marchi [this message]
2018-03-30 21:20 ` [PATCH 1/3] Use std::vector in uploaded_tp Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1521667509-303-2-git-send-email-simon.marchi@ericsson.com \
--to=simon.marchi@ericsson.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@polymtl.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).