Otherwise it makes little sense on most arches to try to get syscall
number.
* defs.h (TCB_GRABBED): New tcb flag.
* strace.c (attach_tcb): Set TCB_GRABBED for the tcb.
(startup_tcb): Call get_scno() only if process is grabbed and its
registers may contain syscall number information.
Reported-by: Dmitry V. Levin <ldv@altlinux.org>
Closes: https://github.com/strace/strace/issues/22
#define TCB_TAMPERED 0x40 /* A syscall has been tampered with */
#define TCB_HIDE_LOG 0x80 /* We should hide everything (until execve) */
#define TCB_SKIP_DETACH_ON_FIRST_EXEC 0x100 /* -b execve should skip detach on first execve */
+#define TCB_GRABBED 0x200 /* We grab the process and can catch it
+ * in the middle of a syscall */
/* qualifier flags */
#define QUAL_TRACE 0x001 /* this system call should be traced */
return;
}
- tcp->flags |= TCB_ATTACHED | TCB_STARTUP | post_attach_sigstop;
+ tcp->flags |= TCB_ATTACHED | TCB_GRABBED | TCB_STARTUP |
+ post_attach_sigstop;
newoutf(tcp);
debug_msg("attach to pid %d (main) succeeded", tcp->pid);
debug_msg("attach to pid %d succeeded", tid);
struct tcb *tid_tcp = alloctcb(tid);
- tid_tcp->flags |= TCB_ATTACHED | TCB_STARTUP |
- post_attach_sigstop;
+ tid_tcp->flags |= TCB_ATTACHED | TCB_GRABBED |
+ TCB_STARTUP | post_attach_sigstop;
newoutf(tid_tcp);
}
}
}
- if (get_scno(tcp) == 1)
+ if ((tcp->flags & TCB_GRABBED) && (get_scno(tcp) == 1))
tcp->s_prev_ent = tcp->s_ent;
}