int
internal_fork(struct tcb *tcp)
{
- if ((ptrace_setoptions_followfork
+ if ((ptrace_setoptions
& (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
== (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK))
return 0;
tcp->flags &= ~TCB_WAITEXECVE;
else {
/* Maybe we have post-execve SIGTRAP suppressed? */
- if (!(ptrace_setoptions_for_all & PTRACE_O_TRACEEXEC))
+ if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC))
tcp->flags |= TCB_WAITEXECVE; /* no */
}
#endif /* LINUX && TCB_WAITEXECVE */
int debug = 0, followfork = 0;
-unsigned int ptrace_setoptions_followfork = 0;
-unsigned int ptrace_setoptions_for_all = 0;
+unsigned int ptrace_setoptions = 0;
/* Which WSTOPSIG(status) value marks syscall traps? */
static unsigned int syscall_trap_sig = SIGTRAP;
int dtime = 0, xflag = 0, qflag = 0;
}
}
if (expected_grandchild && expected_grandchild == found_grandchild)
- ptrace_setoptions_followfork |= test_options;
+ ptrace_setoptions |= test_options;
return 0;
}
if (it_worked) {
syscall_trap_sig = (SIGTRAP | 0x80);
- ptrace_setoptions_for_all = test_options;
+ ptrace_setoptions |= test_options;
if (debug)
- fprintf(stderr, "ptrace_setoptions_for_all = %#x\n",
- ptrace_setoptions_for_all);
+ fprintf(stderr, "ptrace_setoptions = %#x\n",
+ ptrace_setoptions);
return;
}
fprintf(stderr,
"Test for options supported by PTRACE_SETOPTIONS "
"failed, giving up using this feature.\n");
- ptrace_setoptions_followfork = 0;
+ ptrace_setoptions = 0;
}
if (debug)
- fprintf(stderr, "ptrace_setoptions_followfork = %#x\n",
- ptrace_setoptions_followfork);
+ fprintf(stderr, "ptrace_setoptions = %#x\n",
+ ptrace_setoptions);
}
test_ptrace_setoptions_for_all();
#endif
}
}
#ifdef LINUX
- int options = ptrace_setoptions_for_all;
- if (followfork && (tcp->parent == NULL))
- options |= ptrace_setoptions_followfork;
- if (options) {
- if (debug)
- fprintf(stderr, "setting opts %x on pid %d\n", options, tcp->pid);
- if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, options) < 0) {
- if (errno != ESRCH) {
- /* Should never happen, really */
- perror_msg_and_die("PTRACE_SETOPTIONS");
+ /* If options were not set for this tracee yet */
+ if (tcp->parent == NULL) {
+ if (ptrace_setoptions) {
+ if (debug)
+ fprintf(stderr, "setting opts %x on pid %d\n", ptrace_setoptions, tcp->pid);
+ if (ptrace(PTRACE_SETOPTIONS, tcp->pid, NULL, ptrace_setoptions) < 0) {
+ if (errno != ESRCH) {
+ /* Should never happen, really */
+ perror_msg_and_die("PTRACE_SETOPTIONS");
+ }
}
}
}