Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 1 | From 115fcf1daff18aa2f2e130d63704f04031878db0 Mon Sep 17 00:00:00 2001 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 2 | From: Khem Raj <raj.khem@gmail.com> |
| 3 | Date: Thu, 24 Mar 2016 15:46:14 +0000 |
| 4 | Subject: [PATCH] Use UINTPTR_MAX instead of __WORDSIZE |
| 5 | |
| 6 | Do not include sys/user.h since it conflicts with |
| 7 | pt_regs struct from kernel APIs in asm/ptrace.h |
| 8 | |
| 9 | Signed-off-by: Khem Raj <raj.khem@gmail.com> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 10 | Upstream-Status: Pending |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 11 | --- |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 12 | src/peekfd.c | 13 ++++++++----- |
| 13 | 1 file changed, 8 insertions(+), 5 deletions(-) |
| 14 | |
| 15 | diff --git a/src/peekfd.c b/src/peekfd.c |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 16 | index 5aa990a..7e8e3fc 100644 |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 17 | --- a/src/peekfd.c |
| 18 | +++ b/src/peekfd.c |
| 19 | @@ -30,8 +30,11 @@ |
| 20 | #include <asm/ptrace.h> |
| 21 | #include <byteswap.h> |
| 22 | #include <endian.h> |
| 23 | +#ifdef __GLIBC__ |
| 24 | #include <sys/user.h> |
| 25 | +#endif |
| 26 | #include <stdlib.h> |
| 27 | +#include <stdint.h> |
| 28 | #include <getopt.h> |
| 29 | #include <ctype.h> |
Brad Bishop | 1932369 | 2019-04-05 15:28:33 -0400 | [diff] [blame^] | 30 | #include <dirent.h> |
| 31 | @@ -266,11 +269,11 @@ int main(int argc, char **argv) |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 32 | if (WIFSTOPPED(status)) { |
| 33 | #ifdef PPC |
| 34 | struct pt_regs regs; |
| 35 | - regs.gpr[0] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R0, 0); |
| 36 | - regs.gpr[3] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R3, 0); |
| 37 | - regs.gpr[4] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R4, 0); |
| 38 | - regs.gpr[5] = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_R5, 0); |
| 39 | - regs.orig_gpr3 = ptrace(PTRACE_PEEKUSER, pid, __WORDSIZE/8 * PT_ORIG_R3, 0); |
| 40 | + regs.gpr[0] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R0, 0); |
| 41 | + regs.gpr[3] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R3, 0); |
| 42 | + regs.gpr[4] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R4, 0); |
| 43 | + regs.gpr[5] = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_R5, 0); |
| 44 | + regs.orig_gpr3 = ptrace(PTRACE_PEEKUSER, pid, UINTPTR_MAX/8 * PT_ORIG_R3, 0); |
| 45 | #elif defined(ARM) |
| 46 | struct pt_regs regs; |
| 47 | ptrace(PTRACE_GETREGS, pid, 0, ®s); |