t_ptrace_x86_wait.h revision 1.1.2.2 1 1.1.2.2 bouyer /* $NetBSD: t_ptrace_x86_wait.h,v 1.1.2.2 2017/04/21 16:54:11 bouyer Exp $ */
2 1.1.2.2 bouyer
3 1.1.2.2 bouyer /*-
4 1.1.2.2 bouyer * Copyright (c) 2016 The NetBSD Foundation, Inc.
5 1.1.2.2 bouyer * All rights reserved.
6 1.1.2.2 bouyer *
7 1.1.2.2 bouyer * Redistribution and use in source and binary forms, with or without
8 1.1.2.2 bouyer * modification, are permitted provided that the following conditions
9 1.1.2.2 bouyer * are met:
10 1.1.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
11 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer.
12 1.1.2.2 bouyer * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.2.2 bouyer * notice, this list of conditions and the following disclaimer in the
14 1.1.2.2 bouyer * documentation and/or other materials provided with the distribution.
15 1.1.2.2 bouyer *
16 1.1.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 1.1.2.2 bouyer * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 1.1.2.2 bouyer * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 1.1.2.2 bouyer * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 1.1.2.2 bouyer * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 1.1.2.2 bouyer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 1.1.2.2 bouyer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 1.1.2.2 bouyer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 1.1.2.2 bouyer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 1.1.2.2 bouyer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 1.1.2.2 bouyer * POSSIBILITY OF SUCH DAMAGE.
27 1.1.2.2 bouyer */
28 1.1.2.2 bouyer
29 1.1.2.2 bouyer #if defined(__i386__) || defined(__x86_64__)
30 1.1.2.2 bouyer union u {
31 1.1.2.2 bouyer unsigned long raw;
32 1.1.2.2 bouyer struct {
33 1.1.2.2 bouyer unsigned long local_dr0_breakpoint : 1; /* 0 */
34 1.1.2.2 bouyer unsigned long global_dr0_breakpoint : 1; /* 1 */
35 1.1.2.2 bouyer unsigned long local_dr1_breakpoint : 1; /* 2 */
36 1.1.2.2 bouyer unsigned long global_dr1_breakpoint : 1; /* 3 */
37 1.1.2.2 bouyer unsigned long local_dr2_breakpoint : 1; /* 4 */
38 1.1.2.2 bouyer unsigned long global_dr2_breakpoint : 1; /* 5 */
39 1.1.2.2 bouyer unsigned long local_dr3_breakpoint : 1; /* 6 */
40 1.1.2.2 bouyer unsigned long global_dr3_breakpoint : 1; /* 7 */
41 1.1.2.2 bouyer unsigned long local_exact_breakpt : 1; /* 8 */
42 1.1.2.2 bouyer unsigned long global_exact_breakpt : 1; /* 9 */
43 1.1.2.2 bouyer unsigned long reserved_10 : 1; /* 10 */
44 1.1.2.2 bouyer unsigned long rest_trans_memory : 1; /* 11 */
45 1.1.2.2 bouyer unsigned long reserved_12 : 1; /* 12 */
46 1.1.2.2 bouyer unsigned long general_detect_enable : 1; /* 13 */
47 1.1.2.2 bouyer unsigned long reserved_14 : 1; /* 14 */
48 1.1.2.2 bouyer unsigned long reserved_15 : 1; /* 15 */
49 1.1.2.2 bouyer unsigned long condition_dr0 : 2; /* 16-17 */
50 1.1.2.2 bouyer unsigned long len_dr0 : 2; /* 18-19 */
51 1.1.2.2 bouyer unsigned long condition_dr1 : 2; /* 20-21 */
52 1.1.2.2 bouyer unsigned long len_dr1 : 2; /* 22-23 */
53 1.1.2.2 bouyer unsigned long condition_dr2 : 2; /* 24-25 */
54 1.1.2.2 bouyer unsigned long len_dr2 : 2; /* 26-27 */
55 1.1.2.2 bouyer unsigned long condition_dr3 : 2; /* 28-29 */
56 1.1.2.2 bouyer unsigned long len_dr3 : 2; /* 30-31 */
57 1.1.2.2 bouyer } bits;
58 1.1.2.2 bouyer };
59 1.1.2.2 bouyer
60 1.1.2.2 bouyer ATF_TC(dbregs_print);
61 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_print, tc)
62 1.1.2.2 bouyer {
63 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
64 1.1.2.2 bouyer "Verify plain PT_GETDBREGS with printing Debug Registers");
65 1.1.2.2 bouyer }
66 1.1.2.2 bouyer
67 1.1.2.2 bouyer ATF_TC_BODY(dbregs_print, tc)
68 1.1.2.2 bouyer {
69 1.1.2.2 bouyer const int exitval = 5;
70 1.1.2.2 bouyer const int sigval = SIGSTOP;
71 1.1.2.2 bouyer pid_t child, wpid;
72 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
73 1.1.2.2 bouyer int status;
74 1.1.2.2 bouyer #endif
75 1.1.2.2 bouyer struct dbreg r;
76 1.1.2.2 bouyer size_t i;
77 1.1.2.2 bouyer
78 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
79 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
80 1.1.2.2 bouyer if (child == 0) {
81 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
82 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
83 1.1.2.2 bouyer
84 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
85 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
86 1.1.2.2 bouyer
87 1.1.2.2 bouyer printf("Before exiting of the child process\n");
88 1.1.2.2 bouyer _exit(exitval);
89 1.1.2.2 bouyer }
90 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
91 1.1.2.2 bouyer
92 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
93 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
94 1.1.2.2 bouyer
95 1.1.2.2 bouyer validate_status_stopped(status, sigval);
96 1.1.2.2 bouyer
97 1.1.2.2 bouyer printf("Call GETDBREGS for the child process\n");
98 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r, 0) != -1);
99 1.1.2.2 bouyer
100 1.1.2.2 bouyer printf("State of the debug registers:\n");
101 1.1.2.2 bouyer for (i = 0; i < __arraycount(r.dr); i++)
102 1.1.2.2 bouyer printf("r[%zu]=%" PRIxREGISTER "\n", i, r.dr[i]);
103 1.1.2.2 bouyer
104 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
105 1.1.2.2 bouyer "without signal to be sent\n");
106 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
107 1.1.2.2 bouyer
108 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
109 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
110 1.1.2.2 bouyer
111 1.1.2.2 bouyer validate_status_exited(status, exitval);
112 1.1.2.2 bouyer
113 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
114 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
115 1.1.2.2 bouyer }
116 1.1.2.2 bouyer
117 1.1.2.2 bouyer
118 1.1.2.2 bouyer enum dbreg_preserve_mode {
119 1.1.2.2 bouyer dbreg_preserve_mode_none,
120 1.1.2.2 bouyer dbreg_preserve_mode_yield,
121 1.1.2.2 bouyer dbreg_preserve_mode_continued
122 1.1.2.2 bouyer };
123 1.1.2.2 bouyer
124 1.1.2.2 bouyer static void
125 1.1.2.2 bouyer dbreg_preserve(int reg, enum dbreg_preserve_mode mode)
126 1.1.2.2 bouyer {
127 1.1.2.2 bouyer const int exitval = 5;
128 1.1.2.2 bouyer const int sigval = SIGSTOP;
129 1.1.2.2 bouyer pid_t child, wpid;
130 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
131 1.1.2.2 bouyer int status;
132 1.1.2.2 bouyer #endif
133 1.1.2.2 bouyer struct dbreg r1;
134 1.1.2.2 bouyer struct dbreg r2;
135 1.1.2.2 bouyer size_t i;
136 1.1.2.2 bouyer int watchme;
137 1.1.2.2 bouyer
138 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
139 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
140 1.1.2.2 bouyer if (child == 0) {
141 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
142 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
143 1.1.2.2 bouyer
144 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
145 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
146 1.1.2.2 bouyer
147 1.1.2.2 bouyer if (mode == dbreg_preserve_mode_continued) {
148 1.1.2.2 bouyer printf("Before raising %s from child\n",
149 1.1.2.2 bouyer strsignal(sigval));
150 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
151 1.1.2.2 bouyer }
152 1.1.2.2 bouyer
153 1.1.2.2 bouyer printf("Before exiting of the child process\n");
154 1.1.2.2 bouyer _exit(exitval);
155 1.1.2.2 bouyer }
156 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
157 1.1.2.2 bouyer
158 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
159 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
160 1.1.2.2 bouyer
161 1.1.2.2 bouyer validate_status_stopped(status, sigval);
162 1.1.2.2 bouyer
163 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r1)\n");
164 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
165 1.1.2.2 bouyer
166 1.1.2.2 bouyer printf("State of the debug registers (r1):\n");
167 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
168 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
169 1.1.2.2 bouyer
170 1.1.2.2 bouyer r1.dr[reg] = (long)(intptr_t)&watchme;
171 1.1.2.2 bouyer printf("Set DR0 (r1.dr[%d]) to new value %" PRIxREGISTER "\n",
172 1.1.2.2 bouyer reg, r1.dr[reg]);
173 1.1.2.2 bouyer
174 1.1.2.2 bouyer printf("New state of the debug registers (r1):\n");
175 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
176 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
177 1.1.2.2 bouyer
178 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
179 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
180 1.1.2.2 bouyer
181 1.1.2.2 bouyer switch (mode) {
182 1.1.2.2 bouyer case dbreg_preserve_mode_none:
183 1.1.2.2 bouyer break;
184 1.1.2.2 bouyer case dbreg_preserve_mode_yield:
185 1.1.2.2 bouyer printf("Yields a processor voluntarily and gives other "
186 1.1.2.2 bouyer "threads a chance to run without waiting for an "
187 1.1.2.2 bouyer "involuntary preemptive switch\n");
188 1.1.2.2 bouyer sched_yield();
189 1.1.2.2 bouyer break;
190 1.1.2.2 bouyer case dbreg_preserve_mode_continued:
191 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
192 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
193 1.1.2.2 bouyer
194 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
195 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
196 1.1.2.2 bouyer
197 1.1.2.2 bouyer validate_status_stopped(status, sigval);
198 1.1.2.2 bouyer break;
199 1.1.2.2 bouyer }
200 1.1.2.2 bouyer
201 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r2)\n");
202 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
203 1.1.2.2 bouyer
204 1.1.2.2 bouyer printf("Assert that (r1) and (r2) are the same\n");
205 1.1.2.2 bouyer ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
206 1.1.2.2 bouyer
207 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
208 1.1.2.2 bouyer "without signal to be sent\n");
209 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
210 1.1.2.2 bouyer
211 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
212 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
213 1.1.2.2 bouyer
214 1.1.2.2 bouyer validate_status_exited(status, exitval);
215 1.1.2.2 bouyer
216 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
217 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
218 1.1.2.2 bouyer }
219 1.1.2.2 bouyer
220 1.1.2.2 bouyer
221 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr0);
222 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr0, tc)
223 1.1.2.2 bouyer {
224 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
225 1.1.2.2 bouyer "Verify that setting DR0 is preserved across ptrace(2) calls");
226 1.1.2.2 bouyer }
227 1.1.2.2 bouyer
228 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr0, tc)
229 1.1.2.2 bouyer {
230 1.1.2.2 bouyer dbreg_preserve(0, dbreg_preserve_mode_none);
231 1.1.2.2 bouyer }
232 1.1.2.2 bouyer
233 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr1);
234 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr1, tc)
235 1.1.2.2 bouyer {
236 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
237 1.1.2.2 bouyer "Verify that setting DR1 is preserved across ptrace(2) calls");
238 1.1.2.2 bouyer }
239 1.1.2.2 bouyer
240 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr1, tc)
241 1.1.2.2 bouyer {
242 1.1.2.2 bouyer dbreg_preserve(1, dbreg_preserve_mode_none);
243 1.1.2.2 bouyer }
244 1.1.2.2 bouyer
245 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr2);
246 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr2, tc)
247 1.1.2.2 bouyer {
248 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
249 1.1.2.2 bouyer "Verify that setting DR2 is preserved across ptrace(2) calls");
250 1.1.2.2 bouyer }
251 1.1.2.2 bouyer
252 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr2, tc)
253 1.1.2.2 bouyer {
254 1.1.2.2 bouyer dbreg_preserve(2, dbreg_preserve_mode_none);
255 1.1.2.2 bouyer }
256 1.1.2.2 bouyer
257 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr3);
258 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr3, tc)
259 1.1.2.2 bouyer {
260 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
261 1.1.2.2 bouyer "Verify that setting DR3 is preserved across ptrace(2) calls");
262 1.1.2.2 bouyer }
263 1.1.2.2 bouyer
264 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr3, tc)
265 1.1.2.2 bouyer {
266 1.1.2.2 bouyer dbreg_preserve(3, dbreg_preserve_mode_none);
267 1.1.2.2 bouyer }
268 1.1.2.2 bouyer
269 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr0_yield);
270 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr0_yield, tc)
271 1.1.2.2 bouyer {
272 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
273 1.1.2.2 bouyer "Verify that setting DR0 is preserved across ptrace(2) calls with "
274 1.1.2.2 bouyer "scheduler yield");
275 1.1.2.2 bouyer }
276 1.1.2.2 bouyer
277 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr0_yield, tc)
278 1.1.2.2 bouyer {
279 1.1.2.2 bouyer dbreg_preserve(0, dbreg_preserve_mode_yield);
280 1.1.2.2 bouyer }
281 1.1.2.2 bouyer
282 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr1_yield);
283 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr1_yield, tc)
284 1.1.2.2 bouyer {
285 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
286 1.1.2.2 bouyer "Verify that setting DR1 is preserved across ptrace(2) calls with "
287 1.1.2.2 bouyer "scheduler yield");
288 1.1.2.2 bouyer }
289 1.1.2.2 bouyer
290 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr1_yield, tc)
291 1.1.2.2 bouyer {
292 1.1.2.2 bouyer dbreg_preserve(0, dbreg_preserve_mode_yield);
293 1.1.2.2 bouyer }
294 1.1.2.2 bouyer
295 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr2_yield);
296 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr2_yield, tc)
297 1.1.2.2 bouyer {
298 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
299 1.1.2.2 bouyer "Verify that setting DR2 is preserved across ptrace(2) calls with "
300 1.1.2.2 bouyer "scheduler yield");
301 1.1.2.2 bouyer }
302 1.1.2.2 bouyer
303 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr2_yield, tc)
304 1.1.2.2 bouyer {
305 1.1.2.2 bouyer dbreg_preserve(0, dbreg_preserve_mode_yield);
306 1.1.2.2 bouyer }
307 1.1.2.2 bouyer
308 1.1.2.2 bouyer
309 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr3_yield);
310 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr3_yield, tc)
311 1.1.2.2 bouyer {
312 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
313 1.1.2.2 bouyer "Verify that setting DR3 is preserved across ptrace(2) calls with "
314 1.1.2.2 bouyer "scheduler yield");
315 1.1.2.2 bouyer }
316 1.1.2.2 bouyer
317 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr3_yield, tc)
318 1.1.2.2 bouyer {
319 1.1.2.2 bouyer dbreg_preserve(3, dbreg_preserve_mode_yield);
320 1.1.2.2 bouyer }
321 1.1.2.2 bouyer
322 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr0_continued);
323 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr0_continued, tc)
324 1.1.2.2 bouyer {
325 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
326 1.1.2.2 bouyer "Verify that setting DR0 is preserved across ptrace(2) calls and "
327 1.1.2.2 bouyer "with continued child");
328 1.1.2.2 bouyer }
329 1.1.2.2 bouyer
330 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr0_continued, tc)
331 1.1.2.2 bouyer {
332 1.1.2.2 bouyer dbreg_preserve(0, dbreg_preserve_mode_continued);
333 1.1.2.2 bouyer }
334 1.1.2.2 bouyer
335 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr1_continued);
336 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr1_continued, tc)
337 1.1.2.2 bouyer {
338 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
339 1.1.2.2 bouyer "Verify that setting DR1 is preserved across ptrace(2) calls and "
340 1.1.2.2 bouyer "with continued child");
341 1.1.2.2 bouyer }
342 1.1.2.2 bouyer
343 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr1_continued, tc)
344 1.1.2.2 bouyer {
345 1.1.2.2 bouyer dbreg_preserve(1, dbreg_preserve_mode_continued);
346 1.1.2.2 bouyer }
347 1.1.2.2 bouyer
348 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr2_continued);
349 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr2_continued, tc)
350 1.1.2.2 bouyer {
351 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
352 1.1.2.2 bouyer "Verify that setting DR2 is preserved across ptrace(2) calls and "
353 1.1.2.2 bouyer "with continued child");
354 1.1.2.2 bouyer }
355 1.1.2.2 bouyer
356 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr2_continued, tc)
357 1.1.2.2 bouyer {
358 1.1.2.2 bouyer dbreg_preserve(2, dbreg_preserve_mode_continued);
359 1.1.2.2 bouyer }
360 1.1.2.2 bouyer
361 1.1.2.2 bouyer ATF_TC(dbregs_preserve_dr3_continued);
362 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_preserve_dr3_continued, tc)
363 1.1.2.2 bouyer {
364 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
365 1.1.2.2 bouyer "Verify that setting DR3 is preserved across ptrace(2) calls and "
366 1.1.2.2 bouyer "with continued child");
367 1.1.2.2 bouyer }
368 1.1.2.2 bouyer
369 1.1.2.2 bouyer ATF_TC_BODY(dbregs_preserve_dr3_continued, tc)
370 1.1.2.2 bouyer {
371 1.1.2.2 bouyer dbreg_preserve(3, dbreg_preserve_mode_continued);
372 1.1.2.2 bouyer }
373 1.1.2.2 bouyer
374 1.1.2.2 bouyer
375 1.1.2.2 bouyer static void
376 1.1.2.2 bouyer dbregs_trap_variable(int reg, int cond, int len, bool write)
377 1.1.2.2 bouyer {
378 1.1.2.2 bouyer const int exitval = 5;
379 1.1.2.2 bouyer const int sigval = SIGSTOP;
380 1.1.2.2 bouyer pid_t child, wpid;
381 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
382 1.1.2.2 bouyer int status;
383 1.1.2.2 bouyer #endif
384 1.1.2.2 bouyer struct dbreg r1;
385 1.1.2.2 bouyer size_t i;
386 1.1.2.2 bouyer volatile int watchme = 0;
387 1.1.2.2 bouyer union u dr7;
388 1.1.2.2 bouyer
389 1.1.2.2 bouyer struct ptrace_siginfo info;
390 1.1.2.2 bouyer memset(&info, 0, sizeof(info));
391 1.1.2.2 bouyer
392 1.1.2.2 bouyer dr7.raw = 0;
393 1.1.2.2 bouyer switch (reg) {
394 1.1.2.2 bouyer case 0:
395 1.1.2.2 bouyer dr7.bits.global_dr0_breakpoint = 1;
396 1.1.2.2 bouyer dr7.bits.condition_dr0 = cond;
397 1.1.2.2 bouyer dr7.bits.len_dr0 = len;
398 1.1.2.2 bouyer case 1:
399 1.1.2.2 bouyer dr7.bits.global_dr1_breakpoint = 1;
400 1.1.2.2 bouyer dr7.bits.condition_dr1 = cond;
401 1.1.2.2 bouyer dr7.bits.len_dr1 = len;
402 1.1.2.2 bouyer case 2:
403 1.1.2.2 bouyer dr7.bits.global_dr2_breakpoint = 1;
404 1.1.2.2 bouyer dr7.bits.condition_dr2 = cond;
405 1.1.2.2 bouyer dr7.bits.len_dr2 = len;
406 1.1.2.2 bouyer case 3:
407 1.1.2.2 bouyer dr7.bits.global_dr3_breakpoint = 1;
408 1.1.2.2 bouyer dr7.bits.condition_dr3 = cond;
409 1.1.2.2 bouyer dr7.bits.len_dr3 = len;
410 1.1.2.2 bouyer break;
411 1.1.2.2 bouyer }
412 1.1.2.2 bouyer
413 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
414 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
415 1.1.2.2 bouyer if (child == 0) {
416 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
417 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
418 1.1.2.2 bouyer
419 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
420 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
421 1.1.2.2 bouyer
422 1.1.2.2 bouyer if (write)
423 1.1.2.2 bouyer watchme = 1;
424 1.1.2.2 bouyer else
425 1.1.2.2 bouyer printf("watchme=%d\n", watchme);
426 1.1.2.2 bouyer
427 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
428 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
429 1.1.2.2 bouyer
430 1.1.2.2 bouyer printf("Before exiting of the child process\n");
431 1.1.2.2 bouyer _exit(exitval);
432 1.1.2.2 bouyer }
433 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
434 1.1.2.2 bouyer
435 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
436 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
437 1.1.2.2 bouyer
438 1.1.2.2 bouyer validate_status_stopped(status, sigval);
439 1.1.2.2 bouyer
440 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r1)\n");
441 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
442 1.1.2.2 bouyer
443 1.1.2.2 bouyer printf("State of the debug registers (r1):\n");
444 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
445 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
446 1.1.2.2 bouyer
447 1.1.2.2 bouyer r1.dr[reg] = (long)(intptr_t)&watchme;
448 1.1.2.2 bouyer printf("Set DR%d (r1.dr[%d]) to new value %" PRIxREGISTER "\n",
449 1.1.2.2 bouyer reg, reg, r1.dr[reg]);
450 1.1.2.2 bouyer
451 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
452 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
453 1.1.2.2 bouyer r1.dr[7]);
454 1.1.2.2 bouyer
455 1.1.2.2 bouyer printf("New state of the debug registers (r1):\n");
456 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
457 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
458 1.1.2.2 bouyer
459 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
460 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
461 1.1.2.2 bouyer
462 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
463 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
464 1.1.2.2 bouyer
465 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
466 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
467 1.1.2.2 bouyer
468 1.1.2.2 bouyer validate_status_stopped(status, SIGTRAP);
469 1.1.2.2 bouyer
470 1.1.2.2 bouyer printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
471 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
472 1.1.2.2 bouyer
473 1.1.2.2 bouyer printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
474 1.1.2.2 bouyer printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
475 1.1.2.2 bouyer info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
476 1.1.2.2 bouyer info.psi_siginfo.si_errno);
477 1.1.2.2 bouyer
478 1.1.2.2 bouyer printf("Before checking siginfo_t\n");
479 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
480 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_DBREG);
481 1.1.2.2 bouyer
482 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
483 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
484 1.1.2.2 bouyer
485 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
486 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
487 1.1.2.2 bouyer
488 1.1.2.2 bouyer validate_status_stopped(status, sigval);
489 1.1.2.2 bouyer
490 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
491 1.1.2.2 bouyer "without signal to be sent\n");
492 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
493 1.1.2.2 bouyer
494 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
495 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
496 1.1.2.2 bouyer
497 1.1.2.2 bouyer validate_status_exited(status, exitval);
498 1.1.2.2 bouyer
499 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
500 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
501 1.1.2.2 bouyer }
502 1.1.2.2 bouyer
503 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_writeonly_byte);
504 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_writeonly_byte, tc)
505 1.1.2.2 bouyer {
506 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
507 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
508 1.1.2.2 bouyer "(break on data writes only and 1 byte mode)");
509 1.1.2.2 bouyer }
510 1.1.2.2 bouyer
511 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_writeonly_byte, tc)
512 1.1.2.2 bouyer {
513 1.1.2.2 bouyer /* 0b01 -- break on data write only */
514 1.1.2.2 bouyer /* 0b00 -- 1 byte */
515 1.1.2.2 bouyer
516 1.1.2.2 bouyer dbregs_trap_variable(0, 1, 0, true);
517 1.1.2.2 bouyer }
518 1.1.2.2 bouyer
519 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_writeonly_byte);
520 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_writeonly_byte, tc)
521 1.1.2.2 bouyer {
522 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
523 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
524 1.1.2.2 bouyer "(break on data writes only and 1 byte mode)");
525 1.1.2.2 bouyer }
526 1.1.2.2 bouyer
527 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_writeonly_byte, tc)
528 1.1.2.2 bouyer {
529 1.1.2.2 bouyer /* 0b01 -- break on data write only */
530 1.1.2.2 bouyer /* 0b00 -- 1 byte */
531 1.1.2.2 bouyer
532 1.1.2.2 bouyer dbregs_trap_variable(1, 1, 0, true);
533 1.1.2.2 bouyer }
534 1.1.2.2 bouyer
535 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_writeonly_byte);
536 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_writeonly_byte, tc)
537 1.1.2.2 bouyer {
538 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
539 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
540 1.1.2.2 bouyer "(break on data writes only and 1 byte mode)");
541 1.1.2.2 bouyer }
542 1.1.2.2 bouyer
543 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_writeonly_byte, tc)
544 1.1.2.2 bouyer {
545 1.1.2.2 bouyer /* 0b01 -- break on data write only */
546 1.1.2.2 bouyer /* 0b00 -- 1 byte */
547 1.1.2.2 bouyer
548 1.1.2.2 bouyer dbregs_trap_variable(2, 1, 0, true);
549 1.1.2.2 bouyer }
550 1.1.2.2 bouyer
551 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_writeonly_byte);
552 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_writeonly_byte, tc)
553 1.1.2.2 bouyer {
554 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
555 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
556 1.1.2.2 bouyer "(break on data writes only and 1 byte mode)");
557 1.1.2.2 bouyer }
558 1.1.2.2 bouyer
559 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_writeonly_byte, tc)
560 1.1.2.2 bouyer {
561 1.1.2.2 bouyer /* 0b01 -- break on data write only */
562 1.1.2.2 bouyer /* 0b00 -- 1 byte */
563 1.1.2.2 bouyer
564 1.1.2.2 bouyer dbregs_trap_variable(3, 1, 0, true);
565 1.1.2.2 bouyer }
566 1.1.2.2 bouyer
567 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_writeonly_2bytes);
568 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_writeonly_2bytes, tc)
569 1.1.2.2 bouyer {
570 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
571 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
572 1.1.2.2 bouyer "(break on data writes only and 2 bytes mode)");
573 1.1.2.2 bouyer }
574 1.1.2.2 bouyer
575 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_writeonly_2bytes, tc)
576 1.1.2.2 bouyer {
577 1.1.2.2 bouyer /* 0b01 -- break on data write only */
578 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
579 1.1.2.2 bouyer
580 1.1.2.2 bouyer dbregs_trap_variable(0, 1, 1, true);
581 1.1.2.2 bouyer }
582 1.1.2.2 bouyer
583 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_writeonly_2bytes);
584 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_writeonly_2bytes, tc)
585 1.1.2.2 bouyer {
586 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
587 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
588 1.1.2.2 bouyer "(break on data writes only and 2 bytes mode)");
589 1.1.2.2 bouyer }
590 1.1.2.2 bouyer
591 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_writeonly_2bytes, tc)
592 1.1.2.2 bouyer {
593 1.1.2.2 bouyer /* 0b01 -- break on data write only */
594 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
595 1.1.2.2 bouyer
596 1.1.2.2 bouyer dbregs_trap_variable(1, 1, 1, true);
597 1.1.2.2 bouyer }
598 1.1.2.2 bouyer
599 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_writeonly_2bytes);
600 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_writeonly_2bytes, tc)
601 1.1.2.2 bouyer {
602 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
603 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
604 1.1.2.2 bouyer "(break on data writes only and 2 bytes mode)");
605 1.1.2.2 bouyer }
606 1.1.2.2 bouyer
607 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_writeonly_2bytes, tc)
608 1.1.2.2 bouyer {
609 1.1.2.2 bouyer /* 0b01 -- break on data write only */
610 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
611 1.1.2.2 bouyer
612 1.1.2.2 bouyer dbregs_trap_variable(2, 1, 1, true);
613 1.1.2.2 bouyer }
614 1.1.2.2 bouyer
615 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_writeonly_2bytes);
616 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_writeonly_2bytes, tc)
617 1.1.2.2 bouyer {
618 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
619 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
620 1.1.2.2 bouyer "(break on data writes only and 2 bytes mode)");
621 1.1.2.2 bouyer }
622 1.1.2.2 bouyer
623 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_writeonly_2bytes, tc)
624 1.1.2.2 bouyer {
625 1.1.2.2 bouyer /* 0b01 -- break on data write only */
626 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
627 1.1.2.2 bouyer
628 1.1.2.2 bouyer dbregs_trap_variable(3, 1, 1, true);
629 1.1.2.2 bouyer }
630 1.1.2.2 bouyer
631 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_writeonly_4bytes);
632 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_writeonly_4bytes, tc)
633 1.1.2.2 bouyer {
634 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
635 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
636 1.1.2.2 bouyer "(break on data writes only and 4 bytes mode)");
637 1.1.2.2 bouyer }
638 1.1.2.2 bouyer
639 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_writeonly_4bytes, tc)
640 1.1.2.2 bouyer {
641 1.1.2.2 bouyer /* 0b01 -- break on data write only */
642 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
643 1.1.2.2 bouyer
644 1.1.2.2 bouyer dbregs_trap_variable(0, 1, 3, true);
645 1.1.2.2 bouyer }
646 1.1.2.2 bouyer
647 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_writeonly_4bytes);
648 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_writeonly_4bytes, tc)
649 1.1.2.2 bouyer {
650 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
651 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
652 1.1.2.2 bouyer "(break on data writes only and 4 bytes mode)");
653 1.1.2.2 bouyer }
654 1.1.2.2 bouyer
655 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_writeonly_4bytes, tc)
656 1.1.2.2 bouyer {
657 1.1.2.2 bouyer /* 0b01 -- break on data write only */
658 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
659 1.1.2.2 bouyer
660 1.1.2.2 bouyer dbregs_trap_variable(1, 1, 3, true);
661 1.1.2.2 bouyer }
662 1.1.2.2 bouyer
663 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_writeonly_4bytes);
664 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_writeonly_4bytes, tc)
665 1.1.2.2 bouyer {
666 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
667 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
668 1.1.2.2 bouyer "(break on data writes only and 4 bytes mode)");
669 1.1.2.2 bouyer }
670 1.1.2.2 bouyer
671 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_writeonly_4bytes, tc)
672 1.1.2.2 bouyer {
673 1.1.2.2 bouyer /* 0b01 -- break on data write only */
674 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
675 1.1.2.2 bouyer
676 1.1.2.2 bouyer dbregs_trap_variable(2, 1, 3, true);
677 1.1.2.2 bouyer }
678 1.1.2.2 bouyer
679 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_writeonly_4bytes);
680 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_writeonly_4bytes, tc)
681 1.1.2.2 bouyer {
682 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
683 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
684 1.1.2.2 bouyer "(break on data writes only and 4 bytes mode)");
685 1.1.2.2 bouyer }
686 1.1.2.2 bouyer
687 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_writeonly_4bytes, tc)
688 1.1.2.2 bouyer {
689 1.1.2.2 bouyer /* 0b01 -- break on data write only */
690 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
691 1.1.2.2 bouyer
692 1.1.2.2 bouyer dbregs_trap_variable(3, 1, 3, true);
693 1.1.2.2 bouyer }
694 1.1.2.2 bouyer
695 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_readwrite_write_byte);
696 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_readwrite_write_byte, tc)
697 1.1.2.2 bouyer {
698 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
699 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
700 1.1.2.2 bouyer "(break on data read/write trap in read 1 byte mode)");
701 1.1.2.2 bouyer }
702 1.1.2.2 bouyer
703 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_readwrite_write_byte, tc)
704 1.1.2.2 bouyer {
705 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
706 1.1.2.2 bouyer /* 0b00 -- 1 byte */
707 1.1.2.2 bouyer
708 1.1.2.2 bouyer dbregs_trap_variable(0, 3, 0, true);
709 1.1.2.2 bouyer }
710 1.1.2.2 bouyer
711 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_readwrite_write_byte);
712 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_readwrite_write_byte, tc)
713 1.1.2.2 bouyer {
714 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
715 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
716 1.1.2.2 bouyer "(break on data read/write trap in read 1 byte mode)");
717 1.1.2.2 bouyer }
718 1.1.2.2 bouyer
719 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_readwrite_write_byte, tc)
720 1.1.2.2 bouyer {
721 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
722 1.1.2.2 bouyer /* 0b00 -- 1 byte */
723 1.1.2.2 bouyer
724 1.1.2.2 bouyer dbregs_trap_variable(1, 3, 0, true);
725 1.1.2.2 bouyer }
726 1.1.2.2 bouyer
727 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_readwrite_write_byte);
728 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_readwrite_write_byte, tc)
729 1.1.2.2 bouyer {
730 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
731 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
732 1.1.2.2 bouyer "(break on data read/write trap in read 1 byte mode)");
733 1.1.2.2 bouyer }
734 1.1.2.2 bouyer
735 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_readwrite_write_byte, tc)
736 1.1.2.2 bouyer {
737 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
738 1.1.2.2 bouyer /* 0b00 -- 1 byte */
739 1.1.2.2 bouyer
740 1.1.2.2 bouyer dbregs_trap_variable(2, 3, 0, true);
741 1.1.2.2 bouyer }
742 1.1.2.2 bouyer
743 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_readwrite_write_byte);
744 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_readwrite_write_byte, tc)
745 1.1.2.2 bouyer {
746 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
747 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
748 1.1.2.2 bouyer "(break on data read/write trap in read 1 byte mode)");
749 1.1.2.2 bouyer }
750 1.1.2.2 bouyer
751 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_readwrite_write_byte, tc)
752 1.1.2.2 bouyer {
753 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
754 1.1.2.2 bouyer /* 0b00 -- 1 byte */
755 1.1.2.2 bouyer
756 1.1.2.2 bouyer dbregs_trap_variable(3, 3, 0, true);
757 1.1.2.2 bouyer }
758 1.1.2.2 bouyer
759 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_readwrite_write_2bytes);
760 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_readwrite_write_2bytes, tc)
761 1.1.2.2 bouyer {
762 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
763 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
764 1.1.2.2 bouyer "(break on data read/write trap in read 2 bytes mode)");
765 1.1.2.2 bouyer }
766 1.1.2.2 bouyer
767 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_readwrite_write_2bytes, tc)
768 1.1.2.2 bouyer {
769 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
770 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
771 1.1.2.2 bouyer
772 1.1.2.2 bouyer dbregs_trap_variable(0, 3, 1, true);
773 1.1.2.2 bouyer }
774 1.1.2.2 bouyer
775 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_readwrite_write_2bytes);
776 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_readwrite_write_2bytes, tc)
777 1.1.2.2 bouyer {
778 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
779 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
780 1.1.2.2 bouyer "(break on data read/write trap in read 2 bytes mode)");
781 1.1.2.2 bouyer }
782 1.1.2.2 bouyer
783 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_readwrite_write_2bytes, tc)
784 1.1.2.2 bouyer {
785 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
786 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
787 1.1.2.2 bouyer
788 1.1.2.2 bouyer dbregs_trap_variable(1, 3, 1, true);
789 1.1.2.2 bouyer }
790 1.1.2.2 bouyer
791 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_readwrite_write_2bytes);
792 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_readwrite_write_2bytes, tc)
793 1.1.2.2 bouyer {
794 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
795 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
796 1.1.2.2 bouyer "(break on data read/write trap in read 2 bytes mode)");
797 1.1.2.2 bouyer }
798 1.1.2.2 bouyer
799 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_readwrite_write_2bytes, tc)
800 1.1.2.2 bouyer {
801 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
802 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
803 1.1.2.2 bouyer
804 1.1.2.2 bouyer dbregs_trap_variable(2, 3, 1, true);
805 1.1.2.2 bouyer }
806 1.1.2.2 bouyer
807 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_readwrite_write_2bytes);
808 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_readwrite_write_2bytes, tc)
809 1.1.2.2 bouyer {
810 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
811 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
812 1.1.2.2 bouyer "(break on data read/write trap in read 2 bytes mode)");
813 1.1.2.2 bouyer }
814 1.1.2.2 bouyer
815 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_readwrite_write_2bytes, tc)
816 1.1.2.2 bouyer {
817 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
818 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
819 1.1.2.2 bouyer
820 1.1.2.2 bouyer dbregs_trap_variable(3, 3, 1, true);
821 1.1.2.2 bouyer }
822 1.1.2.2 bouyer
823 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_readwrite_write_4bytes);
824 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_readwrite_write_4bytes, tc)
825 1.1.2.2 bouyer {
826 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
827 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
828 1.1.2.2 bouyer "(break on data read/write trap in read 4 bytes mode)");
829 1.1.2.2 bouyer }
830 1.1.2.2 bouyer
831 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_readwrite_write_4bytes, tc)
832 1.1.2.2 bouyer {
833 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
834 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
835 1.1.2.2 bouyer
836 1.1.2.2 bouyer dbregs_trap_variable(0, 3, 3, true);
837 1.1.2.2 bouyer }
838 1.1.2.2 bouyer
839 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_readwrite_write_4bytes);
840 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_readwrite_write_4bytes, tc)
841 1.1.2.2 bouyer {
842 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
843 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
844 1.1.2.2 bouyer "(break on data read/write trap in read 4 bytes mode)");
845 1.1.2.2 bouyer }
846 1.1.2.2 bouyer
847 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_readwrite_write_4bytes, tc)
848 1.1.2.2 bouyer {
849 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
850 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
851 1.1.2.2 bouyer
852 1.1.2.2 bouyer dbregs_trap_variable(1, 3, 3, true);
853 1.1.2.2 bouyer }
854 1.1.2.2 bouyer
855 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_readwrite_write_4bytes);
856 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_readwrite_write_4bytes, tc)
857 1.1.2.2 bouyer {
858 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
859 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
860 1.1.2.2 bouyer "(break on data read/write trap in read 4 bytes mode)");
861 1.1.2.2 bouyer }
862 1.1.2.2 bouyer
863 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_readwrite_write_4bytes, tc)
864 1.1.2.2 bouyer {
865 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
866 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
867 1.1.2.2 bouyer
868 1.1.2.2 bouyer dbregs_trap_variable(2, 3, 3, true);
869 1.1.2.2 bouyer }
870 1.1.2.2 bouyer
871 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_readwrite_write_4bytes);
872 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_readwrite_write_4bytes, tc)
873 1.1.2.2 bouyer {
874 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
875 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
876 1.1.2.2 bouyer "(break on data read/write trap in read 4 bytes mode)");
877 1.1.2.2 bouyer }
878 1.1.2.2 bouyer
879 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_readwrite_write_4bytes, tc)
880 1.1.2.2 bouyer {
881 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
882 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
883 1.1.2.2 bouyer
884 1.1.2.2 bouyer dbregs_trap_variable(3, 3, 3, true);
885 1.1.2.2 bouyer }
886 1.1.2.2 bouyer
887 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_readwrite_read_byte);
888 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_readwrite_read_byte, tc)
889 1.1.2.2 bouyer {
890 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
891 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
892 1.1.2.2 bouyer "(break on data read/write trap in write 1 byte mode)");
893 1.1.2.2 bouyer }
894 1.1.2.2 bouyer
895 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_readwrite_read_byte, tc)
896 1.1.2.2 bouyer {
897 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
898 1.1.2.2 bouyer /* 0b00 -- 1 byte */
899 1.1.2.2 bouyer
900 1.1.2.2 bouyer dbregs_trap_variable(0, 3, 0, false);
901 1.1.2.2 bouyer }
902 1.1.2.2 bouyer
903 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_readwrite_read_byte);
904 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_readwrite_read_byte, tc)
905 1.1.2.2 bouyer {
906 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
907 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
908 1.1.2.2 bouyer "(break on data read/write trap in write 1 byte mode)");
909 1.1.2.2 bouyer }
910 1.1.2.2 bouyer
911 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_readwrite_read_byte, tc)
912 1.1.2.2 bouyer {
913 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
914 1.1.2.2 bouyer /* 0b00 -- 1 byte */
915 1.1.2.2 bouyer
916 1.1.2.2 bouyer dbregs_trap_variable(1, 3, 0, false);
917 1.1.2.2 bouyer }
918 1.1.2.2 bouyer
919 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_readwrite_read_byte);
920 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_readwrite_read_byte, tc)
921 1.1.2.2 bouyer {
922 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
923 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
924 1.1.2.2 bouyer "(break on data read/write trap in write 1 byte mode)");
925 1.1.2.2 bouyer }
926 1.1.2.2 bouyer
927 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_readwrite_read_byte, tc)
928 1.1.2.2 bouyer {
929 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
930 1.1.2.2 bouyer /* 0b00 -- 1 byte */
931 1.1.2.2 bouyer
932 1.1.2.2 bouyer dbregs_trap_variable(2, 3, 0, false);
933 1.1.2.2 bouyer }
934 1.1.2.2 bouyer
935 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_readwrite_read_byte);
936 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_readwrite_read_byte, tc)
937 1.1.2.2 bouyer {
938 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
939 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
940 1.1.2.2 bouyer "(break on data read/write trap in write 1 byte mode)");
941 1.1.2.2 bouyer }
942 1.1.2.2 bouyer
943 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_readwrite_read_byte, tc)
944 1.1.2.2 bouyer {
945 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
946 1.1.2.2 bouyer /* 0b00 -- 1 byte */
947 1.1.2.2 bouyer
948 1.1.2.2 bouyer dbregs_trap_variable(3, 3, 0, false);
949 1.1.2.2 bouyer }
950 1.1.2.2 bouyer
951 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_readwrite_read_2bytes);
952 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_readwrite_read_2bytes, tc)
953 1.1.2.2 bouyer {
954 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
955 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
956 1.1.2.2 bouyer "(break on data read/write trap in write 2 bytes mode)");
957 1.1.2.2 bouyer }
958 1.1.2.2 bouyer
959 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_readwrite_read_2bytes, tc)
960 1.1.2.2 bouyer {
961 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
962 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
963 1.1.2.2 bouyer
964 1.1.2.2 bouyer dbregs_trap_variable(0, 3, 1, false);
965 1.1.2.2 bouyer }
966 1.1.2.2 bouyer
967 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_readwrite_read_2bytes);
968 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_readwrite_read_2bytes, tc)
969 1.1.2.2 bouyer {
970 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
971 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
972 1.1.2.2 bouyer "(break on data read/write trap in write 2 bytes mode)");
973 1.1.2.2 bouyer }
974 1.1.2.2 bouyer
975 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_readwrite_read_2bytes, tc)
976 1.1.2.2 bouyer {
977 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
978 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
979 1.1.2.2 bouyer
980 1.1.2.2 bouyer dbregs_trap_variable(1, 3, 1, false);
981 1.1.2.2 bouyer }
982 1.1.2.2 bouyer
983 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_readwrite_read_2bytes);
984 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_readwrite_read_2bytes, tc)
985 1.1.2.2 bouyer {
986 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
987 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
988 1.1.2.2 bouyer "(break on data read/write trap in write 2 bytes mode)");
989 1.1.2.2 bouyer }
990 1.1.2.2 bouyer
991 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_readwrite_read_2bytes, tc)
992 1.1.2.2 bouyer {
993 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
994 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
995 1.1.2.2 bouyer
996 1.1.2.2 bouyer dbregs_trap_variable(2, 3, 1, false);
997 1.1.2.2 bouyer }
998 1.1.2.2 bouyer
999 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_readwrite_read_2bytes);
1000 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_readwrite_read_2bytes, tc)
1001 1.1.2.2 bouyer {
1002 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1003 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
1004 1.1.2.2 bouyer "(break on data read/write trap in write 2 bytes mode)");
1005 1.1.2.2 bouyer }
1006 1.1.2.2 bouyer
1007 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_readwrite_read_2bytes, tc)
1008 1.1.2.2 bouyer {
1009 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
1010 1.1.2.2 bouyer /* 0b01 -- 2 bytes */
1011 1.1.2.2 bouyer
1012 1.1.2.2 bouyer dbregs_trap_variable(3, 3, 1, false);
1013 1.1.2.2 bouyer }
1014 1.1.2.2 bouyer
1015 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_variable_readwrite_read_4bytes);
1016 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_variable_readwrite_read_4bytes, tc)
1017 1.1.2.2 bouyer {
1018 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1019 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
1020 1.1.2.2 bouyer "(break on data read/write trap in write 4 bytes mode)");
1021 1.1.2.2 bouyer }
1022 1.1.2.2 bouyer
1023 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_variable_readwrite_read_4bytes, tc)
1024 1.1.2.2 bouyer {
1025 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
1026 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
1027 1.1.2.2 bouyer
1028 1.1.2.2 bouyer dbregs_trap_variable(0, 3, 3, false);
1029 1.1.2.2 bouyer }
1030 1.1.2.2 bouyer
1031 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_variable_readwrite_read_4bytes);
1032 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_variable_readwrite_read_4bytes, tc)
1033 1.1.2.2 bouyer {
1034 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1035 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
1036 1.1.2.2 bouyer "(break on data read/write trap in write 4 bytes mode)");
1037 1.1.2.2 bouyer }
1038 1.1.2.2 bouyer
1039 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_variable_readwrite_read_4bytes, tc)
1040 1.1.2.2 bouyer {
1041 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
1042 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
1043 1.1.2.2 bouyer
1044 1.1.2.2 bouyer dbregs_trap_variable(1, 3, 3, false);
1045 1.1.2.2 bouyer }
1046 1.1.2.2 bouyer
1047 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_variable_readwrite_read_4bytes);
1048 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_variable_readwrite_read_4bytes, tc)
1049 1.1.2.2 bouyer {
1050 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1051 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
1052 1.1.2.2 bouyer "(break on data read/write trap in write 4 bytes mode)");
1053 1.1.2.2 bouyer }
1054 1.1.2.2 bouyer
1055 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_variable_readwrite_read_4bytes, tc)
1056 1.1.2.2 bouyer {
1057 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
1058 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
1059 1.1.2.2 bouyer
1060 1.1.2.2 bouyer dbregs_trap_variable(2, 3, 3, false);
1061 1.1.2.2 bouyer }
1062 1.1.2.2 bouyer
1063 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_variable_readwrite_read_4bytes);
1064 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_variable_readwrite_read_4bytes, tc)
1065 1.1.2.2 bouyer {
1066 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1067 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
1068 1.1.2.2 bouyer "(break on data read/write trap in write 4 bytes mode)");
1069 1.1.2.2 bouyer }
1070 1.1.2.2 bouyer
1071 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_variable_readwrite_read_4bytes, tc)
1072 1.1.2.2 bouyer {
1073 1.1.2.2 bouyer /* 0b11 -- break on data write&read */
1074 1.1.2.2 bouyer /* 0b11 -- 4 bytes */
1075 1.1.2.2 bouyer
1076 1.1.2.2 bouyer dbregs_trap_variable(3, 3, 3, false);
1077 1.1.2.2 bouyer }
1078 1.1.2.2 bouyer
1079 1.1.2.2 bouyer #if defined(HAVE_DBREGS)
1080 1.1.2.2 bouyer ATF_TC(dbregs_dr0_trap_code);
1081 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_trap_code, tc)
1082 1.1.2.2 bouyer {
1083 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1084 1.1.2.2 bouyer "Verify that setting trap with DR0 triggers SIGTRAP "
1085 1.1.2.2 bouyer "(break on code execution trap)");
1086 1.1.2.2 bouyer }
1087 1.1.2.2 bouyer
1088 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_trap_code, tc)
1089 1.1.2.2 bouyer {
1090 1.1.2.2 bouyer const int exitval = 5;
1091 1.1.2.2 bouyer const int sigval = SIGSTOP;
1092 1.1.2.2 bouyer pid_t child, wpid;
1093 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
1094 1.1.2.2 bouyer int status;
1095 1.1.2.2 bouyer #endif
1096 1.1.2.2 bouyer struct dbreg r1;
1097 1.1.2.2 bouyer size_t i;
1098 1.1.2.2 bouyer volatile int watchme = 1;
1099 1.1.2.2 bouyer union u dr7;
1100 1.1.2.2 bouyer
1101 1.1.2.2 bouyer struct ptrace_siginfo info;
1102 1.1.2.2 bouyer memset(&info, 0, sizeof(info));
1103 1.1.2.2 bouyer
1104 1.1.2.2 bouyer dr7.raw = 0;
1105 1.1.2.2 bouyer dr7.bits.global_dr0_breakpoint = 1;
1106 1.1.2.2 bouyer dr7.bits.condition_dr0 = 0; /* 0b00 -- break on code execution */
1107 1.1.2.2 bouyer dr7.bits.len_dr0 = 0; /* 0b00 -- 1 byte */
1108 1.1.2.2 bouyer
1109 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
1110 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
1111 1.1.2.2 bouyer if (child == 0) {
1112 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1113 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1114 1.1.2.2 bouyer
1115 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1116 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1117 1.1.2.2 bouyer
1118 1.1.2.2 bouyer printf("check_happy(%d)=%d\n", watchme, check_happy(watchme));
1119 1.1.2.2 bouyer
1120 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1121 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1122 1.1.2.2 bouyer
1123 1.1.2.2 bouyer printf("Before exiting of the child process\n");
1124 1.1.2.2 bouyer _exit(exitval);
1125 1.1.2.2 bouyer }
1126 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1127 1.1.2.2 bouyer
1128 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1129 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1130 1.1.2.2 bouyer
1131 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1132 1.1.2.2 bouyer
1133 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r1)\n");
1134 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
1135 1.1.2.2 bouyer
1136 1.1.2.2 bouyer printf("State of the debug registers (r1):\n");
1137 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1138 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1139 1.1.2.2 bouyer
1140 1.1.2.2 bouyer r1.dr[0] = (long)(intptr_t)check_happy;
1141 1.1.2.2 bouyer printf("Set DR0 (r1.dr[0]) to new value %" PRIxREGISTER "\n",
1142 1.1.2.2 bouyer r1.dr[0]);
1143 1.1.2.2 bouyer
1144 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
1145 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
1146 1.1.2.2 bouyer r1.dr[7]);
1147 1.1.2.2 bouyer
1148 1.1.2.2 bouyer printf("New state of the debug registers (r1):\n");
1149 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1150 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1151 1.1.2.2 bouyer
1152 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1153 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1154 1.1.2.2 bouyer
1155 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
1156 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1157 1.1.2.2 bouyer
1158 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1159 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1160 1.1.2.2 bouyer
1161 1.1.2.2 bouyer validate_status_stopped(status, SIGTRAP);
1162 1.1.2.2 bouyer
1163 1.1.2.2 bouyer printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
1164 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
1165 1.1.2.2 bouyer
1166 1.1.2.2 bouyer printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
1167 1.1.2.2 bouyer printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
1168 1.1.2.2 bouyer info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
1169 1.1.2.2 bouyer info.psi_siginfo.si_errno);
1170 1.1.2.2 bouyer
1171 1.1.2.2 bouyer printf("Before checking siginfo_t\n");
1172 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
1173 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_DBREG);
1174 1.1.2.2 bouyer
1175 1.1.2.2 bouyer printf("Remove code trap from check_happy=%p\n", check_happy);
1176 1.1.2.2 bouyer dr7.bits.global_dr0_breakpoint = 0;
1177 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
1178 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
1179 1.1.2.2 bouyer r1.dr[7]);
1180 1.1.2.2 bouyer
1181 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1182 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1183 1.1.2.2 bouyer
1184 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
1185 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1186 1.1.2.2 bouyer
1187 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1188 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1189 1.1.2.2 bouyer
1190 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1191 1.1.2.2 bouyer
1192 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
1193 1.1.2.2 bouyer "without signal to be sent\n");
1194 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1195 1.1.2.2 bouyer
1196 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1197 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1198 1.1.2.2 bouyer
1199 1.1.2.2 bouyer validate_status_exited(status, exitval);
1200 1.1.2.2 bouyer
1201 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1202 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1203 1.1.2.2 bouyer }
1204 1.1.2.2 bouyer #endif
1205 1.1.2.2 bouyer
1206 1.1.2.2 bouyer #if defined(HAVE_DBREGS)
1207 1.1.2.2 bouyer ATF_TC(dbregs_dr1_trap_code);
1208 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_trap_code, tc)
1209 1.1.2.2 bouyer {
1210 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1211 1.1.2.2 bouyer "Verify that setting trap with DR1 triggers SIGTRAP "
1212 1.1.2.2 bouyer "(break on code execution trap)");
1213 1.1.2.2 bouyer }
1214 1.1.2.2 bouyer
1215 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_trap_code, tc)
1216 1.1.2.2 bouyer {
1217 1.1.2.2 bouyer const int exitval = 5;
1218 1.1.2.2 bouyer const int sigval = SIGSTOP;
1219 1.1.2.2 bouyer pid_t child, wpid;
1220 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
1221 1.1.2.2 bouyer int status;
1222 1.1.2.2 bouyer #endif
1223 1.1.2.2 bouyer struct dbreg r1;
1224 1.1.2.2 bouyer size_t i;
1225 1.1.2.2 bouyer volatile int watchme = 1;
1226 1.1.2.2 bouyer union u dr7;
1227 1.1.2.2 bouyer
1228 1.1.2.2 bouyer struct ptrace_siginfo info;
1229 1.1.2.2 bouyer memset(&info, 0, sizeof(info));
1230 1.1.2.2 bouyer
1231 1.1.2.2 bouyer dr7.raw = 0;
1232 1.1.2.2 bouyer dr7.bits.global_dr1_breakpoint = 1;
1233 1.1.2.2 bouyer dr7.bits.condition_dr1 = 0; /* 0b00 -- break on code execution */
1234 1.1.2.2 bouyer dr7.bits.len_dr1 = 0; /* 0b00 -- 1 byte */
1235 1.1.2.2 bouyer
1236 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
1237 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
1238 1.1.2.2 bouyer if (child == 0) {
1239 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1240 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1241 1.1.2.2 bouyer
1242 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1243 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1244 1.1.2.2 bouyer
1245 1.1.2.2 bouyer printf("check_happy(%d)=%d\n", watchme, check_happy(watchme));
1246 1.1.2.2 bouyer
1247 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1248 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1249 1.1.2.2 bouyer
1250 1.1.2.2 bouyer printf("Before exiting of the child process\n");
1251 1.1.2.2 bouyer _exit(exitval);
1252 1.1.2.2 bouyer }
1253 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1254 1.1.2.2 bouyer
1255 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1256 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1257 1.1.2.2 bouyer
1258 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1259 1.1.2.2 bouyer
1260 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r1)\n");
1261 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
1262 1.1.2.2 bouyer
1263 1.1.2.2 bouyer printf("State of the debug registers (r1):\n");
1264 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1265 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1266 1.1.2.2 bouyer
1267 1.1.2.2 bouyer r1.dr[1] = (long)(intptr_t)check_happy;
1268 1.1.2.2 bouyer printf("Set DR1 (r1.dr[1]) to new value %" PRIxREGISTER "\n",
1269 1.1.2.2 bouyer r1.dr[1]);
1270 1.1.2.2 bouyer
1271 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
1272 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
1273 1.1.2.2 bouyer r1.dr[7]);
1274 1.1.2.2 bouyer
1275 1.1.2.2 bouyer printf("New state of the debug registers (r1):\n");
1276 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1277 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1278 1.1.2.2 bouyer
1279 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1280 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1281 1.1.2.2 bouyer
1282 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
1283 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1284 1.1.2.2 bouyer
1285 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1286 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1287 1.1.2.2 bouyer
1288 1.1.2.2 bouyer validate_status_stopped(status, SIGTRAP);
1289 1.1.2.2 bouyer
1290 1.1.2.2 bouyer printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
1291 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
1292 1.1.2.2 bouyer
1293 1.1.2.2 bouyer printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
1294 1.1.2.2 bouyer printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
1295 1.1.2.2 bouyer info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
1296 1.1.2.2 bouyer info.psi_siginfo.si_errno);
1297 1.1.2.2 bouyer
1298 1.1.2.2 bouyer printf("Before checking siginfo_t\n");
1299 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
1300 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_DBREG);
1301 1.1.2.2 bouyer
1302 1.1.2.2 bouyer printf("Remove code trap from check_happy=%p\n", check_happy);
1303 1.1.2.2 bouyer dr7.bits.global_dr1_breakpoint = 0;
1304 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
1305 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
1306 1.1.2.2 bouyer r1.dr[7]);
1307 1.1.2.2 bouyer
1308 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1309 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1310 1.1.2.2 bouyer
1311 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
1312 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1313 1.1.2.2 bouyer
1314 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1315 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1316 1.1.2.2 bouyer
1317 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1318 1.1.2.2 bouyer
1319 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
1320 1.1.2.2 bouyer "without signal to be sent\n");
1321 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1322 1.1.2.2 bouyer
1323 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1324 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1325 1.1.2.2 bouyer
1326 1.1.2.2 bouyer validate_status_exited(status, exitval);
1327 1.1.2.2 bouyer
1328 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1329 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1330 1.1.2.2 bouyer }
1331 1.1.2.2 bouyer #endif
1332 1.1.2.2 bouyer
1333 1.1.2.2 bouyer #if defined(HAVE_DBREGS)
1334 1.1.2.2 bouyer ATF_TC(dbregs_dr2_trap_code);
1335 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_trap_code, tc)
1336 1.1.2.2 bouyer {
1337 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1338 1.1.2.2 bouyer "Verify that setting trap with DR2 triggers SIGTRAP "
1339 1.1.2.2 bouyer "(break on code execution trap)");
1340 1.1.2.2 bouyer }
1341 1.1.2.2 bouyer
1342 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_trap_code, tc)
1343 1.1.2.2 bouyer {
1344 1.1.2.2 bouyer const int exitval = 5;
1345 1.1.2.2 bouyer const int sigval = SIGSTOP;
1346 1.1.2.2 bouyer pid_t child, wpid;
1347 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
1348 1.1.2.2 bouyer int status;
1349 1.1.2.2 bouyer #endif
1350 1.1.2.2 bouyer struct dbreg r1;
1351 1.1.2.2 bouyer size_t i;
1352 1.1.2.2 bouyer volatile int watchme = 1;
1353 1.1.2.2 bouyer union u dr7;
1354 1.1.2.2 bouyer
1355 1.1.2.2 bouyer struct ptrace_siginfo info;
1356 1.1.2.2 bouyer memset(&info, 0, sizeof(info));
1357 1.1.2.2 bouyer
1358 1.1.2.2 bouyer dr7.raw = 0;
1359 1.1.2.2 bouyer dr7.bits.global_dr2_breakpoint = 1;
1360 1.1.2.2 bouyer dr7.bits.condition_dr2 = 0; /* 0b00 -- break on code execution */
1361 1.1.2.2 bouyer dr7.bits.len_dr2 = 0; /* 0b00 -- 1 byte */
1362 1.1.2.2 bouyer
1363 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
1364 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
1365 1.1.2.2 bouyer if (child == 0) {
1366 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1367 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1368 1.1.2.2 bouyer
1369 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1370 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1371 1.1.2.2 bouyer
1372 1.1.2.2 bouyer printf("check_happy(%d)=%d\n", watchme, check_happy(watchme));
1373 1.1.2.2 bouyer
1374 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1375 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1376 1.1.2.2 bouyer
1377 1.1.2.2 bouyer printf("Before exiting of the child process\n");
1378 1.1.2.2 bouyer _exit(exitval);
1379 1.1.2.2 bouyer }
1380 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1381 1.1.2.2 bouyer
1382 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1383 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1384 1.1.2.2 bouyer
1385 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1386 1.1.2.2 bouyer
1387 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r1)\n");
1388 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
1389 1.1.2.2 bouyer
1390 1.1.2.2 bouyer printf("State of the debug registers (r1):\n");
1391 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1392 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1393 1.1.2.2 bouyer
1394 1.1.2.2 bouyer r1.dr[2] = (long)(intptr_t)check_happy;
1395 1.1.2.2 bouyer printf("Set DR2 (r1.dr[2]) to new value %" PRIxREGISTER "\n",
1396 1.1.2.2 bouyer r1.dr[2]);
1397 1.1.2.2 bouyer
1398 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
1399 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
1400 1.1.2.2 bouyer r1.dr[7]);
1401 1.1.2.2 bouyer
1402 1.1.2.2 bouyer printf("New state of the debug registers (r1):\n");
1403 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1404 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1405 1.1.2.2 bouyer
1406 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1407 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1408 1.1.2.2 bouyer
1409 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
1410 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1411 1.1.2.2 bouyer
1412 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1413 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1414 1.1.2.2 bouyer
1415 1.1.2.2 bouyer validate_status_stopped(status, SIGTRAP);
1416 1.1.2.2 bouyer
1417 1.1.2.2 bouyer printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
1418 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
1419 1.1.2.2 bouyer
1420 1.1.2.2 bouyer printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
1421 1.1.2.2 bouyer printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
1422 1.1.2.2 bouyer info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
1423 1.1.2.2 bouyer info.psi_siginfo.si_errno);
1424 1.1.2.2 bouyer
1425 1.1.2.2 bouyer printf("Before checking siginfo_t\n");
1426 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
1427 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_DBREG);
1428 1.1.2.2 bouyer
1429 1.1.2.2 bouyer printf("Remove code trap from check_happy=%p\n", check_happy);
1430 1.1.2.2 bouyer dr7.bits.global_dr2_breakpoint = 0;
1431 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
1432 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
1433 1.1.2.2 bouyer r1.dr[7]);
1434 1.1.2.2 bouyer
1435 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1436 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1437 1.1.2.2 bouyer
1438 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
1439 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1440 1.1.2.2 bouyer
1441 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1442 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1443 1.1.2.2 bouyer
1444 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1445 1.1.2.2 bouyer
1446 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
1447 1.1.2.2 bouyer "without signal to be sent\n");
1448 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1449 1.1.2.2 bouyer
1450 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1451 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1452 1.1.2.2 bouyer
1453 1.1.2.2 bouyer validate_status_exited(status, exitval);
1454 1.1.2.2 bouyer
1455 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1456 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1457 1.1.2.2 bouyer }
1458 1.1.2.2 bouyer #endif
1459 1.1.2.2 bouyer
1460 1.1.2.2 bouyer #if defined(HAVE_DBREGS)
1461 1.1.2.2 bouyer ATF_TC(dbregs_dr3_trap_code);
1462 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_trap_code, tc)
1463 1.1.2.2 bouyer {
1464 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1465 1.1.2.2 bouyer "Verify that setting trap with DR3 triggers SIGTRAP "
1466 1.1.2.2 bouyer "(break on code execution trap)");
1467 1.1.2.2 bouyer }
1468 1.1.2.2 bouyer
1469 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_trap_code, tc)
1470 1.1.2.2 bouyer {
1471 1.1.2.2 bouyer const int exitval = 5;
1472 1.1.2.2 bouyer const int sigval = SIGSTOP;
1473 1.1.2.2 bouyer pid_t child, wpid;
1474 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
1475 1.1.2.2 bouyer int status;
1476 1.1.2.2 bouyer #endif
1477 1.1.2.2 bouyer struct dbreg r1;
1478 1.1.2.2 bouyer size_t i;
1479 1.1.2.2 bouyer volatile int watchme = 1;
1480 1.1.2.2 bouyer union u dr7;
1481 1.1.2.2 bouyer
1482 1.1.2.2 bouyer struct ptrace_siginfo info;
1483 1.1.2.2 bouyer memset(&info, 0, sizeof(info));
1484 1.1.2.2 bouyer
1485 1.1.2.2 bouyer dr7.raw = 0;
1486 1.1.2.2 bouyer dr7.bits.global_dr3_breakpoint = 1;
1487 1.1.2.2 bouyer dr7.bits.condition_dr3 = 0; /* 0b00 -- break on code execution */
1488 1.1.2.2 bouyer dr7.bits.len_dr3 = 0; /* 0b00 -- 1 byte */
1489 1.1.2.2 bouyer
1490 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
1491 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
1492 1.1.2.2 bouyer if (child == 0) {
1493 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1494 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1495 1.1.2.2 bouyer
1496 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1497 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1498 1.1.2.2 bouyer
1499 1.1.2.2 bouyer printf("check_happy(%d)=%d\n", watchme, check_happy(watchme));
1500 1.1.2.2 bouyer
1501 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1502 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1503 1.1.2.2 bouyer
1504 1.1.2.2 bouyer printf("Before exiting of the child process\n");
1505 1.1.2.2 bouyer _exit(exitval);
1506 1.1.2.2 bouyer }
1507 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1508 1.1.2.2 bouyer
1509 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1510 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1511 1.1.2.2 bouyer
1512 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1513 1.1.2.2 bouyer
1514 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r1)\n");
1515 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
1516 1.1.2.2 bouyer
1517 1.1.2.2 bouyer printf("State of the debug registers (r1):\n");
1518 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1519 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1520 1.1.2.2 bouyer
1521 1.1.2.2 bouyer r1.dr[3] = (long)(intptr_t)check_happy;
1522 1.1.2.2 bouyer printf("Set DR3 (r1.dr[3]) to new value %" PRIxREGISTER "\n",
1523 1.1.2.2 bouyer r1.dr[3]);
1524 1.1.2.2 bouyer
1525 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
1526 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
1527 1.1.2.2 bouyer r1.dr[7]);
1528 1.1.2.2 bouyer
1529 1.1.2.2 bouyer printf("New state of the debug registers (r1):\n");
1530 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1531 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1532 1.1.2.2 bouyer
1533 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1534 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1535 1.1.2.2 bouyer
1536 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
1537 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1538 1.1.2.2 bouyer
1539 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1540 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1541 1.1.2.2 bouyer
1542 1.1.2.2 bouyer validate_status_stopped(status, SIGTRAP);
1543 1.1.2.2 bouyer
1544 1.1.2.2 bouyer printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
1545 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
1546 1.1.2.2 bouyer
1547 1.1.2.2 bouyer printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
1548 1.1.2.2 bouyer printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
1549 1.1.2.2 bouyer info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
1550 1.1.2.2 bouyer info.psi_siginfo.si_errno);
1551 1.1.2.2 bouyer
1552 1.1.2.2 bouyer printf("Before checking siginfo_t\n");
1553 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
1554 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_DBREG);
1555 1.1.2.2 bouyer
1556 1.1.2.2 bouyer printf("Remove code trap from check_happy=%p\n", check_happy);
1557 1.1.2.2 bouyer dr7.bits.global_dr3_breakpoint = 0;
1558 1.1.2.2 bouyer r1.dr[7] = dr7.raw;
1559 1.1.2.2 bouyer printf("Set DR7 (r1.dr[7]) to new value %" PRIxREGISTER "\n",
1560 1.1.2.2 bouyer r1.dr[7]);
1561 1.1.2.2 bouyer
1562 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1563 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1564 1.1.2.2 bouyer
1565 1.1.2.2 bouyer printf("Call CONTINUE for the child process\n");
1566 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1567 1.1.2.2 bouyer
1568 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1569 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1570 1.1.2.2 bouyer
1571 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1572 1.1.2.2 bouyer
1573 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
1574 1.1.2.2 bouyer "without signal to be sent\n");
1575 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1576 1.1.2.2 bouyer
1577 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1578 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1579 1.1.2.2 bouyer
1580 1.1.2.2 bouyer validate_status_exited(status, exitval);
1581 1.1.2.2 bouyer
1582 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1583 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1584 1.1.2.2 bouyer }
1585 1.1.2.2 bouyer #endif
1586 1.1.2.2 bouyer
1587 1.1.2.2 bouyer volatile lwpid_t x86_the_lwp_id = 0;
1588 1.1.2.2 bouyer
1589 1.1.2.2 bouyer static void __used
1590 1.1.2.2 bouyer x86_lwp_main_func(void *arg)
1591 1.1.2.2 bouyer {
1592 1.1.2.2 bouyer x86_the_lwp_id = _lwp_self();
1593 1.1.2.2 bouyer _lwp_exit();
1594 1.1.2.2 bouyer }
1595 1.1.2.2 bouyer
1596 1.1.2.2 bouyer static void
1597 1.1.2.2 bouyer dbregs_dont_inherit_lwp(int reg)
1598 1.1.2.2 bouyer {
1599 1.1.2.2 bouyer const int exitval = 5;
1600 1.1.2.2 bouyer const int sigval = SIGSTOP;
1601 1.1.2.2 bouyer pid_t child, wpid;
1602 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
1603 1.1.2.2 bouyer int status;
1604 1.1.2.2 bouyer #endif
1605 1.1.2.2 bouyer ptrace_state_t state;
1606 1.1.2.2 bouyer const int slen = sizeof(state);
1607 1.1.2.2 bouyer ptrace_event_t event;
1608 1.1.2.2 bouyer const int elen = sizeof(event);
1609 1.1.2.2 bouyer ucontext_t uc;
1610 1.1.2.2 bouyer lwpid_t lid;
1611 1.1.2.2 bouyer static const size_t ssize = 16*1024;
1612 1.1.2.2 bouyer void *stack;
1613 1.1.2.2 bouyer size_t i;
1614 1.1.2.2 bouyer struct dbreg r1;
1615 1.1.2.2 bouyer struct dbreg r2;
1616 1.1.2.2 bouyer
1617 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
1618 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
1619 1.1.2.2 bouyer if (child == 0) {
1620 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1621 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1622 1.1.2.2 bouyer
1623 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1624 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1625 1.1.2.2 bouyer
1626 1.1.2.2 bouyer printf("Before allocating memory for stack in child\n");
1627 1.1.2.2 bouyer FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
1628 1.1.2.2 bouyer
1629 1.1.2.2 bouyer printf("Before making context for new lwp in child\n");
1630 1.1.2.2 bouyer _lwp_makecontext(&uc, x86_lwp_main_func, NULL, NULL, stack,
1631 1.1.2.2 bouyer ssize);
1632 1.1.2.2 bouyer
1633 1.1.2.2 bouyer printf("Before creating new in child\n");
1634 1.1.2.2 bouyer FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
1635 1.1.2.2 bouyer
1636 1.1.2.2 bouyer printf("Before waiting for lwp %d to exit\n", lid);
1637 1.1.2.2 bouyer FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
1638 1.1.2.2 bouyer
1639 1.1.2.2 bouyer printf("Before verifying that reported %d and running lid %d "
1640 1.1.2.2 bouyer "are the same\n", lid, x86_the_lwp_id);
1641 1.1.2.2 bouyer FORKEE_ASSERT_EQ(lid, x86_the_lwp_id);
1642 1.1.2.2 bouyer
1643 1.1.2.2 bouyer printf("Before exiting of the child process\n");
1644 1.1.2.2 bouyer _exit(exitval);
1645 1.1.2.2 bouyer }
1646 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1647 1.1.2.2 bouyer
1648 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1649 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1650 1.1.2.2 bouyer
1651 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1652 1.1.2.2 bouyer
1653 1.1.2.2 bouyer printf("Set empty EVENT_MASK for the child %d\n", child);
1654 1.1.2.2 bouyer event.pe_set_event = PTRACE_LWP_CREATE;
1655 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
1656 1.1.2.2 bouyer
1657 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r1)\n");
1658 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
1659 1.1.2.2 bouyer
1660 1.1.2.2 bouyer printf("State of the debug registers (r1):\n");
1661 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1662 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1663 1.1.2.2 bouyer
1664 1.1.2.2 bouyer r1.dr[reg] = (long)(intptr_t)check_happy;
1665 1.1.2.2 bouyer printf("Set DR%d (r1.dr[%d]) to new value %" PRIxREGISTER "\n",
1666 1.1.2.2 bouyer reg, reg, r1.dr[0]);
1667 1.1.2.2 bouyer
1668 1.1.2.2 bouyer printf("New state of the debug registers (r1):\n");
1669 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1670 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1671 1.1.2.2 bouyer
1672 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1673 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1674 1.1.2.2 bouyer
1675 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
1676 1.1.2.2 bouyer "without signal to be sent\n");
1677 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1678 1.1.2.2 bouyer
1679 1.1.2.2 bouyer printf("Before calling %s() for the child - expected stopped "
1680 1.1.2.2 bouyer "SIGTRAP\n", TWAIT_FNAME);
1681 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1682 1.1.2.2 bouyer
1683 1.1.2.2 bouyer validate_status_stopped(status, SIGTRAP);
1684 1.1.2.2 bouyer
1685 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
1686 1.1.2.2 bouyer
1687 1.1.2.2 bouyer ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_CREATE);
1688 1.1.2.2 bouyer
1689 1.1.2.2 bouyer lid = state.pe_lwp;
1690 1.1.2.2 bouyer printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
1691 1.1.2.2 bouyer
1692 1.1.2.2 bouyer printf("Call GETDBREGS for the child process new lwp (r2)\n");
1693 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, lid) != -1);
1694 1.1.2.2 bouyer
1695 1.1.2.2 bouyer printf("State of the debug registers (r2):\n");
1696 1.1.2.2 bouyer for (i = 0; i < __arraycount(r2.dr); i++)
1697 1.1.2.2 bouyer printf("r2[%zu]=%" PRIxREGISTER "\n", i, r2.dr[i]);
1698 1.1.2.2 bouyer
1699 1.1.2.2 bouyer printf("Assert that (r1) and (r2) are not the same\n");
1700 1.1.2.2 bouyer ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) != 0);
1701 1.1.2.2 bouyer
1702 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
1703 1.1.2.2 bouyer "without signal to be sent\n");
1704 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1705 1.1.2.2 bouyer
1706 1.1.2.2 bouyer printf("Before calling %s() for the child - expected exited\n",
1707 1.1.2.2 bouyer TWAIT_FNAME);
1708 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1709 1.1.2.2 bouyer
1710 1.1.2.2 bouyer validate_status_exited(status, exitval);
1711 1.1.2.2 bouyer
1712 1.1.2.2 bouyer printf("Before calling %s() for the child - expected no process\n",
1713 1.1.2.2 bouyer TWAIT_FNAME);
1714 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1715 1.1.2.2 bouyer }
1716 1.1.2.2 bouyer
1717 1.1.2.2 bouyer ATF_TC(dbregs_dr0_dont_inherit_lwp);
1718 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_dont_inherit_lwp, tc)
1719 1.1.2.2 bouyer {
1720 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1721 1.1.2.2 bouyer "Verify that 1 LWP creation is intercepted by ptrace(2) with "
1722 1.1.2.2 bouyer "EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 0 from "
1723 1.1.2.2 bouyer "the forker thread is not inherited");
1724 1.1.2.2 bouyer }
1725 1.1.2.2 bouyer
1726 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_dont_inherit_lwp, tc)
1727 1.1.2.2 bouyer {
1728 1.1.2.2 bouyer dbregs_dont_inherit_lwp(0);
1729 1.1.2.2 bouyer }
1730 1.1.2.2 bouyer
1731 1.1.2.2 bouyer ATF_TC(dbregs_dr1_dont_inherit_lwp);
1732 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_dont_inherit_lwp, tc)
1733 1.1.2.2 bouyer {
1734 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1735 1.1.2.2 bouyer "Verify that 1 LWP creation is intercepted by ptrace(2) with "
1736 1.1.2.2 bouyer "EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 1 from "
1737 1.1.2.2 bouyer "the forker thread is not inherited");
1738 1.1.2.2 bouyer }
1739 1.1.2.2 bouyer
1740 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_dont_inherit_lwp, tc)
1741 1.1.2.2 bouyer {
1742 1.1.2.2 bouyer dbregs_dont_inherit_lwp(1);
1743 1.1.2.2 bouyer }
1744 1.1.2.2 bouyer
1745 1.1.2.2 bouyer ATF_TC(dbregs_dr2_dont_inherit_lwp);
1746 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_dont_inherit_lwp, tc)
1747 1.1.2.2 bouyer {
1748 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1749 1.1.2.2 bouyer "Verify that 1 LWP creation is intercepted by ptrace(2) with "
1750 1.1.2.2 bouyer "EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 2 from "
1751 1.1.2.2 bouyer "the forker thread is not inherited");
1752 1.1.2.2 bouyer }
1753 1.1.2.2 bouyer
1754 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_dont_inherit_lwp, tc)
1755 1.1.2.2 bouyer {
1756 1.1.2.2 bouyer dbregs_dont_inherit_lwp(2);
1757 1.1.2.2 bouyer }
1758 1.1.2.2 bouyer
1759 1.1.2.2 bouyer ATF_TC(dbregs_dr3_dont_inherit_lwp);
1760 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_dont_inherit_lwp, tc)
1761 1.1.2.2 bouyer {
1762 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1763 1.1.2.2 bouyer "Verify that 1 LWP creation is intercepted by ptrace(2) with "
1764 1.1.2.2 bouyer "EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 3 from "
1765 1.1.2.2 bouyer "the forker thread is not inherited");
1766 1.1.2.2 bouyer }
1767 1.1.2.2 bouyer
1768 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_dont_inherit_lwp, tc)
1769 1.1.2.2 bouyer {
1770 1.1.2.2 bouyer dbregs_dont_inherit_lwp(3);
1771 1.1.2.2 bouyer }
1772 1.1.2.2 bouyer
1773 1.1.2.2 bouyer static void
1774 1.1.2.2 bouyer dbregs_dont_inherit_execve(int reg)
1775 1.1.2.2 bouyer {
1776 1.1.2.2 bouyer const int sigval = SIGTRAP;
1777 1.1.2.2 bouyer pid_t child, wpid;
1778 1.1.2.2 bouyer #if defined(TWAIT_HAVE_STATUS)
1779 1.1.2.2 bouyer int status;
1780 1.1.2.2 bouyer #endif
1781 1.1.2.2 bouyer size_t i;
1782 1.1.2.2 bouyer struct dbreg r1;
1783 1.1.2.2 bouyer struct dbreg r2;
1784 1.1.2.2 bouyer
1785 1.1.2.2 bouyer struct ptrace_siginfo info;
1786 1.1.2.2 bouyer memset(&info, 0, sizeof(info));
1787 1.1.2.2 bouyer
1788 1.1.2.2 bouyer printf("Before forking process PID=%d\n", getpid());
1789 1.1.2.2 bouyer ATF_REQUIRE((child = fork()) != -1);
1790 1.1.2.2 bouyer if (child == 0) {
1791 1.1.2.2 bouyer printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1792 1.1.2.2 bouyer FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1793 1.1.2.2 bouyer
1794 1.1.2.2 bouyer printf("Before raising %s from child\n", strsignal(sigval));
1795 1.1.2.2 bouyer FORKEE_ASSERT(raise(sigval) == 0);
1796 1.1.2.2 bouyer
1797 1.1.2.2 bouyer printf("Before calling execve(2) from child\n");
1798 1.1.2.2 bouyer execlp("/bin/echo", "/bin/echo", NULL);
1799 1.1.2.2 bouyer
1800 1.1.2.2 bouyer FORKEE_ASSERT(0 && "Not reached");
1801 1.1.2.2 bouyer }
1802 1.1.2.2 bouyer printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1803 1.1.2.2 bouyer
1804 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1805 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1806 1.1.2.2 bouyer
1807 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1808 1.1.2.2 bouyer
1809 1.1.2.2 bouyer printf("Call GETDBREGS for the child process (r1)\n");
1810 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
1811 1.1.2.2 bouyer
1812 1.1.2.2 bouyer printf("State of the debug registers (r1):\n");
1813 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1814 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1815 1.1.2.2 bouyer
1816 1.1.2.2 bouyer r1.dr[reg] = (long)(intptr_t)check_happy;
1817 1.1.2.2 bouyer printf("Set DR%d (r1.dr[%d]) to new value %" PRIxREGISTER "\n",
1818 1.1.2.2 bouyer reg, reg, r1.dr[reg]);
1819 1.1.2.2 bouyer
1820 1.1.2.2 bouyer printf("New state of the debug registers (r1):\n");
1821 1.1.2.2 bouyer for (i = 0; i < __arraycount(r1.dr); i++)
1822 1.1.2.2 bouyer printf("r1[%zu]=%" PRIxREGISTER "\n", i, r1.dr[i]);
1823 1.1.2.2 bouyer
1824 1.1.2.2 bouyer printf("Call SETDBREGS for the child process (r1)\n");
1825 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
1826 1.1.2.2 bouyer
1827 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
1828 1.1.2.2 bouyer "without signal to be sent\n");
1829 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1830 1.1.2.2 bouyer
1831 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1832 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1833 1.1.2.2 bouyer
1834 1.1.2.2 bouyer validate_status_stopped(status, sigval);
1835 1.1.2.2 bouyer
1836 1.1.2.2 bouyer printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
1837 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
1838 1.1.2.2 bouyer
1839 1.1.2.2 bouyer printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
1840 1.1.2.2 bouyer printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
1841 1.1.2.2 bouyer info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
1842 1.1.2.2 bouyer info.psi_siginfo.si_errno);
1843 1.1.2.2 bouyer
1844 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
1845 1.1.2.2 bouyer ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_EXEC);
1846 1.1.2.2 bouyer
1847 1.1.2.2 bouyer printf("Call GETDBREGS for the child process after execve(2)\n");
1848 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
1849 1.1.2.2 bouyer
1850 1.1.2.2 bouyer printf("State of the debug registers (r2):\n");
1851 1.1.2.2 bouyer for (i = 0; i < __arraycount(r2.dr); i++)
1852 1.1.2.2 bouyer printf("r2[%zu]=%" PRIxREGISTER "\n", i, r2.dr[i]);
1853 1.1.2.2 bouyer
1854 1.1.2.2 bouyer printf("Assert that (r1) and (r2) are not the same\n");
1855 1.1.2.2 bouyer ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) != 0);
1856 1.1.2.2 bouyer
1857 1.1.2.2 bouyer printf("Before resuming the child process where it left off and "
1858 1.1.2.2 bouyer "without signal to be sent\n");
1859 1.1.2.2 bouyer ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1860 1.1.2.2 bouyer
1861 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1862 1.1.2.2 bouyer TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1863 1.1.2.2 bouyer
1864 1.1.2.2 bouyer printf("Before calling %s() for the child\n", TWAIT_FNAME);
1865 1.1.2.2 bouyer TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1866 1.1.2.2 bouyer }
1867 1.1.2.2 bouyer
1868 1.1.2.2 bouyer ATF_TC(dbregs_dr0_dont_inherit_execve);
1869 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr0_dont_inherit_execve, tc)
1870 1.1.2.2 bouyer {
1871 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1872 1.1.2.2 bouyer "Verify that execve(2) is intercepted by tracer and Debug "
1873 1.1.2.2 bouyer "Register 0 is reset");
1874 1.1.2.2 bouyer }
1875 1.1.2.2 bouyer
1876 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr0_dont_inherit_execve, tc)
1877 1.1.2.2 bouyer {
1878 1.1.2.2 bouyer dbregs_dont_inherit_execve(0);
1879 1.1.2.2 bouyer }
1880 1.1.2.2 bouyer
1881 1.1.2.2 bouyer ATF_TC(dbregs_dr1_dont_inherit_execve);
1882 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr1_dont_inherit_execve, tc)
1883 1.1.2.2 bouyer {
1884 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1885 1.1.2.2 bouyer "Verify that execve(2) is intercepted by tracer and Debug "
1886 1.1.2.2 bouyer "Register 1 is reset");
1887 1.1.2.2 bouyer }
1888 1.1.2.2 bouyer
1889 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr1_dont_inherit_execve, tc)
1890 1.1.2.2 bouyer {
1891 1.1.2.2 bouyer dbregs_dont_inherit_execve(1);
1892 1.1.2.2 bouyer }
1893 1.1.2.2 bouyer
1894 1.1.2.2 bouyer ATF_TC(dbregs_dr2_dont_inherit_execve);
1895 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr2_dont_inherit_execve, tc)
1896 1.1.2.2 bouyer {
1897 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1898 1.1.2.2 bouyer "Verify that execve(2) is intercepted by tracer and Debug "
1899 1.1.2.2 bouyer "Register 2 is reset");
1900 1.1.2.2 bouyer }
1901 1.1.2.2 bouyer
1902 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr2_dont_inherit_execve, tc)
1903 1.1.2.2 bouyer {
1904 1.1.2.2 bouyer dbregs_dont_inherit_execve(2);
1905 1.1.2.2 bouyer }
1906 1.1.2.2 bouyer
1907 1.1.2.2 bouyer ATF_TC(dbregs_dr3_dont_inherit_execve);
1908 1.1.2.2 bouyer ATF_TC_HEAD(dbregs_dr3_dont_inherit_execve, tc)
1909 1.1.2.2 bouyer {
1910 1.1.2.2 bouyer atf_tc_set_md_var(tc, "descr",
1911 1.1.2.2 bouyer "Verify that execve(2) is intercepted by tracer and Debug "
1912 1.1.2.2 bouyer "Register 3 is reset");
1913 1.1.2.2 bouyer }
1914 1.1.2.2 bouyer
1915 1.1.2.2 bouyer ATF_TC_BODY(dbregs_dr3_dont_inherit_execve, tc)
1916 1.1.2.2 bouyer {
1917 1.1.2.2 bouyer dbregs_dont_inherit_execve(3);
1918 1.1.2.2 bouyer }
1919 1.1.2.2 bouyer #define ATF_TP_ADD_TCS_PTRACE_WAIT_X86() \
1920 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_print); \
1921 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr0); \
1922 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr1); \
1923 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr2); \
1924 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr3); \
1925 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr0_yield); \
1926 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr1_yield); \
1927 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr2_yield); \
1928 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr3_yield); \
1929 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr0_continued); \
1930 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr1_continued); \
1931 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr2_continued); \
1932 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_preserve_dr3_continued); \
1933 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_writeonly_byte); \
1934 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_writeonly_byte); \
1935 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_writeonly_byte); \
1936 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_writeonly_byte); \
1937 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_writeonly_2bytes); \
1938 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_writeonly_2bytes); \
1939 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_writeonly_2bytes); \
1940 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_writeonly_2bytes); \
1941 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_writeonly_4bytes); \
1942 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_writeonly_4bytes); \
1943 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_writeonly_4bytes); \
1944 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_writeonly_4bytes); \
1945 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_readwrite_write_byte); \
1946 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_readwrite_write_byte); \
1947 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_readwrite_write_byte); \
1948 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_readwrite_write_byte); \
1949 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_readwrite_write_2bytes); \
1950 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_readwrite_write_2bytes); \
1951 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_readwrite_write_2bytes); \
1952 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_readwrite_write_2bytes); \
1953 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_readwrite_write_4bytes); \
1954 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_readwrite_write_4bytes); \
1955 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_readwrite_write_4bytes); \
1956 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_readwrite_write_4bytes); \
1957 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_readwrite_read_byte); \
1958 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_readwrite_read_byte); \
1959 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_readwrite_read_byte); \
1960 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_readwrite_read_byte); \
1961 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_readwrite_read_2bytes); \
1962 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_readwrite_read_2bytes); \
1963 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_readwrite_read_2bytes); \
1964 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_readwrite_read_2bytes); \
1965 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_variable_readwrite_read_4bytes); \
1966 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_variable_readwrite_read_4bytes); \
1967 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_variable_readwrite_read_4bytes); \
1968 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_variable_readwrite_read_4bytes); \
1969 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_trap_code); \
1970 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_trap_code); \
1971 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_code); \
1972 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_code); \
1973 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_dont_inherit_lwp); \
1974 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_dont_inherit_lwp); \
1975 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_dont_inherit_lwp); \
1976 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_dont_inherit_lwp); \
1977 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_dont_inherit_execve); \
1978 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_dont_inherit_execve); \
1979 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_dont_inherit_execve); \
1980 1.1.2.2 bouyer ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_dont_inherit_execve);
1981 1.1.2.2 bouyer #else
1982 1.1.2.2 bouyer #define ATF_TP_ADD_TCS_PTRACE_WAIT_X86()
1983 1.1.2.2 bouyer #endif
1984