Change the first argument of upeek from pid to tcp

All users were changed automatically by:

	for i in `git grep -l 'upeek(tcp->pid'`; do \
		sed -i 's/upeek(tcp->pid/upeek(tcp/g' "$i"; \
	done

* upeek.c (upeek): Change the first argument from pid_t pid to struct
tcb *tcp. Use tcp->pid instead of pid in the function's body.
* defs.h (upeek): Update declaration.
* linux/alpha/arch_getrval2.c: Pass tcp instead of tcp->pid to the
upeek calls.
* linux/alpha/arch_rt_sigframe.c: Likewise.
* linux/alpha/arch_sigreturn.c: Likewise.
* linux/alpha/get_scno.c: Likewise.
* linux/alpha/get_syscall_args.c: Likewise.
* linux/alpha/get_syscall_result.c: Likewise.
* linux/bfin/arch_rt_sigframe.c: Likewise.
* linux/bfin/get_scno.c: Likewise.
* linux/bfin/get_syscall_args.c: Likewise.
* linux/bfin/get_syscall_result.c: Likewise.
* linux/crisv10/arch_rt_sigframe.c: Likewise.
* linux/crisv10/get_scno.c: Likewise.
* linux/crisv10/get_syscall_args.c: Likewise.
* linux/crisv10/get_syscall_result.c: Likewise.
* linux/hppa/arch_rt_sigframe.c: Likewise.
* linux/hppa/get_scno.c: Likewise.
* linux/hppa/get_syscall_args.c: Likewise.
* linux/hppa/get_syscall_result.c: Likewise.
* linux/microblaze/arch_rt_sigframe.c: Likewise.
* linux/microblaze/arch_sigreturn.c: Likewise.
* linux/microblaze/get_scno.c: Likewise.
* linux/microblaze/get_syscall_args.c: Likewise.
* linux/microblaze/get_syscall_result.c: Likewise.
* linux/powerpc/getregs_old.c: Likewise.
* linux/sh/arch_getrval2.c: Likewise.
* linux/sh/arch_rt_sigframe.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/sh/get_syscall_args.c: Likewise.
* linux/sh/get_syscall_result.c: Likewise.
* linux/sh64/get_scno.c: Likewise.
* linux/sh64/get_syscall_args.c: Likewise.
* linux/sh64/get_syscall_result.c: Likewise.
* linux/xtensa/arch_rt_sigframe.c: Likewise.
* linux/xtensa/get_scno.c: Likewise.
* linux/xtensa/get_syscall_args.c: Likewise.
* linux/xtensa/get_syscall_result.c: Likewise.
* syscall.c: Likewise.
This commit is contained in:
Eugene Syromiatnikov 2017-12-25 23:52:48 +01:00 committed by Eugene Syromyatnikov
parent 26d340fe9c
commit 20ac169d7b
39 changed files with 48 additions and 47 deletions

2
defs.h
View File

