strace/upeek.c

35 lines
980 B
C
Raw Normal View History

/*
* Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
* Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
* Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
* Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
* Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
* Linux for s390 port by D.J. Barrow
* <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
2018-12-25 02:46:43 +03:00
* Copyright (c) 1999-2018 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
*/
#include "defs.h"
#include "ptrace.h"
int
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.
2017-12-26 01:52:48 +03:00
upeek(struct tcb *tcp, unsigned long off, kernel_ulong_t *res)
{
long val;
errno = 0;
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.
2017-12-26 01:52:48 +03:00
val = ptrace(PTRACE_PEEKUSER, (pid_t) tcp->pid, (void *) off, 0);
if (val == -1 && errno) {
if (errno != ESRCH) {
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.
2017-12-26 01:52:48 +03:00
perror_msg("upeek: PTRACE_PEEKUSER pid:%d @0x%lx)",
tcp->pid, off);
}
return -1;
}
upeek, upoke: change argument types from long to unsigned long * defs.h (upeek, upoke): Change offset argument type from long to unsigned long. Change res argument type from long to kernel_ureg_t. * upeek.c (upeek): Likewise. * upoke.c (upoke.c): Likewise. * syscall.c (print_pc) [ARCH_PC_PEEK_ADDR]: Change pc type from long to kernel_ureg_t. * linux/aarch64/arch_regs.c (arm_sp_ptr): Remove redundant cast. * linux/metag/get_syscall_args.c (get_syscall_args): Likewise. * linux/sh/get_syscall_result.c (get_syscall_result_regs): Likewise. * linux/sh64/get_syscall_result.c (get_syscall_result_regs): Likewise. * linux/powerpc/getregs_old.c (getregs_old): Remove redundant casts. * linux/alpha/arch_getrval2.c (getrval2): Change r20 type from long to unsigned long. * linux/alpha/arch_regs.c (alpha_r0, alpha_a3): Change type from long to unsigned long. * linux/bfin/arch_regs.c (bfin_r0): Likewise. * linux/crisv10/arch_regs.c (cris_r10): Likewise. * linux/hppa/arch_regs.c (hppa_r28): Likewise. * linux/ia64/arch_regs.c (IA64_PSR_IS): Likewise. * linux/microblaze/arch_regs.c (microblaze_r3): Likewise. * linux/sh/arch_regs.c (sh_r0): Likewise. * linux/sh64/arch_regs.c (sh64_r9): Likewise. * linux/xtensa/arch_regs.c (xtensa_a2): Likewise. * linux/alpha/arch_sigreturn.c (arch_sigreturn): Change addr type from long to unsigned long. * linux/microblaze/arch_sigreturn.c (arch_sigreturn): Likewise. * linux/alpha/get_scno.c (arch_get_scno): Update for the change of signedness. * linux/arc/get_syscall_args.c (get_syscall_args): Change arc_args type from pointer to long to pointer to unsigned long. * linux/arm/arch_regs.c (arm_sp_ptr): Change type from pointer to long to pointer to unsigned long. * linux/arm/arch_regs.h (arm_sp_ptr): Likewise. * linux/i386/arch_regs.c (i386_esp_ptr): Likewise. * linux/i386/arch_regs.h (i386_esp_ptr): Likewise. * linux/m68k/arch_regs.c (m68k_usp_ptr): Likewise. * linux/m68k/arch_regs.h (m68k_usp_ptr): Likewise. * linux/ia64/get_syscall_args.c (get_syscall_args): Use umove instead of umoven. * linux/sh/arch_getrval2.c (getrval2): Change val type from long to unsigned long.
2016-12-25 15:53:14 +03:00
*res = (unsigned long) val;
return 0;
}