From: Denys Vlasenko Date: Tue, 20 Mar 2012 15:26:25 +0000 (+0100) Subject: Make ptrace_restart() static. No code changes X-Git-Tag: v4.7~53 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=852f98a3824f6b8359df744af5772306410341ab;p=strace Make ptrace_restart() static. No code changes * defs.h: Remove ptrace_restart() declaration. * strace.c (ptrace_restart): Move its definition here. * util.c (ptrace_restart): Remove its definition. Signed-off-by: Denys Vlasenko --- diff --git a/defs.h b/defs.h index d327128a..7179c320 100644 --- a/defs.h +++ b/defs.h @@ -459,7 +459,6 @@ extern const char *xlookup(const struct xlat *, int); extern void set_sortby(const char *); extern void set_overhead(int); extern void qualify(const char *); -extern int ptrace_restart(int request, struct tcb *tcp, int sig); extern int trace_syscall(struct tcb *); extern void count_syscall(struct tcb *, struct timeval *); extern void printxval(const struct xlat *, int, const char *); diff --git a/strace.c b/strace.c index 5f590cdd..04efd1e6 100644 --- a/strace.c +++ b/strace.c @@ -336,6 +336,39 @@ ptrace_attach_or_seize(int pid) # define ptrace_attach_or_seize(pid) ptrace(PTRACE_ATTACH, (pid), 0, 0) #endif +/* + * Used when we want to unblock stopped traced process. + * Should be only used with PTRACE_CONT, PTRACE_DETACH and PTRACE_SYSCALL. + * Returns 0 on success or if error was ESRCH + * (presumably process was killed while we talk to it). + * Otherwise prints error message and returns -1. + */ +static int +ptrace_restart(int op, struct tcb *tcp, int sig) +{ + int err; + const char *msg; + + errno = 0; + ptrace(op, tcp->pid, (void *) 0, (long) sig); + err = errno; + if (!err || err == ESRCH) + return 0; + + tcp->ptrace_errno = err; + msg = "SYSCALL"; + if (op == PTRACE_CONT) + msg = "CONT"; + if (op == PTRACE_DETACH) + msg = "DETACH"; +#ifdef PTRACE_LISTEN + if (op == PTRACE_LISTEN) + msg = "LISTEN"; +#endif + perror_msg("ptrace(PTRACE_%s,pid:%d,sig:%d)", msg, tcp->pid, sig); + return -1; +} + static void set_cloexec_flag(int fd) { diff --git a/util.c b/util.c index 9a777051..e57f46ae 100644 --- a/util.c +++ b/util.c @@ -160,39 +160,6 @@ stpcpy(char *dst, const char *src) } #endif -/* - * Used when we want to unblock stopped traced process. - * Should be only used with PTRACE_CONT, PTRACE_DETACH and PTRACE_SYSCALL. - * Returns 0 on success or if error was ESRCH - * (presumably process was killed while we talk to it). - * Otherwise prints error message and returns -1. - */ -int -ptrace_restart(int op, struct tcb *tcp, int sig) -{ - int err; - const char *msg; - - errno = 0; - ptrace(op, tcp->pid, (void *) 0, (long) sig); - err = errno; - if (!err || err == ESRCH) - return 0; - - tcp->ptrace_errno = err; - msg = "SYSCALL"; - if (op == PTRACE_CONT) - msg = "CONT"; - if (op == PTRACE_DETACH) - msg = "DETACH"; -#ifdef PTRACE_LISTEN - if (op == PTRACE_LISTEN) - msg = "LISTEN"; -#endif - perror_msg("ptrace(PTRACE_%s,pid:%d,sig:%d)", msg, tcp->pid, sig); - return -1; -} - /* * Print entry in struct xlat table, if there. */