/* Low-level child interface to ttrace.
- Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
- Free Software Foundation, Inc.
+ Copyright (C) 2004-2013 Free Software Foundation, Inc.
This file is part of GDB.
#include "inf-child.h"
#include "inf-ttrace.h"
+#include "common/filestuff.h"
\f
static pid_t inf_ttrace_vfork_ppid = -1;
static int
-inf_ttrace_follow_fork (struct target_ops *ops, int follow_child)
+inf_ttrace_follow_fork (struct target_ops *ops, int follow_child,
+ int detach_fork)
{
pid_t pid, fpid;
lwpid_t lwpid, flwpid;
inf->pspace = parent_inf->pspace;
inf->aspace = parent_inf->aspace;
copy_terminal_info (inf, parent_inf);
- detach_breakpoints (pid);
+ detach_breakpoints (ptid_build (pid, lwpid, 0));
target_terminal_ours ();
fprintf_unfiltered (gdb_stdlog,
else
{
inferior_ptid = ptid_build (pid, lwpid, 0);
- detach_breakpoints (fpid);
+ /* Detach any remaining breakpoints in the child. In the case
+ of fork events, we do not need to do this, because breakpoints
+ should have already been removed earlier. */
+ if (tts.tts_event == TTEVT_VFORK)
+ detach_breakpoints (ptid_build (fpid, flwpid, 0));
target_terminal_ours ();
fprintf_unfiltered (gdb_stdlog,
close (inf_ttrace_pfd1[1]);
close (inf_ttrace_pfd2[0]);
close (inf_ttrace_pfd2[1]);
+
+ unmark_fd_no_cloexec (inf_ttrace_pfd1[0]);
+ unmark_fd_no_cloexec (inf_ttrace_pfd1[1]);
+ unmark_fd_no_cloexec (inf_ttrace_pfd2[0]);
+ unmark_fd_no_cloexec (inf_ttrace_pfd2[1]);
}
static void
close (inf_ttrace_pfd2[0]);
perror_with_name (("pipe"));
}
+
+ mark_fd_no_cloexec (inf_ttrace_pfd1[0]);
+ mark_fd_no_cloexec (inf_ttrace_pfd1[1]);
+ mark_fd_no_cloexec (inf_ttrace_pfd2[0]);
+ mark_fd_no_cloexec (inf_ttrace_pfd2[1]);
}
/* Prepare to be traced. */
static void
inf_ttrace_resume (struct target_ops *ops,
- ptid_t ptid, int step, enum target_signal signal)
+ ptid_t ptid, int step, enum gdb_signal signal)
{
int resume_all;
ttreq_t request = step ? TT_LWP_SINGLE : TT_LWP_CONTINUE;
- int sig = target_signal_to_host (signal);
+ int sig = gdb_signal_to_host (signal);
struct thread_info *info;
/* A specific PTID means `step only this process id'. */
case TTEVT_BPT_SSTEP:
/* Make it look like a breakpoint. */
ourstatus->kind = TARGET_WAITKIND_STOPPED;
- ourstatus->value.sig = TARGET_SIGNAL_TRAP;
+ ourstatus->value.sig = GDB_SIGNAL_TRAP;
break;
#endif
case TTEVT_SIGNAL:
ourstatus->kind = TARGET_WAITKIND_STOPPED;
ourstatus->value.sig =
- target_signal_from_host (tts.tts_u.tts_signal.tts_signo);
+ gdb_signal_from_host (tts.tts_u.tts_signal.tts_signo);
break;
case TTEVT_SYSCALL_ENTRY:
\f
/* Prevent warning from -Wmissing-prototypes. */
-void _initialize_hppa_hpux_nat (void);
+void _initialize_inf_ttrace (void);
void
_initialize_inf_ttrace (void)