/* * Copyright (c) 1991, 1992 Paul Kranenburg * Copyright (c) 1993 Branko Lankester * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey * Copyright (c) 1996-1999 Wichert Akkerman * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation * Linux for s390 port by D.J. Barrow * * 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 upeek(struct tcb *tcp, unsigned long off, kernel_ulong_t *res) { long val; errno = 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)", tcp->pid, off); } return -1; } *res = (unsigned long) val; return 0; }