summaryrefslogtreecommitdiff
path: root/sysutils/strace/patches/patch-as
blob: 5363de1573b870ca5ea1088764e7043425cbe16d (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
$NetBSD: patch-as,v 1.1 2007/04/27 19:45:02 christos Exp $

--- strace.c.orig	2006-01-12 04:50:49.000000000 -0500
+++ strace.c	2007-04-27 11:31:51.000000000 -0400
@@ -820,13 +820,13 @@
 	}
 #else
 	/* Open the process pseudo-file in /proc. */
-#ifndef FREEBSD
+#ifndef ALLBSD
 	sprintf(proc, "/proc/%d", tcp->pid);
 	if ((tcp->pfd = open(proc, O_RDWR|O_EXCL)) < 0) {
-#else /* FREEBSD */
+#else /* ALLBSD */
 	sprintf(proc, "/proc/%d/mem", tcp->pid);
 	if ((tcp->pfd = open(proc, O_RDWR)) < 0) {
-#endif /* FREEBSD */
+#endif /* ALLBSD */
 		perror("strace: open(\"/proc/...\", ...)");
 		return -1;
 	}
@@ -839,7 +839,7 @@
 		return -1;
 	}
 #endif
-#ifdef FREEBSD
+#ifdef ALLBSD
 	sprintf(proc, "/proc/%d/regs", tcp->pid);
 	if ((tcp->pfd_reg = open(proc, O_RDONLY)) < 0) {
 		perror("strace: open(\"/proc/.../regs\", ...)");
@@ -853,7 +853,7 @@
 		}
 	} else
 		tcp->pfd_status = -1;
-#endif /* FREEBSD */
+#endif /* ALLBSD */
 	rebuild_pollv();
 	if (!attaching) {
 		/*
@@ -869,7 +869,7 @@
 			    break;
 		}
 	}
-#ifndef FREEBSD
+#ifndef ALLBSD
 	/* Stop the process so that we own the stop. */
 	if (IOCTL(tcp->pfd, PIOCSTOP, (char *)NULL) < 0) {
 		perror("strace: PIOCSTOP");
@@ -1204,8 +1204,10 @@
 int sig;
 {
 	int error = 0;
+#if defined(NETBSD) || defined(LINUX)
+	int resumed, status;
+#endif
 #ifdef LINUX
-	int status, resumed;
 	struct tcb *zombie = NULL;
 
 	/* If the group leader is lingering only because of this other
@@ -1219,16 +1221,18 @@
 	if (tcp->flags & TCB_BPTSET)
 		sig = SIGKILL;
 
-#ifdef LINUX
+#if defined(LINUX) || defined(NETBSD)
 	/*
 	 * Linux wrongly insists the child be stopped
 	 * before detaching.  Arghh.  We go through hoops
 	 * to make a clean break of things.
 	 */
 #if defined(SPARC)
+#ifdef PTRACE_SUNDETACH
 #undef PTRACE_DETACH
 #define PTRACE_DETACH PTRACE_SUNDETACH
 #endif
+#endif
 	if ((error = ptrace(PTRACE_DETACH, tcp->pid, (char *) 1, sig)) == 0) {
 		/* On a clear day, you can see forever. */
 	}
@@ -1296,7 +1300,7 @@
 			}
 		}
 	}
-#endif /* LINUX */
+#endif /* NETBSD */
 
 #if defined(SUNOS4)
 	/* PTRACE_DETACH won't respect `sig' argument, so we post it here. */
@@ -2047,9 +2051,9 @@
 		pid = wait4(-1, &status, 0, cflag ? &ru : NULL);
 #endif /* __WALL */
 #endif /* LINUX */
-#ifdef SUNOS4
+#if defined(SUNOS4) || defined(NETBSD)
 		pid = wait(&status);
-#endif /* SUNOS4 */
+#endif /* SUNOS4 || NETBSD */
 		wait_errno = errno;
 		if (interactive)
 			sigprocmask(SIG_BLOCK, &blocked_set, NULL);
@@ -2279,7 +2283,11 @@
 				printtrailer(tcp);
 			}
 			if (((tcp->flags & TCB_ATTACHED) ||
+#ifdef LINUX
 			     tcp->nclone_threads > 0) &&
+#else
+			     0) &&
+#endif
 				!sigishandled(tcp, WSTOPSIG(status))) {
 #ifdef TCB_GROUP_EXITING
 				handle_group_exit(tcp, WSTOPSIG(status));