From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sourceware.org, Pedro Alves <pedro@codesourcery.com>
Subject: [patch] Fix gdbserver vRun parsing again
Date: Mon, 24 Nov 2008 20:11:00 -0000 [thread overview]
Message-ID: <20081124173135.GA9091@caradoc.them.org> (raw)
As part of closing PR 2474, I took another look at Pedro's fix last
month to vRun. I approved it at the time but now I can see that he
and I were both a little confused about the documented semantics :-(
With Pedro's patch, "target extended-remote", "run one", "run two"
will never run the program with argv[1] == "two". We're always
supposed to use the new argv. "vRun;" means "old program, no args";
"vRun;;XXXX" means "old program, decoded arg XXXX".
This patch seems to do the right thing; Pedro, want to take a look at
this obviously tricky code before I change it?
--
Daniel Jacobowitz
CodeSourcery
2008-11-24 Daniel Jacobowitz <dan@codesourcery.com>
* server.c (handle_v_run): Always use the supplied argument list.
Index: server.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbserver/server.c,v
retrieving revision 1.79
diff -u -p -r1.79 server.c
--- server.c 10 Oct 2008 14:06:05 -0000 1.79
+++ server.c 24 Nov 2008 17:24:44 -0000
@@ -1071,7 +1071,7 @@ handle_v_run (char *own_buf, char *statu
new_argc++;
}
- new_argv = malloc ((new_argc + 2) * sizeof (char *));
+ new_argv = calloc (new_argc + 2, sizeof (char *));
i = 0;
for (p = own_buf + strlen ("vRun;"); *p; p = next_p)
{
@@ -1096,10 +1096,8 @@ handle_v_run (char *own_buf, char *statu
if (new_argv[0] == NULL)
{
- /* GDB didn't specify a program to run. Try to use the argv
- from the last run: either from the last vRun with a non-empty
- argv, or from what the user specified if gdbserver was
- started as: `gdbserver :1234 PROG ARGS'. */
+ /* GDB didn't specify a program to run. Use the program from the
+ last run with the new argument list. */
if (program_argv == NULL)
{
@@ -1107,20 +1105,17 @@ handle_v_run (char *own_buf, char *statu
return 0;
}
- /* We can reuse the old args. We don't need this then. */
- free (new_argv);
+ new_argv[0] = strdup (program_argv[0]);
}
- else
+
+ /* Free the old argv. */
+ if (program_argv)
{
- /* Free the old argv. */
- if (program_argv)
- {
- for (pp = program_argv; *pp != NULL; pp++)
- free (*pp);
- free (program_argv);
- }
- program_argv = new_argv;
+ for (pp = program_argv; *pp != NULL; pp++)
+ free (*pp);
+ free (program_argv);
}
+ program_argv = new_argv;
*signal = start_inferior (program_argv, status);
if (*status == 'T')
next reply other threads:[~2008-11-24 17:32 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-24 20:11 Daniel Jacobowitz [this message]
2008-11-24 20:11 ` Pedro Alves
2008-11-24 20:11 ` Daniel Jacobowitz
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=20081124173135.GA9091@caradoc.them.org \
--to=drow@false.org \
--cc=gdb-patches@sourceware.org \
--cc=pedro@codesourcery.com \
/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