* Re: [patch] Fix gdbserver vRun parsing again
2008-11-24 20:11 ` Pedro Alves
@ 2008-11-24 20:11 ` Daniel Jacobowitz
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-11-24 20:11 UTC (permalink / raw)
To: Pedro Alves; +Cc: gdb-patches
On Mon, Nov 24, 2008 at 05:59:36PM +0000, Pedro Alves wrote:
> I tried it out, and it does do the right thing, and I
> also confirmed the original crash isn't reintroduced.
Thanks! I checked it in.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [patch] Fix gdbserver vRun parsing again
2008-11-24 20:11 [patch] Fix gdbserver vRun parsing again Daniel Jacobowitz
@ 2008-11-24 20:11 ` Pedro Alves
2008-11-24 20:11 ` Daniel Jacobowitz
0 siblings, 1 reply; 3+ messages in thread
From: Pedro Alves @ 2008-11-24 20:11 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches
On Monday 24 November 2008 17:31:35, Daniel Jacobowitz wrote:
> 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".
>
Oh, very sorry about that. I should have sticked to fixing
the crash. :-(
> This patch seems to do the right thing; Pedro, want to take a look at
> this obviously tricky code before I change it?
I tried it out, and it does do the right thing, and I
also confirmed the original crash isn't reintroduced.
Thanks.
--
Pedro Alves
^ permalink raw reply [flat|nested] 3+ messages in thread
* [patch] Fix gdbserver vRun parsing again
@ 2008-11-24 20:11 Daniel Jacobowitz
2008-11-24 20:11 ` Pedro Alves
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Jacobowitz @ 2008-11-24 20:11 UTC (permalink / raw)
To: gdb-patches, Pedro Alves
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')
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-24 18:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-24 20:11 [patch] Fix gdbserver vRun parsing again Daniel Jacobowitz
2008-11-24 20:11 ` Pedro Alves
2008-11-24 20:11 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox