From: Denys Vlasenko Date: Sun, 18 Mar 2012 21:10:48 +0000 (+0100) Subject: Make internal_fork and internal_exec static X-Git-Tag: v4.7~62 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=146b944d4a968c2922f4220d33219ed3534f50d0;p=strace Make internal_fork and internal_exec static text data bss dec hex filename 237917 672 18980 257569 3ee21 strace 237845 672 18980 257497 3edd9 strace_new * defs.h: Remove declarations of internal_fork and internal_exec. * process.c: Remove definitions of internal_fork and internal_exec. * syscall.c: Move them here. (internal_syscall): Return void instead of int. We were always returning zero, and callers weren't checking it anyway. Signed-off-by: Denys Vlasenko --- diff --git a/defs.h b/defs.h index e9df327b..87503223 100644 --- a/defs.h +++ b/defs.h @@ -516,9 +516,6 @@ extern int is_restart_error(struct tcb *); extern int pathtrace_select(const char *); extern int pathtrace_match(struct tcb *); -extern int internal_fork(struct tcb *); -extern int internal_exec(struct tcb *); - extern const struct ioctlent *ioctl_lookup(long); extern const struct ioctlent *ioctl_next_match(const struct ioctlent *); extern int ioctl_decode(struct tcb *, long, long); diff --git a/process.c b/process.c index ac184fa7..2239d4a1 100644 --- a/process.c +++ b/process.c @@ -530,34 +530,6 @@ sys_unshare(struct tcb *tcp) return 0; } -int -internal_fork(struct tcb *tcp) -{ - if ((ptrace_setoptions - & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) - == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) - return 0; - - if (!followfork) - return 0; - - if (entering(tcp)) { - /* - * We won't see the new child if clone is called with - * CLONE_UNTRACED, so we keep the same logic with that option - * and don't trace it. - */ - if ((sysent[tcp->scno].sys_func == sys_clone) && - (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED)) - return 0; - setbpt(tcp); - } else { - if (tcp->flags & TCB_BPTSET) - clearbpt(tcp); - } - return 0; -} - int sys_fork(struct tcb *tcp) { @@ -961,21 +933,6 @@ sys_execve(struct tcb *tcp) return 0; } -#if defined(TCB_WAITEXECVE) -int -internal_exec(struct tcb *tcp) -{ - if (exiting(tcp) && syserror(tcp)) - tcp->flags &= ~TCB_WAITEXECVE; - else { - /* Maybe we have post-execve SIGTRAP suppressed? */ - if (!(ptrace_setoptions & PTRACE_O_TRACEEXEC)) - tcp->flags |= TCB_WAITEXECVE; /* no */ - } - return 0; -} -#endif - #ifndef __WNOTHREAD #define __WNOTHREAD 0x20000000 #endif diff --git a/syscall.c b/syscall.c index 272e3a0d..3f157b2a 100644 --- a/syscall.c +++ b/syscall.c @@ -1169,7 +1169,58 @@ syscall_fixup_on_sysenter(struct tcb *tcp) return 1; } -static int +static void +internal_fork(struct tcb *tcp) +{ +#if defined S390 || defined S390X || defined CRISV10 || defined CRISV32 +# define ARG_FLAGS 1 +#else +# define ARG_FLAGS 0 +#endif +#ifndef CLONE_UNTRACED +# define CLONE_UNTRACED 0x00800000 +#endif + if ((ptrace_setoptions + & (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) + == (PTRACE_O_TRACECLONE | PTRACE_O_TRACEFORK | PTRACE_O_TRACEVFORK)) + return; + + if (!followfork) + return; + + if (entering(tcp)) { + /* + * We won't see the new child if clone is called with + * CLONE_UNTRACED, so we keep the same logic with that option + * and don't trace it. + */ + if ((sysent[tcp->scno].sys_func == sys_clone) && + (tcp->u_arg[ARG_FLAGS] & CLONE_UNTRACED)) + return; + setbpt(tcp); + } else { + if (tcp->flags & TCB_BPTSET) + clearbpt(tcp); + } +} + +#if defined(TCB_WAITEXECVE) +static void +internal_exec(struct tcb *tcp) +{ + /* Maybe we have post-execve SIGTRAP suppressed? */ + if (ptrace_setoptions & PTRACE_O_TRACEEXEC) + return; /* yes, no need to do anything */ + + if (exiting(tcp) && syserror(tcp)) + /* Error in execve, no post-execve SIGTRAP expected */ + tcp->flags &= ~TCB_WAITEXECVE; + else + tcp->flags |= TCB_WAITEXECVE; +} +#endif + +static void internal_syscall(struct tcb *tcp) { /* @@ -1180,26 +1231,28 @@ internal_syscall(struct tcb *tcp) int (*func)(); if (!SCNO_IN_RANGE(tcp->scno)) - return 0; + return; func = sysent[tcp->scno].sys_func; if ( sys_fork == func || sys_vfork == func || sys_clone == func - ) - return internal_fork(tcp); + ) { + internal_fork(tcp); + return; + } #if defined(TCB_WAITEXECVE) if ( sys_execve == func # if defined(SPARC) || defined(SPARC64) || sys_execv == func # endif - ) - return internal_exec(tcp); + ) { + internal_exec(tcp); + return; + } #endif - - return 0; } static int