]> granicus.if.org Git - strace/blob - upeek.c
xlat: add BPF_F_TEST_STATE_FREQ to bpf_prog_flags
[strace] / upeek.c
1 /*
2  * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl>
3  * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl>
4  * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com>
5  * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl>
6  * Copyright (c) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7  *                     Linux for s390 port by D.J. Barrow
8  *                    <barrow_dj@mail.yahoo.com,djbarrow@de.ibm.com>
9  * Copyright (c) 1999-2019 The strace developers.
10  * All rights reserved.
11  *
12  * SPDX-License-Identifier: LGPL-2.1-or-later
13  */
14
15 #include "defs.h"
16 #include "ptrace.h"
17
18 int
19 upeek(struct tcb *tcp, unsigned long off, kernel_ulong_t *res)
20 {
21         long val;
22
23         errno = 0;
24         val = ptrace(PTRACE_PEEKUSER, (pid_t) tcp->pid, (void *) off, 0);
25         if (val == -1 && errno) {
26                 if (errno != ESRCH)
27                         perror_func_msg("PTRACE_PEEKUSER pid:%d @0x%lx)",
28                                         tcp->pid, off);
29                 return -1;
30         }
31         *res = (unsigned long) val;
32         return 0;
33 }