forked from Imagelibrary/binutils-gdb
* 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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user