From: Andrew Burgess <aburgess@redhat.com>
To: gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>, Andreas Schwab <schwab@suse.de>
Subject: [PATCHv2 4/5] gdbserver: cleanup in handle_v_run
Date: Wed, 27 Sep 2023 18:27:57 +0100 [thread overview]
Message-ID: <101de2688bc146244f0ae89477cfd4adf3606551.1695835626.git.aburgess@redhat.com> (raw)
In-Reply-To: <cover.1695835626.git.aburgess@redhat.com>
After the previous commit there is now a redundant string copy in
handle_v_run, this commit cleans that up.
There should be no functional change after this commit.
---
gdbserver/server.cc | 24 +++++-------------------
1 file changed, 5 insertions(+), 19 deletions(-)
diff --git a/gdbserver/server.cc b/gdbserver/server.cc
index 84b8712e668..e02cdb83b51 100644
--- a/gdbserver/server.cc
+++ b/gdbserver/server.cc
@@ -2989,33 +2989,19 @@ handle_v_run (char *own_buf)
}
else
{
+ /* The length of the decoded argument. */
size_t len = (next_p - p) / 2;
- /* ARG is the unquoted argument received via the RSP. */
+
+ /* Buffer to decode the argument into. */
char *arg = (char *) xmalloc (len + 1);
- /* FULL_ARGS will contain the quoted version of ARG. */
- char *full_arg = (char *) xmalloc ((len + 1) * 2);
- /* These are pointers used to navigate the strings above. */
- char *tmp_arg = arg;
- char *tmp_full_arg = full_arg;
hex2bin (p, (gdb_byte *) arg, len);
arg[len] = '\0';
- while (*tmp_arg != '\0')
- {
- *tmp_full_arg = *tmp_arg;
- ++tmp_full_arg;
- ++tmp_arg;
- }
-
- /* Finish FULL_ARG and push it into the vector containing
- the argv. */
- *tmp_full_arg = '\0';
if (i == 0)
- new_program_name = full_arg;
+ new_program_name = arg;
else
- new_argv.push_back (full_arg);
- xfree (arg);
+ new_argv.push_back (arg);
}
if (*next_p == '\0')
break;
--
2.25.4
next prev parent reply other threads:[~2023-09-27 17:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-27 12:21 [PATCH] gdbserver: fix handling of single quote arguments Andrew Burgess
2023-09-27 13:01 ` Andreas Schwab
2023-09-27 17:27 ` [PATCHv2 0/5] Fixes for passing arguments to gdbserver Andrew Burgess
2023-09-27 17:27 ` [PATCHv2 1/5] gdbserver: fix handling of single quote arguments Andrew Burgess
2023-09-27 17:27 ` [PATCHv2 2/5] gdbserver: fix handling of trailing empty argument Andrew Burgess
2023-09-27 17:27 ` [PATCHv2 3/5] gdbserver: handle newlines in inferior arguments Andrew Burgess
2023-09-27 17:27 ` Andrew Burgess [this message]
2023-10-03 19:13 ` [PATCHv2 4/5] gdbserver: cleanup in handle_v_run Tom Tromey
2023-10-04 14:40 ` Andrew Burgess
2023-10-04 19:35 ` Tom Tromey
2023-09-27 17:27 ` [PATCHv2 5/5] gdb/testsuite: cleanup in gdb.base/args.exp Andrew Burgess
2023-10-05 16:17 ` Tom Tromey
2023-10-05 16:18 ` [PATCHv2 0/5] Fixes for passing arguments to gdbserver Tom Tromey
2023-10-06 12:15 ` Andrew Burgess
2023-10-06 12:56 ` Tom Tromey
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=101de2688bc146244f0ae89477cfd4adf3606551.1695835626.git.aburgess@redhat.com \
--to=aburgess@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=schwab@suse.de \
/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).