@ -450,7 +450,7 @@ umoven_or_printaddr_ignore_syserror(struct tcb *, kernel_ulong_t addr,
extern int
umovestr(struct tcb *, kernel_ulong_t addr, unsigned int len, char *laddr);
extern int upeek(int pid, unsigned long, kernel_ulong_t *);
extern int upeek(struct tcb *tcp, unsigned long, kernel_ulong_t *);
extern int upoke(struct tcb *tcp, unsigned long, kernel_ulong_t);
extern bool

View File

@ -2,7 +2,7 @@ long
getrval2(struct tcb *tcp)
{
unsigned long r20;
if (upeek(tcp->pid, 20, &r20) < 0)
if (upeek(tcp, 20, &r20) < 0)
return -1;
return r20;
}

View File

@ -29,5 +29,5 @@ FUNC_GET_RT_SIGFRAME_ADDR
{
unsigned long addr;
return upeek(tcp->pid, REG_FP, &addr) ? 0 : addr;
return upeek(tcp, REG_FP, &addr) ? 0 : addr;
}

View File

@ -3,7 +3,7 @@ arch_sigreturn(struct tcb *tcp)
{
unsigned long addr;
if (upeek(tcp->pid, REG_FP, &addr) < 0)
if (upeek(tcp, REG_FP, &addr) < 0)
return;
addr += offsetof(struct sigcontext, sc_mask);

View File

@ -4,9 +4,9 @@ arch_get_scno(struct tcb *tcp)
{
kernel_ulong_t scno = 0;
if (upeek(tcp->pid, REG_A3, &alpha_a3) < 0)
if (upeek(tcp, REG_A3, &alpha_a3) < 0)
return -1;
if (upeek(tcp->pid, REG_R0, &scno) < 0)
if (upeek(tcp, REG_R0, &scno) < 0)
return -1;
/*

View File

@ -5,7 +5,7 @@ get_syscall_args(struct tcb *tcp)
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, REG_A0+i, &tcp->u_arg[i]) < 0)
if (upeek(tcp, REG_A0+i, &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,6 +1,6 @@
static int
get_syscall_result_regs(struct tcb *tcp)
{
return (upeek(tcp->pid, REG_A3, &alpha_a3) < 0 ||
upeek(tcp->pid, REG_R0, &alpha_r0) < 0) ? -1 : 0;
return (upeek(tcp, REG_A3, &alpha_a3) < 0 ||
upeek(tcp, REG_R0, &alpha_r0) < 0) ? -1 : 0;
}

View File

@ -29,5 +29,5 @@ FUNC_GET_RT_SIGFRAME_ADDR
{
unsigned long addr;
return upeek(tcp->pid, PT_USP, &addr) ? 0 : addr;
return upeek(tcp, PT_USP, &addr) ? 0 : addr;
}

View File

@ -2,5 +2,5 @@
static int
arch_get_scno(struct tcb *tcp)
{
return upeek(tcp->pid, PT_ORIG_P0, &tcp->scno) < 0 ? -1 : 1;
return upeek(tcp, PT_ORIG_P0, &tcp->scno) < 0 ? -1 : 1;
}

View File

@ -8,7 +8,7 @@ get_syscall_args(struct tcb *tcp)
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, argreg[i], &tcp->u_arg[i]) < 0)
if (upeek(tcp, argreg[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,5 +1,5 @@
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, PT_R0, &bfin_r0) < 0 ? -1 : 0;
return upeek(tcp, PT_R0, &bfin_r0) < 0 ? -1 : 0;
}

View File

@ -29,5 +29,5 @@ FUNC_GET_RT_SIGFRAME_ADDR
{
unsigned long addr;
return upeek(tcp->pid, 4 * PT_USP, &addr) ? 0 : addr;
return upeek(tcp, 4 * PT_USP, &addr) ? 0 : addr;
}

View File

@ -2,5 +2,5 @@
static int
arch_get_scno(struct tcb *tcp)
{
return upeek(tcp->pid, 4 * PT_R9, &tcp->scno) < 0 ? -1 : 1;
return upeek(tcp, 4 * PT_R9, &tcp->scno) < 0 ? -1 : 1;
}

View File

@ -9,7 +9,7 @@ get_syscall_args(struct tcb *tcp)
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, crisregs[i], &tcp->u_arg[i]) < 0)
if (upeek(tcp, crisregs[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,5 +1,5 @@
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, 4 * PT_R10, &cris_r10) < 0 ? -1 : 0;
return upeek(tcp, 4 * PT_R10, &cris_r10) < 0 ? -1 : 0;
}

View File

@ -36,6 +36,6 @@ FUNC_GET_RT_SIGFRAME_ADDR
{
unsigned long addr;
return upeek(tcp->pid, 4 * 30, &addr)
return upeek(tcp, 4 * 30, &addr)
? 0 : (addr & ~1UL) - RT_SIGFRAME_SIZE;
}

View File

@ -2,5 +2,5 @@
static int
arch_get_scno(struct tcb *tcp)
{
return upeek(tcp->pid, PT_GR20, &tcp->scno) < 0 ? -1 : 1;
return upeek(tcp, PT_GR20, &tcp->scno) < 0 ? -1 : 1;
}

View File

@ -5,7 +5,7 @@ get_syscall_args(struct tcb *tcp)
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, PT_GR26-4*i, &tcp->u_arg[i]) < 0)
if (upeek(tcp, PT_GR26-4*i, &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,5 +1,5 @@
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, PT_GR28, &hppa_r28) < 0 ? -1 : 0;
return upeek(tcp, PT_GR28, &hppa_r28) < 0 ? -1 : 0;
}

View File

@ -29,5 +29,5 @@ FUNC_GET_RT_SIGFRAME_ADDR
{
unsigned long addr;
return upeek(tcp->pid, 4 * 1, &addr) ? 0 : addr;
return upeek(tcp, 4 * 1, &addr) ? 0 : addr;
}

View File

@ -6,7 +6,7 @@ arch_sigreturn(struct tcb *tcp)
unsigned long addr;
/* Read r1, the stack pointer. */
if (upeek(tcp->pid, 1 * 4, &addr) < 0)
if (upeek(tcp, 1 * 4, &addr) < 0)
return;
addr += offsetof(struct sigcontext, oldmask);

View File

@ -2,5 +2,5 @@
static int
arch_get_scno(struct tcb *tcp)
{
return upeek(tcp->pid, 0, &tcp->scno) < 0 ? -1 : 1;
return upeek(tcp, 0, &tcp->scno) < 0 ? -1 : 1;
}

View File

@ -5,7 +5,7 @@ get_syscall_args(struct tcb *tcp)
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, (5 + i) * 4, &tcp->u_arg[i]) < 0)
if (upeek(tcp, (5 + i) * 4, &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,5 +1,5 @@
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, 3 * 4, &microblaze_r3) < 0 ? -1 : 0;
return upeek(tcp, 3 * 4, &microblaze_r3) < 0 ? -1 : 0;
}

View File

@ -9,23 +9,23 @@ getregs_old(struct tcb *tcp)
long r;
if (iflag) {
r = upeek(tcp->pid, sizeof(long) * PT_NIP, &ppc_regs.nip);
r = upeek(tcp, sizeof(long) * PT_NIP, &ppc_regs.nip);
if (r)
goto out;
}
#ifdef POWERPC64 /* else we never use it */
r = upeek(tcp->pid, sizeof(long) * PT_MSR, &ppc_regs.msr);
r = upeek(tcp, sizeof(long) * PT_MSR, &ppc_regs.msr);
if (r)
goto out;
#endif
r = upeek(tcp->pid, sizeof(long) * PT_CCR, &ppc_regs.ccr);
r = upeek(tcp, sizeof(long) * PT_CCR, &ppc_regs.ccr);
if (r)
goto out;
r = upeek(tcp->pid, sizeof(long) * PT_ORIG_R3, &ppc_regs.orig_gpr3);
r = upeek(tcp, sizeof(long) * PT_ORIG_R3, &ppc_regs.orig_gpr3);
if (r)
goto out;
for (i = 0; i <= 8; i++) {
r = upeek(tcp->pid, sizeof(long) * (PT_R0 + i),
r = upeek(tcp, sizeof(long) * (PT_R0 + i),
&ppc_regs.gpr[i]);
if (r)
goto out;

View File

@ -2,7 +2,7 @@ long
getrval2(struct tcb *tcp)
{
unsigned long val;
if (upeek(tcp->pid, 4*(REG_REG0+1), &val) < 0)
if (upeek(tcp, 4*(REG_REG0+1), &val) < 0)
return -1;
return val;
}

View File

@ -29,5 +29,5 @@ FUNC_GET_RT_SIGFRAME_ADDR
{
unsigned long addr;
return upeek(tcp->pid, sizeof(long) * 15, &addr) ? 0 : addr;
return upeek(tcp, sizeof(long) * 15, &addr) ? 0 : addr;
}

View File

@ -7,7 +7,7 @@ arch_get_scno(struct tcb *tcp)
/*
* In the new syscall ABI, the system call number is in R3.
*/
if (upeek(tcp->pid, 4*(REG_REG0+3), &scno) < 0)
if (upeek(tcp, 4*(REG_REG0+3), &scno) < 0)
return -1;
if ((long) scno < 0) {

View File

@ -13,7 +13,7 @@ get_syscall_args(struct tcb *tcp)
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, syscall_regs[i], &tcp->u_arg[i]) < 0)
if (upeek(tcp, syscall_regs[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -2,5 +2,5 @@ static int
get_syscall_result_regs(struct tcb *tcp)
{
/* new syscall ABI returns result in R0 */
return upeek(tcp->pid, 4 * REG_REG0, &sh_r0) < 0 ? -1 : 0;
return upeek(tcp, 4 * REG_REG0, &sh_r0) < 0 ? -1 : 0;
}

View File

@ -2,7 +2,7 @@
static int
arch_get_scno(struct tcb *tcp)
{
if (upeek(tcp->pid, REG_SYSCALL, &tcp->scno) < 0)
if (upeek(tcp, REG_SYSCALL, &tcp->scno) < 0)
return -1;
tcp->scno &= 0xffff;
return 1;

View File

@ -7,7 +7,7 @@ get_syscall_args(struct tcb *tcp)
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, REG_GENERAL(syscall_regs[i]),
if (upeek(tcp, REG_GENERAL(syscall_regs[i]),
&tcp->u_arg[i]) < 0)
return -1;
return 1;

View File

@ -2,5 +2,5 @@ static int
get_syscall_result_regs(struct tcb *tcp)
{
/* ABI defines result returned in r9 */
return upeek(tcp->pid, REG_GENERAL(9), &sh64_r9) < 0 ? -1 : 0;
return upeek(tcp, REG_GENERAL(9), &sh64_r9) < 0 ? -1 : 0;
}

View File

@ -29,5 +29,5 @@ FUNC_GET_RT_SIGFRAME_ADDR
{
unsigned long addr;
return upeek(tcp->pid, REG_A_BASE + 3, &addr) ? 0 : addr;
return upeek(tcp, REG_A_BASE + 3, &addr) ? 0 : addr;
}

View File

@ -2,5 +2,5 @@
static int
arch_get_scno(struct tcb *tcp)
{
return upeek(tcp->pid, SYSCALL_NR, &tcp->scno) < 0 ? -1 : 1;
return upeek(tcp, SYSCALL_NR, &tcp->scno) < 0 ? -1 : 1;
}

View File

@ -14,7 +14,7 @@ get_syscall_args(struct tcb *tcp)
unsigned int i;
for (i = 0; i < tcp->s_ent->nargs; ++i)
if (upeek(tcp->pid, xtensaregs[i], &tcp->u_arg[i]) < 0)
if (upeek(tcp, xtensaregs[i], &tcp->u_arg[i]) < 0)
return -1;
return 1;
}

View File

@ -1,5 +1,5 @@
static int
get_syscall_result_regs(struct tcb *tcp)
{
return upeek(tcp->pid, REG_A_BASE + 2, &xtensa_a2) < 0 ? -1 : 0;
return upeek(tcp, REG_A_BASE + 2, &xtensa_a2) < 0 ? -1 : 0;
}

View File

@ -1009,7 +1009,7 @@ print_pc(struct tcb *tcp)
#elif defined ARCH_PC_PEEK_ADDR
kernel_ulong_t pc;
# define ARCH_PC_REG pc
# define ARCH_GET_PC upeek(tcp->pid, ARCH_PC_PEEK_ADDR, &pc)
# define ARCH_GET_PC upeek(tcp, ARCH_PC_PEEK_ADDR, &pc)
#else
# error Neither ARCH_PC_REG nor ARCH_PC_PEEK_ADDR is defined
#endif

View File

@ -36,15 +36,16 @@
#include "ptrace.h"
int
upeek(int pid, unsigned long off, kernel_ulong_t *res)
upeek(struct tcb *tcp, unsigned long off, kernel_ulong_t *res)
{
long val;
errno = 0;
val = ptrace(PTRACE_PEEKUSER, (pid_t) pid, (void *) off, 0);
val = ptrace(PTRACE_PEEKUSER, (pid_t) tcp->pid, (void *) off, 0);
if (val == -1 && errno) {
if (errno != ESRCH) {
perror_msg("upeek: PTRACE_PEEKUSER pid:%d @0x%lx)", pid, off);
perror_msg("upeek: PTRACE_PEEKUSER pid:%d @0x%lx)",
tcp->pid, off);
}
return -1;
}