/* GNU/Linux native-dependent code for debugging multiple forks.
- Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+ Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include "defs.h"
#include "inferior.h"
#include "linux-nat.h"
#include <sys/ptrace.h>
-#include <sys/wait.h>
+#include "gdb_wait.h"
#include <sys/param.h>
-#include <dirent.h>
+#include "gdb_dirent.h"
#include <ctype.h>
struct fork_info *fork_list;
linux_nat_switch_fork (inferior_ptid);
if (fp->savedregs && fp->clobber_regs)
- regcache_cpy (current_regcache, fp->savedregs);
+ regcache_cpy (get_current_regcache (), fp->savedregs);
registers_changed ();
reinit_frame_cache ();
if (fp->savedregs)
regcache_xfree (fp->savedregs);
- fp->savedregs = regcache_dup (current_regcache);
+ fp->savedregs = regcache_dup (get_current_regcache ());
fp->clobber_regs = clobber_regs;
fp->pc = read_pc ();
{
pid = PIDGET (fp->ptid);
do {
- ptrace (PT_KILL, pid, 0, 0);
+ /* Use SIGKILL instead of PTRACE_KILL because the former works even
+ if the thread is running, while the later doesn't. */
+ kill (pid, SIGKILL);
ret = waitpid (pid, &status, 0);
/* We might get a SIGCHLD instead of an exit status. This is
aggravated by the first kill above - a child has just
if (fp->num == 0)
printf_filtered (_(" (main process)"));
printf_filtered (_(" at "));
- deprecated_print_address_numeric (pc, 1, gdb_stdout);
+ fputs_filtered (paddress (pc), gdb_stdout);
sal = find_pc_line (pc, 0);
if (sal.symtab)
/* Make this temp var static, 'cause it's used in the error context. */
static int temp_detach_fork;
+ /* Remove breakpoints, so that they are not inserted
+ in the forked process. */
+ remove_breakpoints ();
+
/* Make the inferior fork, record its (and gdb's) state. */
if (lookup_minimal_symbol ("fork", NULL, NULL) != NULL)
if (!fp)
error (_("Failed to find new fork"));
fork_save_infrun_state (fp, 1);
+ insert_breakpoints ();
}
static void
oldfp = add_fork (ptid_get_pid (inferior_ptid));
fork_save_infrun_state (oldfp, 1);
+ remove_breakpoints ();
fork_load_infrun_state (newfp);
+ insert_breakpoints ();
printf_filtered (_("Switching to %s\n"),
target_pid_to_str (inferior_ptid));