summaryrefslogtreecommitdiff
path: root/sysutils/strace/patches/patch-ap
blob: 4825880414f7b6e39db1f6478b7b45e4a0eb00c8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
$NetBSD: patch-ap,v 1.1 2006/03/05 08:17:49 christos Exp $

--- util.c	2005-10-21 18:06:46.000000000 -0400
+++ util.c	2006-03-04 22:32:21.000000000 -0500
@@ -36,9 +36,9 @@
 #include "defs.h"
 
 #include <signal.h>
+#include <sys/param.h>
 #include <sys/syscall.h>
 #include <sys/user.h>
-#include <sys/param.h>
 #include <fcntl.h>
 #if HAVE_SYS_UIO_H
 #include <sys/uio.h>
@@ -58,6 +58,9 @@
 # include <asm/rse.h>
 #endif
 
+#ifdef NETBSD
+#include <machine/reg.h>
+#endif
 #ifdef HAVE_SYS_REG_H
 #include <sys/reg.h>
 # define PTRACE_PEEKUSR PTRACE_PEEKUSER
@@ -96,6 +99,7 @@
 # define PTRACE_SETREGS PTRACE_SETREGS64
 #endif /* SPARC64 */
 
+
 #if !defined(__GLIBC__)
 
 #include <linux/unistd.h>
@@ -759,6 +763,20 @@
 		return -1;
 #endif /* USE_PROCFS */
 
+#ifdef NETBSD
+	struct ptrace_io_desc piod;
+
+	piod.piod_op = PIOD_READ_D;
+	piod.piod_offs = (void *)addr;
+	piod.piod_addr = laddr;
+	piod.piod_len = len;
+
+	if (ptrace(PT_IO, tcp->pid, (char *)&piod, sizeof(piod)) < 0) {
+		perror("PT_IO");
+		return -1;
+	}
+#endif
+
 	return 0;
 }
 
@@ -1079,6 +1097,14 @@
 	pread(tcp->pfd_reg, &regs, sizeof(regs), 0);
 	return regs.r_eip;
 #endif /* FREEBSD */
+#ifdef NETBSD
+	struct reg regs;
+	if (ptrace(PTRACE_GETREGS, tcp->pid, (char *) &regs, 0) < 0) {
+		perror("getpc: ptrace(PTRACE_GETREGS, ...)");
+		return -1;
+	}
+	return regs.r_eip;
+#endif /* NETBSD */
 }
 #endif