Mirror of strace – the linux syscall tracer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

upeek.c 970B

123456789101112131415161718192021222324252627282930313233
  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. #include "defs.h"
  15. #include "ptrace.h"
  16. int
  17. upeek(struct tcb *tcp, unsigned long off, kernel_ulong_t *res)
  18. {
  19. long val;
  20. errno = 0;
  21. val = ptrace(PTRACE_PEEKUSER, (pid_t) tcp->pid, (void *) off, 0);
  22. if (val == -1 && errno) {
  23. if (errno != ESRCH)
  24. perror_func_msg("PTRACE_PEEKUSER pid:%d @0x%lx)",
  25. tcp->pid, off);
  26. return -1;
  27. }
  28. *res = (unsigned long) val;
  29. return 0;
  30. }