From ccd213ac7e82ba5871e7f46d4c2be5aac7d11054 Mon Sep 17 00:00:00 2001 From: Daniel Jacobowitz Date: Mon, 10 Mar 2008 23:14:06 +0000 Subject: * 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. --- gdb/fork-child.c | 46 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) (limited to 'gdb/fork-child.c') diff --git a/gdb/fork-child.c b/gdb/fork-child.c index 15b8245feed..cbde5dbfac4 100644 --- a/gdb/fork-child.c +++ b/gdb/fork-child.c @@ -31,6 +31,7 @@ #include "terminal.h" #include "gdbthread.h" #include "command.h" /* for dont_repeat () */ +#include "gdbcmd.h" #include "solib.h" #include @@ -40,6 +41,8 @@ extern char **environ; +static char *exec_wrapper; + /* Break up SCRATCH into an argument vector suitable for passing to execvp and store it in ARGV. E.g., on "run a b c d" this routine would get as input the string "a b c d", and as output it would @@ -160,6 +163,9 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env, fact that it may expand when quoted; it is a worst-case number based on every character being '. */ len = 5 + 4 * strlen (exec_file) + 1 + strlen (allargs) + 1 + /*slop */ 12; + if (exec_wrapper) + len += strlen (exec_wrapper) + 1; + shell_command = (char *) alloca (len); shell_command[0] = '\0'; @@ -178,14 +184,22 @@ fork_inferior (char *exec_file_arg, char *allargs, char **env, { /* We're going to call a shell. */ - /* Now add exec_file, quoting as necessary. */ - char *p; int need_to_quote; const int escape_bang = escape_bang_in_quoted_argument (shell_file); strcat (shell_command, "exec "); + /* Add any exec wrapper. That may be a program name with arguments, so + the user must handle quoting. */ + if (exec_wrapper) + { + strcat (shell_command, exec_wrapper); + strcat (shell_command, " "); + } + + /* Now add exec_file, quoting as necessary. */ + /* Quoting in this style is said to work with all shells. But csh on IRIX 4.0.1 can't deal with it. So we only quote it if we need to. */ @@ -399,6 +413,9 @@ startup_inferior (int ntraps) have stopped one instruction after execing the shell. Here we must get it up to actual execution of the real program. */ + if (exec_wrapper) + pending_execs++; + clear_proceed_status (); init_wait_for_inferior (); @@ -446,3 +463,28 @@ startup_inferior (int ntraps) } stop_soon = NO_STOP_QUIETLY; } + +/* Implement the "unset exec-wrapper" command. */ + +static void +unset_exec_wrapper_command (char *args, int from_tty) +{ + xfree (exec_wrapper); + exec_wrapper = NULL; +} + +void +_initialize_fork_child (void) +{ + add_setshow_filename_cmd ("exec-wrapper", class_run, &exec_wrapper, _("\ +Set a wrapper for running programs.\n\ +The wrapper prepares the system and environment for the new program."), + _("\ +Show the wrapper for running programs."), NULL, + NULL, NULL, + &setlist, &showlist); + + add_cmd ("exec-wrapper", class_run, unset_exec_wrapper_command, + _("Disable use of an execution wrapper."), + &unsetlist); +} -- cgit v1.2.1