diff options
author | Daniel Jacobowitz <drow@false.org> | 2008-03-10 23:14:06 +0000 |
---|---|---|
committer | Daniel Jacobowitz <drow@false.org> | 2008-03-10 23:14:06 +0000 |
commit | ccd213ac7e82ba5871e7f46d4c2be5aac7d11054 (patch) | |
tree | b0f7a3b2bb209fd34a08d9c693da73996dcc90eb /gdb/gdbserver | |
parent | 42e344a77c6f6f46e98482117e80c3d0ea9db853 (diff) | |
download | gdb-ccd213ac7e82ba5871e7f46d4c2be5aac7d11054.zip gdb-ccd213ac7e82ba5871e7f46d4c2be5aac7d11054.tar.gz gdb-ccd213ac7e82ba5871e7f46d4c2be5aac7d11054.tar.bz2 |
* Makefile.in (fork-child.o): Update.
* NEWS: Document "set exec-wrapper" and the gdbserver --wrapper
argument. Gather all gdbserver features together.
* fork-child.c (exec_wrapper): New variable.
(fork_inferior): Use it.
(startup_inferior): Skip an extra trap if using "set exec-wrapper".
(unset_exec_wrapper_command, _initialize_fork_child): New.
* gdb.texinfo (Starting): Document "set exec-wrapper".
(Server): Document gdbserver --wrapper.
* server.c (wrapper_argv): New.
(start_inferior): Handle wrapper_argv. If set, expect an extra
trap.
(gdbserver_usage): Document --wrapper.
(main): Parse --wrapper.
Diffstat (limited to 'gdb/gdbserver')
-rw-r--r-- | gdb/gdbserver/ChangeLog | 8 | ||||
-rw-r--r-- | gdb/gdbserver/server.c | 71 |
2 files changed, 75 insertions, 4 deletions
diff --git a/gdb/gdbserver/ChangeLog b/gdb/gdbserver/ChangeLog index a59668c..e25f236 100644 --- a/gdb/gdbserver/ChangeLog +++ b/gdb/gdbserver/ChangeLog @@ -1,3 +1,11 @@ +2008-03-10 Daniel Jacobowitz <dan@codesourcery.com> + + * server.c (wrapper_argv): New. + (start_inferior): Handle wrapper_argv. If set, expect an extra + trap. + (gdbserver_usage): Document --wrapper. + (main): Parse --wrapper. + 2008-02-28 Ulrich Weigand <uweigand@de.ibm.com> * configure.srv [powerpc64-*-linux*]: Add all files mentioned for diff --git a/gdb/gdbserver/server.c b/gdb/gdbserver/server.c index 7806bd6..634bf80 100644 --- a/gdb/gdbserver/server.c +++ b/gdb/gdbserver/server.c @@ -41,7 +41,7 @@ static int attached; static int response_needed; static int exit_requested; -static char **program_argv; +static char **program_argv, **wrapper_argv; /* Enable miscellaneous debugging output. The name is historical - it was originally used to debug LinuxThreads support. */ @@ -83,16 +83,34 @@ target_running (void) } static int -start_inferior (char *argv[], char *statusptr) +start_inferior (char **argv, char *statusptr) { + char **new_argv = argv; attached = 0; + if (wrapper_argv != NULL) + { + int i, count = 1; + + for (i = 0; wrapper_argv[i] != NULL; i++) + count++; + for (i = 0; argv[i] != NULL; i++) + count++; + new_argv = alloca (sizeof (char *) * count); + count = 0; + for (i = 0; wrapper_argv[i] != NULL; i++) + new_argv[count++] = wrapper_argv[i]; + for (i = 0; argv[i] != NULL; i++) + new_argv[count++] = argv[i]; + new_argv[count] = NULL; + } + #ifdef SIGTTOU signal (SIGTTOU, SIG_DFL); signal (SIGTTIN, SIG_DFL); #endif - signal_pid = create_inferior (argv[0], argv); + signal_pid = create_inferior (new_argv[0], new_argv); /* FIXME: we don't actually know at this point that the create actually succeeded. We won't know that until we wait. */ @@ -109,6 +127,33 @@ start_inferior (char *argv[], char *statusptr) atexit (restore_old_foreground_pgrp); #endif + if (wrapper_argv != NULL) + { + struct thread_resume resume_info; + int sig; + + resume_info.thread = -1; + resume_info.step = 0; + resume_info.sig = 0; + resume_info.leave_stopped = 0; + + sig = mywait (statusptr, 0); + if (*statusptr != 'T') + return sig; + + do + { + (*the_target->resume) (&resume_info); + + sig = mywait (statusptr, 0); + if (*statusptr != 'T') + return sig; + } + while (sig != TARGET_SIGNAL_TRAP); + + return sig; + } + /* Wait till we are at 1st instruction in program, return signal number (assuming success). */ return mywait (statusptr, 0); @@ -1002,7 +1047,8 @@ gdbserver_usage (void) "HOST:PORT to listen for a TCP connection.\n" "\n" "Options:\n" - " --debug\t\tEnable debugging output.\n"); + " --debug\t\tEnable debugging output.\n" + " --wrapper WRAPPER --\tRun WRAPPER to start new programs.\n"); } #undef require_running @@ -1046,6 +1092,23 @@ main (int argc, char *argv[]) attach = 1; else if (strcmp (*next_arg, "--multi") == 0) multi_mode = 1; + else if (strcmp (*next_arg, "--wrapper") == 0) + { + next_arg++; + + wrapper_argv = next_arg; + while (*next_arg != NULL && strcmp (*next_arg, "--") != 0) + next_arg++; + + if (next_arg == wrapper_argv || *next_arg == NULL) + { + gdbserver_usage (); + exit (1); + } + + /* Consume the "--". */ + *next_arg = NULL; + } else if (strcmp (*next_arg, "--debug") == 0) debug_threads = 1; else |