From: Eugene Syromiatnikov Date: Mon, 25 Dec 2017 22:49:40 +0000 (+0100) Subject: Change argument of getregs_old from pid to tcp X-Git-Tag: v4.21~226 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=26d340fe9c47fc4b58311b49d519f52d80a18275;p=strace Change argument of getregs_old from pid to tcp * linux/powerpc/getregs_old.c (getregs_old): Change the first argument from pid_t pid to struct tcb *tcp. Replace all instances of pid with tcp->pid. * linux/x86_64/getregs_old.c (getregs_old): Likewise. * linux/x86_64/getregs_old.h (getregs_old): Update declaration. * syscall.c (get_regs) [HAVE_GETREGS_OLD]: Pass tcp to the getregs_old call instead of tcp->pid. --- diff --git a/linux/powerpc/getregs_old.c b/linux/powerpc/getregs_old.c index 1730f033..61c41898 100644 --- a/linux/powerpc/getregs_old.c +++ b/linux/powerpc/getregs_old.c @@ -3,29 +3,29 @@ * we provide a slow fallback for old kernels. */ static int -getregs_old(pid_t pid) +getregs_old(struct tcb *tcp) { int i; long r; if (iflag) { - r = upeek(pid, sizeof(long) * PT_NIP, &ppc_regs.nip); + r = upeek(tcp->pid, sizeof(long) * PT_NIP, &ppc_regs.nip); if (r) goto out; } #ifdef POWERPC64 /* else we never use it */ - r = upeek(pid, sizeof(long) * PT_MSR, &ppc_regs.msr); + r = upeek(tcp->pid, sizeof(long) * PT_MSR, &ppc_regs.msr); if (r) goto out; #endif - r = upeek(pid, sizeof(long) * PT_CCR, &ppc_regs.ccr); + r = upeek(tcp->pid, sizeof(long) * PT_CCR, &ppc_regs.ccr); if (r) goto out; - r = upeek(pid, sizeof(long) * PT_ORIG_R3, &ppc_regs.orig_gpr3); + r = upeek(tcp->pid, sizeof(long) * PT_ORIG_R3, &ppc_regs.orig_gpr3); if (r) goto out; for (i = 0; i <= 8; i++) { - r = upeek(pid, sizeof(long) * (PT_R0 + i), + r = upeek(tcp->pid, sizeof(long) * (PT_R0 + i), &ppc_regs.gpr[i]); if (r) goto out; diff --git a/linux/x86_64/getregs_old.c b/linux/x86_64/getregs_old.c index 9f7c2489..0aa05c4e 100644 --- a/linux/x86_64/getregs_old.c +++ b/linux/x86_64/getregs_old.c @@ -31,10 +31,10 @@ * a PTRACE_GETREGS based fallback is provided for old kernels. */ static int -getregs_old(pid_t pid) +getregs_old(struct tcb *tcp) { /* Use old method, with unreliable heuristical detection of 32-bitness. */ - long r = ptrace(PTRACE_GETREGS, pid, NULL, &x86_64_regs); + long r = ptrace(PTRACE_GETREGS, tcp->pid, NULL, &x86_64_regs); if (r) return r; diff --git a/linux/x86_64/getregs_old.h b/linux/x86_64/getregs_old.h index 80303016..f13fe24f 100644 --- a/linux/x86_64/getregs_old.h +++ b/linux/x86_64/getregs_old.h @@ -1,2 +1,2 @@ #define HAVE_GETREGS_OLD -static int getregs_old(pid_t); +static int getregs_old(struct tcb *); diff --git a/syscall.c b/syscall.c index dfeaec17..b0a4fe82 100644 --- a/syscall.c +++ b/syscall.c @@ -1136,7 +1136,7 @@ get_regs(struct tcb *const tcp) return get_regs_error; use_getregs_old = 1; } - return get_regs_error = getregs_old(tcp->pid); + return get_regs_error = getregs_old(tcp); # else /* !HAVE_GETREGS_OLD */ /* Assume that PTRACE_GETREGSET/PTRACE_GETREGS works. */ return get_regs_error = ptrace_getregset_or_getregs(tcp->pid);