2008-10-10 Pedro Alves * server.c (handle_v_run): If GDB didn't specify an argv, use the whole argv from the last run, not just argv[0]. --- gdb/gdbserver/server.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) Index: src/gdb/gdbserver/server.c =================================================================== --- src.orig/gdb/gdbserver/server.c 2008-10-10 12:18:02.000000000 +0100 +++ src/gdb/gdbserver/server.c 2008-10-10 12:18:09.000000000 +0100 @@ -1096,23 +1096,31 @@ 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'. */ + if (program_argv == NULL) { write_enn (own_buf); return 0; } - new_argv[0] = strdup (program_argv[0]); + /* We can reuse the old args. We don't need this then. */ + free (new_argv); } - - /* Free the old argv. */ - if (program_argv) + else { - for (pp = program_argv; *pp != NULL; pp++) - free (*pp); - free (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; } - program_argv = new_argv; *signal = start_inferior (program_argv, status); if (*status == 'T')