summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--defs.h2
-rw-r--r--signal.c12
-rw-r--r--strace.c4
-rw-r--r--syscall.c146
-rw-r--r--util.c18
5 files changed, 91 insertions, 91 deletions
diff --git a/defs.h b/defs.h
index 76eb300..56467ff 100644
--- a/defs.h
+++ b/defs.h
@@ -607,7 +607,7 @@ extern int umoven(struct tcb *, long, int, char *);
#define umove(pid, addr, objp) \
umoven((pid), (addr), sizeof(*(objp)), (char *) (objp))
extern int umovestr(struct tcb *, long, int, char *);
-extern int upeek(struct tcb *, long, long *);
+extern int upeek(int pid, long, long *);
#if defined(SPARC) || defined(SPARC64) || defined(IA64) || defined(SH)
extern long getrval2(struct tcb *);
#endif
diff --git a/signal.c b/signal.c
index 3371ee7..06cb675 100644
--- a/signal.c
+++ b/signal.c
@@ -826,7 +826,7 @@ sys_sigreturn(struct tcb *tcp)
if (entering(tcp)) {
long usp;
struct sigcontext_struct sc;
- if (upeek(tcp, PT_GPR15, &usp) < 0)
+ if (upeek(tcp->pid, PT_GPR15, &usp) < 0)
return 0;
if (umove(tcp, usp + __SIGNAL_FRAMESIZE, &sc) < 0)
return 0;
@@ -853,7 +853,7 @@ sys_sigreturn(struct tcb *tcp)
sigset_t sigm;
/* offset of sigcontext in the kernel's sigframe structure: */
# define SIGFRAME_SC_OFFSET 0x90
- if (upeek(tcp, PT_R12, &sp) < 0)
+ if (upeek(tcp->pid, PT_R12, &sp) < 0)
return 0;
if (umove(tcp, sp + 16 + SIGFRAME_SC_OFFSET, &sc) < 0)
return 0;
@@ -888,7 +888,7 @@ sys_sigreturn(struct tcb *tcp)
long usp;
struct sigcontext sc;
sigset_t sigm;
- if (upeek(tcp, 4*PT_USP, &usp) < 0)
+ if (upeek(tcp->pid, 4*PT_USP, &usp) < 0)
return 0;
if (umove(tcp, usp, &sc) < 0)
return 0;
@@ -900,7 +900,7 @@ sys_sigreturn(struct tcb *tcp)
long fp;
struct sigcontext_struct sc;
sigset_t sigm;
- if (upeek(tcp, REG_FP, &fp) < 0)
+ if (upeek(tcp->pid, REG_FP, &fp) < 0)
return 0;
if (umove(tcp, fp, &sc) < 0)
return 0;
@@ -927,7 +927,7 @@ sys_sigreturn(struct tcb *tcp)
long sp;
struct ucontext uc;
sigset_t sigm;
- if (upeek(tcp, REG_SP, &sp) < 0)
+ if (upeek(tcp->pid, REG_SP, &sp) < 0)
return 0;
/* There are six words followed by a 128-byte siginfo. */
sp = sp + 6 * 4 + 128;
@@ -986,7 +986,7 @@ sys_sigreturn(struct tcb *tcp)
long sp;
sigset_t sigm;
/* Read r1, the stack pointer. */
- if (upeek(tcp, 1 * 4, &sp) < 0)
+ if (upeek(tcp->pid, 1 * 4, &sp) < 0)
return 0;
if (umove(tcp, sp, &sc) < 0)
return 0;
diff --git a/strace.c b/strace.c
index 743e324..67a628b 100644
--- a/strace.c
+++ b/strace.c
@@ -2270,8 +2270,8 @@ trace(void)
long pc = 0;
long psr = 0;
- upeek(tcp, PT_CR_IPSR, &psr);
- upeek(tcp, PT_CR_IIP, &pc);
+ upeek(tcp->pid, PT_CR_IPSR, &psr);
+ upeek(tcp->pid, PT_CR_IIP, &pc);
# define PSR_RI 41
pc += (psr >> PSR_RI) & 0x3;
diff --git a/syscall.c b/syscall.c
index 7c6317f..8d1f8a3 100644
--- a/syscall.c
+++ b/syscall.c
@@ -683,10 +683,10 @@ getrval2(struct tcb *tcp)
# if defined(SPARC) || defined(SPARC64)
val = sparc_regs.u_regs[U_REG_O1];
# elif defined(SH)
- if (upeek(tcp, 4*(REG_REG0+1), &val) < 0)
+ if (upeek(tcp->pid, 4*(REG_REG0+1), &val) < 0)
return -1;
# elif defined(IA64)
- if (upeek(tcp, PT_R9, &val) < 0)
+ if (upeek(tcp->pid, PT_R9, &val) < 0)
return -1;
# endif
@@ -822,7 +822,7 @@ printcall(struct tcb *tcp)
tprintf("[%08lx] ", i386_regs.eip);
#elif defined(S390) || defined(S390X)
long psw;
- if (upeek(tcp, PT_PSWADDR, &psw) < 0) {
+ if (upeek(tcp->pid, PT_PSWADDR, &psw) < 0) {
PRINTBADPC;
return;
}
@@ -844,7 +844,7 @@ printcall(struct tcb *tcp)
}
#elif defined(IA64)
long ip;
- if (upeek(tcp, PT_B0, &ip) < 0) {
+ if (upeek(tcp->pid, PT_B0, &ip) < 0) {
PRINTBADPC;
return;
}
@@ -858,14 +858,14 @@ printcall(struct tcb *tcp)
# endif
#elif defined(M68K)
long pc;
- if (upeek(tcp, 4*PT_PC, &pc) < 0) {
+ if (upeek(tcp->pid, 4*PT_PC, &pc) < 0) {
tprints("[????????] ");
return;
}
tprintf("[%08lx] ", pc);
#elif defined(ALPHA)
long pc;
- if (upeek(tcp, REG_PC, &pc) < 0) {
+ if (upeek(tcp->pid, REG_PC, &pc) < 0) {
tprints("[????????????????] ");
return;
}
@@ -876,28 +876,28 @@ printcall(struct tcb *tcp)
tprintf("[%08lx] ", sparc_regs.tpc);
#elif defined(HPPA)
long pc;
- if (upeek(tcp, PT_IAOQ0, &pc) < 0) {
+ if (upeek(tcp->pid, PT_IAOQ0, &pc) < 0) {
tprints("[????????] ");
return;
}
tprintf("[%08lx] ", pc);
#elif defined(MIPS)
long pc;
- if (upeek(tcp, REG_EPC, &pc) < 0) {
+ if (upeek(tcp->pid, REG_EPC, &pc) < 0) {
tprints("[????????] ");
return;
}
tprintf("[%08lx] ", pc);
#elif defined(SH)
long pc;
- if (upeek(tcp, 4*REG_PC, &pc) < 0) {
+ if (upeek(tcp->pid, 4*REG_PC, &pc) < 0) {
tprints("[????????] ");
return;
}
tprintf("[%08lx] ", pc);
#elif defined(SH64)
long pc;
- if (upeek(tcp, REG_PC, &pc) < 0) {
+ if (upeek(tcp->pid, REG_PC, &pc) < 0) {
tprints("[????????????????] ");
return;
}
@@ -910,21 +910,21 @@ printcall(struct tcb *tcp)
tprintf("[%08lx] ", avr32_regs.pc);
#elif defined(BFIN)
long pc;
- if (upeek(tcp, PT_PC, &pc) < 0) {
+ if (upeek(tcp->pid, PT_PC, &pc) < 0) {
PRINTBADPC;
return;
}
tprintf("[%08lx] ", pc);
#elif defined(CRISV10)
long pc;
- if (upeek(tcp, 4*PT_IRP, &pc) < 0) {
+ if (upeek(tcp->pid, 4*PT_IRP, &pc) < 0) {
PRINTBADPC;
return;
}
tprintf("[%08lx] ", pc);
#elif defined(CRISV32)
long pc;
- if (upeek(tcp, 4*PT_ERP, &pc) < 0) {
+ if (upeek(tcp->pid, 4*PT_ERP, &pc) < 0) {
PRINTBADPC;
return;
}
@@ -941,7 +941,7 @@ printcall(struct tcb *tcp)
tprintf("[%08lx] ", metag_regs.pc);
#elif defined(XTENSA)
long pc;
- if (upeek(tcp, REG_PC, &pc) < 0) {
+ if (upeek(tcp->pid, REG_PC, &pc) < 0) {
PRINTBADPC;
return;
}
@@ -1163,7 +1163,7 @@ get_scno(struct tcb *tcp)
long scno = 0;
#if defined(S390) || defined(S390X)
- if (upeek(tcp, PT_GPR2, &syscall_mode) < 0)
+ if (upeek(tcp->pid, PT_GPR2, &syscall_mode) < 0)
return -1;
if (syscall_mode != -ENOSYS) {
@@ -1185,7 +1185,7 @@ get_scno(struct tcb *tcp)
PT_GPR12, PT_GPR13, PT_GPR14, PT_GPR15
};
- if (upeek(tcp, PT_PSWADDR, &psw) < 0)
+ if (upeek(tcp->pid, PT_PSWADDR, &psw) < 0)
return -1;
errno = 0;
opcode = ptrace(PTRACE_PEEKTEXT, tcp->pid, (char *)(psw - sizeof(long)), 0);
@@ -1218,13 +1218,13 @@ get_scno(struct tcb *tcp)
tmp = 0;
offset_reg = (opcode & 0x000f0000) >> 16;
- if (offset_reg && (upeek(tcp, gpr_offset[offset_reg], &tmp) < 0))
+ if (offset_reg && (upeek(tcp->pid, gpr_offset[offset_reg], &tmp) < 0))
return -1;
svc_addr += tmp;
tmp = 0;
offset_reg = (opcode & 0x0000f000) >> 12;
- if (offset_reg && (upeek(tcp, gpr_offset[offset_reg], &tmp) < 0))
+ if (offset_reg && (upeek(tcp->pid, gpr_offset[offset_reg], &tmp) < 0))
return -1;
svc_addr += tmp;
@@ -1238,7 +1238,7 @@ get_scno(struct tcb *tcp)
# endif
tmp = 0;
offset_reg = (opcode & 0x00f00000) >> 20;
- if (offset_reg && (upeek(tcp, gpr_offset[offset_reg], &tmp) < 0))
+ if (offset_reg && (upeek(tcp->pid, gpr_offset[offset_reg], &tmp) < 0))
return -1;
scno = (scno | tmp) & 0xff;
@@ -1260,7 +1260,7 @@ get_scno(struct tcb *tcp)
#elif defined(AVR32)
scno = avr32_regs.r8;
#elif defined(BFIN)
- if (upeek(tcp, PT_ORIG_P0, &scno))
+ if (upeek(tcp->pid, PT_ORIG_P0, &scno))
return -1;
#elif defined(I386)
scno = i386_regs.orig_eax;
@@ -1357,13 +1357,13 @@ get_scno(struct tcb *tcp)
#elif defined(IA64)
# define IA64_PSR_IS ((long)1 << 34)
long psr;
- if (upeek(tcp, PT_CR_IPSR, &psr) >= 0)
+ if (upeek(tcp->pid, PT_CR_IPSR, &psr) >= 0)
ia32 = (psr & IA64_PSR_IS) != 0;
if (ia32) {
- if (upeek(tcp, PT_R1, &scno) < 0)
+ if (upeek(tcp->pid, PT_R1, &scno) < 0)
return -1;
} else {
- if (upeek(tcp, PT_R15, &scno) < 0)
+ if (upeek(tcp->pid, PT_R15, &scno) < 0)
return -1;
}
#elif defined(AARCH64)
@@ -1414,7 +1414,7 @@ get_scno(struct tcb *tcp)
scno = shuffle_scno(scno);
#elif defined(M68K)
- if (upeek(tcp, 4*PT_ORIG_D0, &scno) < 0)
+ if (upeek(tcp->pid, 4*PT_ORIG_D0, &scno) < 0)
return -1;
#elif defined(LINUX_MIPSN32)
unsigned long long regs[38];
@@ -1433,9 +1433,9 @@ get_scno(struct tcb *tcp)
}
}
#elif defined(MIPS)
- if (upeek(tcp, REG_A3, &mips_a3) < 0)
+ if (upeek(tcp->pid, REG_A3, &mips_a3) < 0)
return -1;
- if (upeek(tcp, REG_V0, &scno) < 0)
+ if (upeek(tcp->pid, REG_V0, &scno) < 0)
return -1;
if (!SCNO_IN_RANGE(scno)) {
@@ -1446,9 +1446,9 @@ get_scno(struct tcb *tcp)
}
}
#elif defined(ALPHA)
- if (upeek(tcp, REG_A3, &alpha_a3) < 0)
+ if (upeek(tcp->pid, REG_A3, &alpha_a3) < 0)
return -1;
- if (upeek(tcp, REG_R0, &scno) < 0)
+ if (upeek(tcp->pid, REG_R0, &scno) < 0)
return -1;
/*
@@ -1521,13 +1521,13 @@ get_scno(struct tcb *tcp)
memmove(&sparc_regs.u_regs[U_REG_O0], &sparc_regs.u_regs[U_REG_O1], 7*sizeof(sparc_regs.u_regs[0]));
}
#elif defined(HPPA)
- if (upeek(tcp, PT_GR20, &scno) < 0)
+ if (upeek(tcp->pid, PT_GR20, &scno) < 0)
return -1;
#elif defined(SH)
/*
* In the new syscall ABI, the system call number is in R3.
*/
- if (upeek(tcp, 4*(REG_REG0+3), &scno) < 0)
+ if (upeek(tcp->pid, 4*(REG_REG0+3), &scno) < 0)
return -1;
if (scno < 0) {
@@ -1544,11 +1544,11 @@ get_scno(struct tcb *tcp)
scno = correct_scno;
}
#elif defined(SH64)
- if (upeek(tcp, REG_SYSCALL, &scno) < 0)
+ if (upeek(tcp->pid, REG_SYSCALL, &scno) < 0)
return -1;
scno &= 0xFFFF;
#elif defined(CRISV10) || defined(CRISV32)
- if (upeek(tcp, 4*PT_R9, &scno) < 0)
+ if (upeek(tcp->pid, 4*PT_R9, &scno) < 0)
return -1;
#elif defined(TILE)
int currpers;
@@ -1566,14 +1566,14 @@ get_scno(struct tcb *tcp)
# endif
update_personality(tcp, currpers);
#elif defined(MICROBLAZE)
- if (upeek(tcp, 0, &scno) < 0)
+ if (upeek(tcp->pid, 0, &scno) < 0)
return -1;
#elif defined(OR1K)
scno = or1k_regs.gpr[11];
#elif defined(METAG)
scno = metag_regs.dx[0][1]; /* syscall number in D1Re0 (D1.0) */
#elif defined(XTENSA)
- if (upeek(tcp, SYSCALL_NR, &scno) < 0)
+ if (upeek(tcp->pid, SYSCALL_NR, &scno) < 0)
return -1;
#endif
@@ -1632,7 +1632,7 @@ syscall_fixup_on_sysenter(struct tcb *tcp)
* and stored it in syscall_mode, reuse it here
* instead of re-fetching?
*/
- if (upeek(tcp, PT_GPR2, &gpr2) < 0)
+ if (upeek(tcp->pid, PT_GPR2, &gpr2) < 0)
return -1;
if (syscall_mode != -ENOSYS)
syscall_mode = tcp->scno;
@@ -1643,7 +1643,7 @@ syscall_fixup_on_sysenter(struct tcb *tcp)
}
#elif defined(M68K)
/* TODO? Eliminate upeek's in arches below like we did in x86 */
- if (upeek(tcp, 4*PT_D0, &m68k_d0) < 0)
+ if (upeek(tcp->pid, 4*PT_D0, &m68k_d0) < 0)
return -1;
if (m68k_d0 != -ENOSYS) {
if (debug_flag)
@@ -1651,9 +1651,9 @@ syscall_fixup_on_sysenter(struct tcb *tcp)
return 0;
}
#elif defined(IA64)
- if (upeek(tcp, PT_R10, &ia64_r10) < 0)
+ if (upeek(tcp->pid, PT_R10, &ia64_r10) < 0)
return -1;
- if (upeek(tcp, PT_R8, &ia64_r8) < 0)
+ if (upeek(tcp->pid, PT_R8, &ia64_r8) < 0)
return -1;
if (ia32 && ia64_r8 != -ENOSYS) {
if (debug_flag)
@@ -1661,7 +1661,7 @@ syscall_fixup_on_sysenter(struct tcb *tcp)
return 0;
}
#elif defined(CRISV10) || defined(CRISV32)
- if (upeek(tcp, 4*PT_R10, &cris_r10) < 0)
+ if (upeek(tcp->pid, 4*PT_R10, &cris_r10) < 0)
return -1;
if (cris_r10 != -ENOSYS) {
if (debug_flag)
@@ -1669,7 +1669,7 @@ syscall_fixup_on_sysenter(struct tcb *tcp)
return 0;
}
#elif defined(MICROBLAZE)
- if (upeek(tcp, 3 * 4, &microblaze_r3) < 0)
+ if (upeek(tcp->pid, 3 * 4, &microblaze_r3) < 0)
return -1;
if (microblaze_r3 != -ENOSYS) {
if (debug_flag)
@@ -1774,11 +1774,11 @@ get_syscall_args(struct tcb *tcp)
#if defined(S390) || defined(S390X)
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, i==0 ? PT_ORIGGPR2 : PT_GPR2 + i*sizeof(long), &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, i==0 ? PT_ORIGGPR2 : PT_GPR2 + i*sizeof(long), &tcp->u_arg[i]) < 0)
return -1;
#elif defined(ALPHA)
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, REG_A0+i, &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, REG_A0+i, &tcp->u_arg[i]) < 0)
return -1;
#elif defined(IA64)
if (!ia32) {
@@ -1789,9 +1789,9 @@ get_syscall_args(struct tcb *tcp)
# define PT_RBS_END PT_AR_BSP
# endif
- if (upeek(tcp, PT_RBS_END, &rbs_end) < 0)
+ if (upeek(tcp->pid, PT_RBS_END, &rbs_end) < 0)
return -1;
- if (upeek(tcp, PT_CFM, (long *) &cfm) < 0)
+ if (upeek(tcp->pid, PT_CFM, (long *) &cfm) < 0)
return -1;
sof = (cfm >> 0) & 0x7f;
@@ -1812,7 +1812,7 @@ get_syscall_args(struct tcb *tcp)
PT_R13 /* EBP = out5 */};
for (i = 0; i < nargs; ++i) {
- if (upeek(tcp, argreg[i], &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, argreg[i], &tcp->u_arg[i]) < 0)
return -1;
/* truncate away IVE sign-extension */
tcp->u_arg[i] &= 0xffffffff;
@@ -1835,16 +1835,16 @@ get_syscall_args(struct tcb *tcp)
if (nargs > 4) {
long sp;
- if (upeek(tcp, REG_SP, &sp) < 0)
+ if (upeek(tcp->pid, REG_SP, &sp) < 0)
return -1;
for (i = 0; i < 4; ++i)
- if (upeek(tcp, REG_A0 + i, &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, REG_A0 + i, &tcp->u_arg[i]) < 0)
return -1;
umoven(tcp, sp + 16, (nargs - 4) * sizeof(tcp->u_arg[0]),
(char *)(tcp->u_arg + 4));
} else {
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, REG_A0 + i, &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, REG_A0 + i, &tcp->u_arg[i]) < 0)
return -1;
}
#elif defined(POWERPC)
@@ -1861,7 +1861,7 @@ get_syscall_args(struct tcb *tcp)
tcp->u_arg[i] = sparc_regs.u_regs[U_REG_O0 + i];
#elif defined(HPPA)
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, PT_GR26-4*i, &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, PT_GR26-4*i, &tcp->u_arg[i]) < 0)
return -1;
#elif defined(ARM) || defined(AARCH64)
# if defined(AARCH64)
@@ -1885,7 +1885,7 @@ get_syscall_args(struct tcb *tcp)
static const int argreg[MAX_ARGS] = { PT_R0, PT_R1, PT_R2, PT_R3, PT_R4, PT_R5 };
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, argreg[i], &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, argreg[i], &tcp->u_arg[i]) < 0)
return -1;
#elif defined(SH)
static const int syscall_regs[MAX_ARGS] = {
@@ -1894,7 +1894,7 @@ get_syscall_args(struct tcb *tcp)
};
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, syscall_regs[i], &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, syscall_regs[i], &tcp->u_arg[i]) < 0)
return -1;
#elif defined(SH64)
int i;
@@ -1902,7 +1902,7 @@ get_syscall_args(struct tcb *tcp)
static const int syscall_regs[MAX_ARGS] = { 2, 3, 4, 5, 6, 7 };
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, REG_GENERAL(syscall_regs[i]), &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, REG_GENERAL(syscall_regs[i]), &tcp->u_arg[i]) < 0)
return -1;
#elif defined(I386)
(void)i;
@@ -1947,7 +1947,7 @@ get_syscall_args(struct tcb *tcp)
}
#elif defined(MICROBLAZE)
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, (5 + i) * 4, &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, (5 + i) * 4, &tcp->u_arg[i]) < 0)
return -1;
#elif defined(CRISV10) || defined(CRISV32)
static const int crisregs[MAX_ARGS] = {
@@ -1956,14 +1956,14 @@ get_syscall_args(struct tcb *tcp)
};
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, crisregs[i], &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, crisregs[i], &tcp->u_arg[i]) < 0)
return -1;
#elif defined(TILE)
for (i = 0; i < nargs; ++i)
tcp->u_arg[i] = tile_regs.regs[i];
#elif defined(M68K)
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, (i < 5 ? i : i + 2)*4, &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, (i < 5 ? i : i + 2)*4, &tcp->u_arg[i]) < 0)
return -1;
#elif defined(OR1K)
(void)nargs;
@@ -1977,11 +1977,11 @@ get_syscall_args(struct tcb *tcp)
/* arg0: a6, arg1: a3, arg2: a4, arg3: a5, arg4: a8, arg5: a9 */
static const int xtensaregs[MAX_ARGS] = { 6, 3, 4, 5, 8, 9 };
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, REG_A_BASE + xtensaregs[i], &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, REG_A_BASE + xtensaregs[i], &tcp->u_arg[i]) < 0)
return -1;
#else /* Other architecture (32bits specific) */
for (i = 0; i < nargs; ++i)
- if (upeek(tcp, i*4, &tcp->u_arg[i]) < 0)
+ if (upeek(tcp->pid, i*4, &tcp->u_arg[i]) < 0)
return -1;
#endif
return 1;
@@ -2097,7 +2097,7 @@ static int
get_syscall_result(struct tcb *tcp)
{
#if defined(S390) || defined(S390X)
- if (upeek(tcp, PT_GPR2, &gpr2) < 0)
+ if (upeek(tcp->pid, PT_GPR2, &gpr2) < 0)
return -1;
#elif defined(POWERPC)
# define SO_MASK 0x10000000
@@ -2107,7 +2107,7 @@ get_syscall_result(struct tcb *tcp)
#elif defined(AVR32)
/* already done by get_regs */
#elif defined(BFIN)
- if (upeek(tcp, PT_R0, &bfin_r0) < 0)
+ if (upeek(tcp->pid, PT_R0, &bfin_r0) < 0)
return -1;
#elif defined(I386)
/* already done by get_regs */
@@ -2116,11 +2116,11 @@ get_syscall_result(struct tcb *tcp)
#elif defined(IA64)
# define IA64_PSR_IS ((long)1 << 34)
long psr;
- if (upeek(tcp, PT_CR_IPSR, &psr) >= 0)
+ if (upeek(tcp->pid, PT_CR_IPSR, &psr) >= 0)
ia32 = (psr & IA64_PSR_IS) != 0;
- if (upeek(tcp, PT_R8, &ia64_r8) < 0)
+ if (upeek(tcp->pid, PT_R8, &ia64_r8) < 0)
return -1;
- if (upeek(tcp, PT_R10, &ia64_r10) < 0)
+ if (upeek(tcp->pid, PT_R10, &ia64_r10) < 0)
return -1;
#elif defined(ARM)
/* already done by get_regs */
@@ -2133,7 +2133,7 @@ get_syscall_result(struct tcb *tcp)
*/
/*update_personality(tcp, aarch64_io.iov_len == sizeof(aarch64_regs));*/
#elif defined(M68K)
- if (upeek(tcp, 4*PT_D0, &m68k_d0) < 0)
+ if (upeek(tcp->pid, 4*PT_D0, &m68k_d0) < 0)
return -1;
#elif defined(LINUX_MIPSN32)
unsigned long long regs[38];
@@ -2143,42 +2143,42 @@ get_syscall_result(struct tcb *tcp)
mips_a3 = regs[REG_A3];
mips_r2 = regs[REG_V0];
#elif defined(MIPS)
- if (upeek(tcp, REG_A3, &mips_a3) < 0)
+ if (upeek(tcp->pid, REG_A3, &mips_a3) < 0)
return -1;
- if (upeek(tcp, REG_V0, &mips_r2) < 0)
+ if (upeek(tcp->pid, REG_V0, &mips_r2) < 0)
return -1;
#elif defined(ALPHA)
- if (upeek(tcp, REG_A3, &alpha_a3) < 0)
+ if (upeek(tcp->pid, REG_A3, &alpha_a3) < 0)
return -1;
- if (upeek(tcp, REG_R0, &alpha_r0) < 0)
+ if (upeek(tcp->pid, REG_R0, &alpha_r0) < 0)
return -1;
#elif defined(SPARC) || defined(SPARC64)
/* already done by get_regs */
#elif defined(HPPA)
- if (upeek(tcp, PT_GR28, &hppa_r28) < 0)
+ if (upeek(tcp->pid, PT_GR28, &hppa_r28) < 0)
return -1;
#elif defined(SH)
/* new syscall ABI returns result in R0 */
- if (upeek(tcp, 4*REG_REG0, (long *)&sh_r0) < 0)
+ if (upeek(tcp->pid, 4*REG_REG0, (long *)&sh_r0) < 0)
return -1;
#elif defined(SH64)
/* ABI defines result returned in r9 */
- if (upeek(tcp, REG_GENERAL(9), (long *)&sh64_r9) < 0)
+ if (upeek(tcp->pid, REG_GENERAL(9), (long *)&sh64_r9) < 0)
return -1;
#elif defined(CRISV10) || defined(CRISV32)
- if (upeek(tcp, 4*PT_R10, &cris_r10) < 0)
+ if (upeek(tcp->pid, 4*PT_R10, &cris_r10) < 0)
return -1;
#elif defined(TILE)
/* already done by get_regs */
#elif defined(MICROBLAZE)
- if (upeek(tcp, 3 * 4, &microblaze_r3) < 0)
+ if (upeek(tcp->pid, 3 * 4, &microblaze_r3) < 0)
return -1;
#elif defined(OR1K)
/* already done by get_regs */
#elif defined(METAG)
/* already done by get_regs */
#elif defined(XTENSA)
- if (upeek(tcp, REG_A_BASE + 2, &xtensa_a2) < 0)
+ if (upeek(tcp->pid, REG_A_BASE + 2, &xtensa_a2) < 0)
return -1;
#endif
return 1;
diff --git a/util.c b/util.c
index 6acdbc2..8878ccf 100644
--- a/util.c
+++ b/util.c
@@ -1056,15 +1056,15 @@ umovestr(struct tcb *tcp, long addr, int len, char *laddr)
}
int
-upeek(struct tcb *tcp, long off, long *res)
+upeek(int pid, long off, long *res)
{
long val;
errno = 0;
- val = ptrace(PTRACE_PEEKUSER, tcp->pid, (char *) off, 0);
+ val = ptrace(PTRACE_PEEKUSER, (pid_t)pid, (char *) off, 0);
if (val == -1 && errno) {
if (errno != ESRCH) {
- perror_msg("upeek: PTRACE_PEEKUSER pid:%d @0x%lx)", tcp->pid, off);
+ perror_msg("upeek: PTRACE_PEEKUSER pid:%d @0x%lx)", pid, off);
}
return -1;
}
@@ -1112,9 +1112,9 @@ arg_setup(struct tcb *tcp, arg_setup_state *state)
return 0;
}
- if (upeek(tcp, PT_AR_BSP, &bsp) < 0)
+ if (upeek(tcp->pid, PT_AR_BSP, &bsp) < 0)
return -1;
- if (upeek(tcp, PT_CFM, (long *) &cfm) < 0)
+ if (upeek(tcp->pid, PT_CFM, (long *) &cfm) < 0)
return -1;
sof = (cfm >> 0) & 0x7f;
@@ -1133,7 +1133,7 @@ get_arg0(struct tcb *tcp, arg_setup_state *state, long *valp)
int ret;
if (ia32)
- ret = upeek(tcp, PT_R11, valp);
+ ret = upeek(tcp->pid, PT_R11, valp);
else
ret = umoven(tcp,
(unsigned long) ia64_rse_skip_regs(*state, 0),
@@ -1147,7 +1147,7 @@ get_arg1(struct tcb *tcp, arg_setup_state *state, long *valp)
int ret;
if (ia32)
- ret = upeek(tcp, PT_R9, valp);
+ ret = upeek(tcp->pid, PT_R9, valp);
else
ret = umoven(tcp,
(unsigned long) ia64_rse_skip_regs(*state, 1),
@@ -1268,8 +1268,8 @@ typedef int arg_setup_state;
# define arg_setup(tcp, state) (0)
# define arg_finish_change(tcp, state) 0
-# define get_arg0(tcp, cookie, valp) (upeek((tcp), arg0_offset, (valp)))
-# define get_arg1(tcp, cookie, valp) (upeek((tcp), arg1_offset, (valp)))
+# define get_arg0(tcp, cookie, valp) (upeek((tcp)->pid, arg0_offset, (valp)))
+# define get_arg1(tcp, cookie, valp) (upeek((tcp)->pid, arg1_offset, (valp)))
static int
set_arg0(struct tcb *tcp, void *cookie, long val)