| @@ -1,68 +1,67 @@ | | | @@ -1,68 +1,67 @@ |
1 | $NetBSD: patch-am,v 1.3 2015/03/19 08:34:53 dholland Exp $ | | 1 | $NetBSD: patch-am,v 1.4 2017/06/23 22:13:22 kamil Exp $ |
2 | | | 2 | |
3 | - Use standard headers. | | 3 | - Use standard headers. |
4 | - Support NetBSD. | | 4 | - Support NetBSD. |
5 | - LP64 fix. | | 5 | - LP64 fix. |
6 | | | 6 | |
7 | --- src/pcat/pcat.c.orig 2001-09-25 17:22:20.000000000 +0000 | | 7 | --- src/pcat/pcat.c.orig 2001-09-25 17:22:20.000000000 +0000 |
8 | +++ src/pcat/pcat.c | | 8 | +++ src/pcat/pcat.c |
9 | @@ -75,6 +75,7 @@ | | 9 | @@ -75,6 +75,7 @@ |
10 | | | 10 | |
11 | #include <stdio.h> | | 11 | #include <stdio.h> |
12 | #include <stdlib.h> | | 12 | #include <stdlib.h> |
13 | +#include <string.h> | | 13 | +#include <string.h> |
14 | #include <unistd.h> | | 14 | #include <unistd.h> |
15 | #include <fcntl.h> | | 15 | #include <fcntl.h> |
16 | #include <signal.h> | | 16 | #include <signal.h> |
17 | @@ -177,6 +178,24 @@ | | 17 | @@ -177,6 +178,23 @@ |
18 | #endif | | 18 | #endif |
19 | | | 19 | |
20 | /* | | 20 | /* |
21 | + * Based on the OpenBSD code above. | | 21 | + * Based on the OpenBSD code above. |
22 | + */ | | 22 | + */ |
23 | +#if defined(NETBSD1) || defined(NETBSD2) | | 23 | +#if defined(NETBSD1) || defined(NETBSD2) |
24 | +#define SUPPORTED | | 24 | +#define SUPPORTED |
25 | +#include <sys/param.h> | | 25 | +#include <sys/param.h> |
26 | +#include <sys/user.h> | | | |
27 | +#include <sys/sysctl.h> | | 26 | +#include <sys/sysctl.h> |
28 | +#include <kvm.h> | | 27 | +#include <kvm.h> |
29 | +#include <stddef.h> | | 28 | +#include <stddef.h> |
30 | +#define HAVE_PTRACE_MEM | | 29 | +#define HAVE_PTRACE_MEM |
31 | +#define PTRACE_ATTACH PT_ATTACH | | 30 | +#define PTRACE_ATTACH PT_ATTACH |
32 | +#define PTRACE_DETACH PT_DETACH | | 31 | +#define PTRACE_DETACH PT_DETACH |
33 | +#define PTRACE_PEEKDATA PT_READ_D | | 32 | +#define PTRACE_PEEKDATA PT_READ_D |
34 | +#define HAVE_BROKEN_CTOB | | 33 | +#define HAVE_BROKEN_CTOB |
35 | +#define PTRACE_ARG3_T caddr_t | | 34 | +#define PTRACE_ARG3_T caddr_t |
36 | +#endif | | 35 | +#endif |
37 | + | | 36 | + |
38 | + /* | | 37 | + /* |
39 | * SunOS 4.x has no /proc, and ptrace() peeking the u area won't give us the | | 38 | * SunOS 4.x has no /proc, and ptrace() peeking the u area won't give us the |
40 | * process memory segment sizes. Instead we must grope process information | | 39 | * process memory segment sizes. Instead we must grope process information |
41 | * from kernel virtual memory. This requires super-user privilege. | | 40 | * from kernel virtual memory. This requires super-user privilege. |
42 | @@ -414,7 +433,7 @@ static int ptrace_attach_wait(pid_t pid) | | 41 | @@ -414,7 +432,7 @@ static int ptrace_attach_wait(pid_t pid) |
43 | | | 42 | |
44 | /* call_ptrace - ptrace() with error handling */ | | 43 | /* call_ptrace - ptrace() with error handling */ |
45 | | | 44 | |
46 | -static int call_ptrace(int request, pid_t pid, int addr, int data) | | 45 | -static int call_ptrace(int request, pid_t pid, int addr, int data) |
47 | +static int call_ptrace(int request, pid_t pid, uintptr_t addr, int data) | | 46 | +static int call_ptrace(int request, pid_t pid, uintptr_t addr, int data) |
48 | { | | 47 | { |
49 | int result; | | 48 | int result; |
50 | | | 49 | |
51 | @@ -456,7 +475,7 @@ static void read_proc(PROC_INFO *proc, c | | 50 | @@ -456,7 +474,7 @@ static void read_proc(PROC_INFO *proc, c |
52 | "; did you use GCC with another machine's header files?" : ""); | | 51 | "; did you use GCC with another machine's header files?" : ""); |
53 | #else | | 52 | #else |
54 | int words[READ_BUFSIZ_WORDS]; | | 53 | int words[READ_BUFSIZ_WORDS]; |
55 | - int addr; | | 54 | - int addr; |
56 | + uintptr_t addr; | | 55 | + uintptr_t addr; |
57 | int n; | | 56 | int n; |
58 | | | 57 | |
59 | /* | | 58 | /* |
60 | @@ -469,7 +488,7 @@ static void read_proc(PROC_INFO *proc, c | | 59 | @@ -469,7 +487,7 @@ static void read_proc(PROC_INFO *proc, c |
61 | panic("read_proc: request size %d is not word-aligned", len); | | 60 | panic("read_proc: request size %d is not word-aligned", len); |
62 | if (verbose) | | 61 | if (verbose) |
63 | fprintf(stderr, "read seek to 0x%lx\n", (long) offset); | | 62 | fprintf(stderr, "read seek to 0x%lx\n", (long) offset); |
64 | - for (n = 0, addr = (int) offset; n < len / sizeof(int); addr += sizeof(int), n++) | | 63 | - for (n = 0, addr = (int) offset; n < len / sizeof(int); addr += sizeof(int), n++) |
65 | + for (n = 0, addr = (uintptr_t) offset; n < len / sizeof(int); addr += sizeof(int), n++) | | 64 | + for (n = 0, addr = (uintptr_t) offset; n < len / sizeof(int); addr += sizeof(int), n++) |
66 | words[n] = call_ptrace(PTRACE_PEEKDATA, proc->pid, addr, 0); | | 65 | words[n] = call_ptrace(PTRACE_PEEKDATA, proc->pid, addr, 0); |
67 | memcpy(data, (char *) words, len); | | 66 | memcpy(data, (char *) words, len); |
68 | #endif | | 67 | #endif |