/* Fork a Unix child process, and set up to debug it, for GDB.
Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
- 2001, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
+ 2001, 2004, 2005, 2006, 2007, 2008, 2009, 2010
+ Free Software Foundation, Inc.
Contributed by Cygnus Support.
#include "defs.h"
#include "gdb_string.h"
-#include "frame.h" /* required by inferior.h */
#include "inferior.h"
+#include "terminal.h"
#include "target.h"
#include "gdb_wait.h"
#include "gdb_vfork.h"
static void
breakup_args (char *scratch, char **argv)
{
- char *cp = scratch;
+ char *cp = scratch, *tmp;
for (;;)
{
*argv++ = cp;
/* Scan for next arg separator. */
- cp = strchr (cp, ' ');
- if (cp == NULL)
- cp = strchr (cp, '\t');
- if (cp == NULL)
- cp = strchr (cp, '\n');
+ tmp = strchr (cp, ' ');
+ if (tmp == NULL)
+ tmp = strchr (cp, '\t');
+ if (tmp == NULL)
+ tmp = strchr (cp, '\n');
/* No separators => end of string => break. */
- if (cp == NULL)
+ if (tmp == NULL)
break;
+ cp = tmp;
/* Replace the separator with a terminator. */
*cp++ = '\0';
int shell = 0;
static char **argv;
const char *inferior_io_terminal = get_inferior_io_terminal ();
+ struct inferior *inf;
/* If no exec file handed to us, get it from the exec-file command
-- with a good, common error message if none is specified. */
assuming that every other character is a separate
argument. */
int argc = (strlen (allargs) + 1) / 2 + 2;
+
argv = (char **) xmalloc (argc * sizeof (*argv));
argv[0] = exec_file;
breakup_args (allargs, &argv[1]);
if (!have_inferiors ())
init_thread_list ();
- add_inferior (pid);
+ inf = current_inferior ();
+
+ inferior_appeared (inf, pid);
/* Needed for wait_for_inferior stuff below. */
inferior_ptid = pid_to_ptid (pid);
+ new_tty_postfork ();
+
/* We have something that executes now. We'll be running through
the shell at this point, but the pid shouldn't change. Targets
supporting MT should fill this task's ptid with more data as soon
while (1)
{
- int resume_signal = TARGET_SIGNAL_0;
+ enum target_signal resume_signal = TARGET_SIGNAL_0;
ptid_t event_ptid;
struct target_waitstatus ws;
memset (&ws, 0, sizeof (ws));
- event_ptid = target_wait (resume_ptid, &ws);
+ event_ptid = target_wait (resume_ptid, &ws, 0);
if (ws.kind == TARGET_WAITKIND_IGNORE)
/* The inferior didn't really stop, keep waiting. */