1 /* $NetBSD: t_ptrace_wait.c,v 1.60 2017/01/14 19:17:10 kamil Exp $ */
4 * Copyright (c) 2016 The NetBSD Foundation, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __RCSID("$NetBSD: t_ptrace_wait.c,v 1.60 2017/01/14 19:17:10 kamil Exp $");
32 #include <sys/param.h>
33 #include <sys/types.h>
34 #include <sys/ptrace.h>
35 #include <sys/resource.h>
37 #include <sys/sysctl.h>
39 #include <machine/reg.h>
54 #include "t_ptrace_wait.h"
57 #define PARENT_TO_CHILD(info, fds, msg) \
58 ATF_REQUIRE(msg_write_child(info " to child " # fds, &fds, &msg, sizeof(msg)) == 0)
60 #define CHILD_FROM_PARENT(info, fds, msg) \
61 FORKEE_ASSERT(msg_read_parent(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0)
63 #define CHILD_TO_PARENT(info, fds, msg) \
64 FORKEE_ASSERT(msg_write_parent(info " to parent " # fds, &fds, &msg, sizeof(msg)) == 0)
66 #define PARENT_FROM_CHILD(info, fds, msg) \
67 ATF_REQUIRE(msg_read_child(info " from parent " # fds, &fds, &msg, sizeof(msg)) == 0)
71 ATF_TC_HEAD(traceme1, tc)
73 atf_tc_set_md_var(tc, "descr",
74 "Verify SIGSTOP followed by _exit(2) in a child");
77 ATF_TC_BODY(traceme1, tc)
79 const int exitval = 5;
80 const int sigval = SIGSTOP;
82 #if defined(TWAIT_HAVE_STATUS)
86 printf("Before forking process PID=%d\n", getpid());
87 ATF_REQUIRE((child = fork()) != -1);
89 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
90 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
92 printf("Before raising %s from child\n", strsignal(sigval));
93 FORKEE_ASSERT(raise(sigval) == 0);
95 printf("Before exiting of the child process\n");
98 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
100 printf("Before calling %s() for the child\n", TWAIT_FNAME);
101 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
103 validate_status_stopped(status, sigval);
105 printf("Before resuming the child process where it left off and "
106 "without signal to be sent\n");
107 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
109 printf("Before calling %s() for the child\n", TWAIT_FNAME);
110 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
112 validate_status_exited(status, exitval);
114 printf("Before calling %s() for the child\n", TWAIT_FNAME);
115 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
119 ATF_TC_HEAD(traceme2, tc)
121 atf_tc_set_md_var(tc, "descr",
122 "Verify SIGSTOP followed by _exit(2) in a child");
125 static int traceme2_caught = 0;
128 traceme2_sighandler(int sig)
130 FORKEE_ASSERT_EQ(sig, SIGINT);
135 ATF_TC_BODY(traceme2, tc)
137 const int exitval = 5;
138 const int sigval = SIGSTOP, sigsent = SIGINT;
141 #if defined(TWAIT_HAVE_STATUS)
145 printf("Before forking process PID=%d\n", getpid());
146 ATF_REQUIRE((child = fork()) != -1);
148 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
149 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
151 sa.sa_handler = traceme2_sighandler;
152 sa.sa_flags = SA_SIGINFO;
153 sigemptyset(&sa.sa_mask);
155 FORKEE_ASSERT(sigaction(sigsent, &sa, NULL) != -1);
157 printf("Before raising %s from child\n", strsignal(sigval));
158 FORKEE_ASSERT(raise(sigval) == 0);
160 FORKEE_ASSERT_EQ(traceme2_caught, 1);
162 printf("Before exiting of the child process\n");
165 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
167 printf("Before calling %s() for the child\n", TWAIT_FNAME);
168 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
170 validate_status_stopped(status, sigval);
172 printf("Before resuming the child process where it left off and with "
173 "signal %s to be sent\n", strsignal(sigsent));
174 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1);
176 printf("Before calling %s() for the child\n", TWAIT_FNAME);
177 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
179 validate_status_exited(status, exitval);
181 printf("Before calling %s() for the exited child\n", TWAIT_FNAME);
182 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
186 ATF_TC_HEAD(traceme3, tc)
188 atf_tc_set_md_var(tc, "descr",
189 "Verify SIGSTOP followed by termination by a signal in a child");
192 ATF_TC_BODY(traceme3, tc)
194 const int sigval = SIGSTOP, sigsent = SIGINT /* Without core-dump */;
196 #if defined(TWAIT_HAVE_STATUS)
200 printf("Before forking process PID=%d\n", getpid());
201 ATF_REQUIRE((child = fork()) != -1);
203 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
204 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
206 printf("Before raising %s from child\n", strsignal(sigval));
207 FORKEE_ASSERT(raise(sigval) == 0);
211 "Child should be terminated by a signal from its parent");
213 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
215 printf("Before calling %s() for the child\n", TWAIT_FNAME);
216 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
218 validate_status_stopped(status, sigval);
220 printf("Before resuming the child process where it left off and with "
221 "signal %s to be sent\n", strsignal(sigsent));
222 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1);
224 printf("Before calling %s() for the child\n", TWAIT_FNAME);
225 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
227 validate_status_signaled(status, sigsent, 0);
229 printf("Before calling %s() for the exited child\n", TWAIT_FNAME);
230 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
234 ATF_TC_HEAD(traceme4, tc)
236 atf_tc_set_md_var(tc, "descr",
237 "Verify SIGSTOP followed by SIGCONT and _exit(2) in a child");
240 ATF_TC_BODY(traceme4, tc)
242 const int exitval = 5;
243 const int sigval = SIGSTOP, sigsent = SIGCONT;
245 #if defined(TWAIT_HAVE_STATUS)
249 printf("Before forking process PID=%d\n", getpid());
250 ATF_REQUIRE((child = fork()) != -1);
252 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
253 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
255 printf("Before raising %s from child\n", strsignal(sigval));
256 FORKEE_ASSERT(raise(sigval) == 0);
258 printf("Before raising %s from child\n", strsignal(sigsent));
259 FORKEE_ASSERT(raise(sigsent) == 0);
261 printf("Before exiting of the child process\n");
264 printf("Parent process PID=%d, child's PID=%d\n", getpid(),child);
266 printf("Before calling %s() for the child\n", TWAIT_FNAME);
267 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
269 validate_status_stopped(status, sigval);
271 printf("Before resuming the child process where it left off and "
272 "without signal to be sent\n");
273 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
275 printf("Before calling %s() for the child\n", TWAIT_FNAME);
276 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
278 validate_status_stopped(status, sigsent);
280 printf("Before resuming the child process where it left off and "
281 "without signal to be sent\n");
282 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
284 printf("Before calling %s() for the child\n", TWAIT_FNAME);
285 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
287 validate_status_exited(status, exitval);
289 printf("Before calling %s() for the exited child\n", TWAIT_FNAME);
290 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
293 #if defined(TWAIT_HAVE_PID)
295 ATF_TC_HEAD(attach1, tc)
297 atf_tc_set_md_var(tc, "descr",
298 "Assert that tracer sees process termination before the parent");
301 ATF_TC_BODY(attach1, tc)
303 struct msg_fds parent_tracee, parent_tracer;
304 const int exitval_tracee = 5;
305 const int exitval_tracer = 10;
306 pid_t tracee, tracer, wpid;
307 uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
308 #if defined(TWAIT_HAVE_STATUS)
312 printf("Spawn tracee\n");
313 ATF_REQUIRE(msg_open(&parent_tracee) == 0);
314 tracee = atf_utils_fork();
316 // Wait for parent to let us exit
317 CHILD_FROM_PARENT("exit tracee", parent_tracee, msg);
318 _exit(exitval_tracee);
321 printf("Spawn debugger\n");
322 ATF_REQUIRE(msg_open(&parent_tracer) == 0);
323 tracer = atf_utils_fork();
325 printf("Before calling PT_ATTACH from tracee %d\n", getpid());
326 FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
328 /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
329 FORKEE_REQUIRE_SUCCESS(
330 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
332 forkee_status_stopped(status, SIGSTOP);
334 /* Resume tracee with PT_CONTINUE */
335 FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
337 /* Inform parent that tracer has attached to tracee */
338 CHILD_TO_PARENT("tracer ready", parent_tracer, msg);
340 /* Wait for parent to tell use that tracee should have exited */
341 CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg);
343 /* Wait for tracee and assert that it exited */
344 FORKEE_REQUIRE_SUCCESS(
345 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
347 forkee_status_exited(status, exitval_tracee);
348 printf("Tracee %d exited with %d\n", tracee, exitval_tracee);
350 printf("Before exiting of the tracer process\n");
351 _exit(exitval_tracer);
354 printf("Wait for the tracer to attach to the tracee\n");
355 PARENT_FROM_CHILD("tracer ready", parent_tracer, msg);
357 printf("Resume the tracee and let it exit\n");
358 PARENT_TO_CHILD("exit tracee", parent_tracee, msg);
360 printf("Detect that tracee is zombie\n");
361 await_zombie(tracee);
364 printf("Assert that there is no status about tracee %d - "
365 "Tracer must detect zombie first - calling %s()\n", tracee,
367 TWAIT_REQUIRE_SUCCESS(
368 wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
370 printf("Tell the tracer child should have exited\n");
371 PARENT_TO_CHILD("wait for tracee exit", parent_tracer, msg);
372 printf("Wait for tracer to finish its job and exit - calling %s()\n",
375 printf("Wait from tracer child to complete waiting for tracee\n");
376 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
379 validate_status_exited(status, exitval_tracer);
381 printf("Wait for tracee to finish its job and exit - calling %s()\n",
383 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
386 validate_status_exited(status, exitval_tracee);
388 msg_close(&parent_tracer);
389 msg_close(&parent_tracee);
393 #if defined(TWAIT_HAVE_PID)
395 ATF_TC_HEAD(attach2, tc)
397 atf_tc_set_md_var(tc, "descr",
398 "Assert that any tracer sees process termination before its "
402 ATF_TC_BODY(attach2, tc)
404 struct msg_fds parent_tracer, parent_tracee;
405 const int exitval_tracee = 5;
406 const int exitval_tracer1 = 10, exitval_tracer2 = 20;
407 pid_t tracee, tracer, wpid;
408 uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
409 #if defined(TWAIT_HAVE_STATUS)
413 printf("Spawn tracee\n");
414 ATF_REQUIRE(msg_open(&parent_tracee) == 0);
415 tracee = atf_utils_fork();
417 /* Wait for message from the parent */
418 CHILD_FROM_PARENT("Message 1", parent_tracee, msg);
419 _exit(exitval_tracee);
422 printf("Spawn debugger\n");
423 ATF_REQUIRE(msg_open(&parent_tracer) == 0);
424 tracer = atf_utils_fork();
426 /* Fork again and drop parent to reattach to PID 1 */
427 tracer = atf_utils_fork();
429 _exit(exitval_tracer1);
431 printf("Before calling PT_ATTACH from tracee %d\n", getpid());
432 FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
434 /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
435 FORKEE_REQUIRE_SUCCESS(
436 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
438 forkee_status_stopped(status, SIGSTOP);
440 /* Resume tracee with PT_CONTINUE */
441 FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
443 /* Inform parent that tracer has attached to tracee */
444 CHILD_TO_PARENT("Message 1", parent_tracer, msg);
445 CHILD_FROM_PARENT("Message 2", parent_tracer, msg);
447 /* Wait for tracee and assert that it exited */
448 FORKEE_REQUIRE_SUCCESS(
449 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
451 forkee_status_exited(status, exitval_tracee);
453 printf("Before exiting of the tracer process\n");
454 _exit(exitval_tracer2);
456 printf("Wait for the tracer process (direct child) to exit calling "
457 "%s()\n", TWAIT_FNAME);
458 TWAIT_REQUIRE_SUCCESS(
459 wpid = TWAIT_GENERIC(tracer, &status, 0), tracer);
461 validate_status_exited(status, exitval_tracer1);
463 printf("Wait for the non-exited tracee process with %s()\n",
465 TWAIT_REQUIRE_SUCCESS(
466 wpid = TWAIT_GENERIC(tracee, NULL, WNOHANG), 0);
468 printf("Wait for the tracer to attach to the tracee\n");
469 PARENT_FROM_CHILD("Message 1", parent_tracer, msg);
470 printf("Resume the tracee and let it exit\n");
471 PARENT_TO_CHILD("Message 1", parent_tracee, msg);
473 printf("Detect that tracee is zombie\n");
474 await_zombie(tracee);
476 printf("Assert that there is no status about tracee - "
477 "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
478 TWAIT_REQUIRE_SUCCESS(
479 wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
481 printf("Resume the tracer and let it detect exited tracee\n");
482 PARENT_TO_CHILD("Message 2", parent_tracer, msg);
484 printf("Wait for tracee to finish its job and exit - calling %s()\n",
486 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
489 validate_status_exited(status, exitval_tracee);
491 msg_close(&parent_tracer);
492 msg_close(&parent_tracee);
498 ATF_TC_HEAD(attach3, tc)
500 atf_tc_set_md_var(tc, "descr",
501 "Assert that tracer parent can PT_ATTACH to its child");
504 ATF_TC_BODY(attach3, tc)
506 struct msg_fds parent_tracee;
507 const int exitval_tracee = 5;
509 uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
510 #if defined(TWAIT_HAVE_STATUS)
514 printf("Spawn tracee\n");
515 ATF_REQUIRE(msg_open(&parent_tracee) == 0);
516 tracee = atf_utils_fork();
518 CHILD_FROM_PARENT("Message 1", parent_tracee, msg);
519 printf("Parent should now attach to tracee\n");
521 CHILD_FROM_PARENT("Message 2", parent_tracee, msg);
522 /* Wait for message from the parent */
523 _exit(exitval_tracee);
525 PARENT_TO_CHILD("Message 1", parent_tracee, msg);
527 printf("Before calling PT_ATTACH for tracee %d\n", tracee);
528 ATF_REQUIRE(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
530 printf("Wait for the stopped tracee process with %s()\n",
532 TWAIT_REQUIRE_SUCCESS(
533 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
535 validate_status_stopped(status, SIGSTOP);
537 printf("Resume tracee with PT_CONTINUE\n");
538 ATF_REQUIRE(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
540 printf("Let the tracee exit now\n");
541 PARENT_TO_CHILD("Message 2", parent_tracee, msg);
543 printf("Wait for tracee to exit with %s()\n", TWAIT_FNAME);
544 TWAIT_REQUIRE_SUCCESS(
545 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
547 validate_status_exited(status, exitval_tracee);
549 printf("Before calling %s() for tracee\n", TWAIT_FNAME);
550 TWAIT_REQUIRE_FAILURE(ECHILD,
551 wpid = TWAIT_GENERIC(tracee, &status, 0));
553 msg_close(&parent_tracee);
557 ATF_TC_HEAD(attach4, tc)
559 atf_tc_set_md_var(tc, "descr",
560 "Assert that tracer child can PT_ATTACH to its parent");
563 ATF_TC_BODY(attach4, tc)
565 struct msg_fds parent_tracee;
566 const int exitval_tracer = 5;
568 uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
569 #if defined(TWAIT_HAVE_STATUS)
573 printf("Spawn tracer\n");
574 ATF_REQUIRE(msg_open(&parent_tracee) == 0);
575 tracer = atf_utils_fork();
578 /* Wait for message from the parent */
579 CHILD_FROM_PARENT("Message 1", parent_tracee, msg);
581 printf("Attach to parent PID %d with PT_ATTACH from child\n",
583 FORKEE_ASSERT(ptrace(PT_ATTACH, getppid(), NULL, 0) != -1);
585 printf("Wait for the stopped parent process with %s()\n",
587 FORKEE_REQUIRE_SUCCESS(
588 wpid = TWAIT_GENERIC(getppid(), &status, 0), getppid());
590 forkee_status_stopped(status, SIGSTOP);
592 printf("Resume parent with PT_DETACH\n");
593 FORKEE_ASSERT(ptrace(PT_DETACH, getppid(), (void *)1, 0)
596 /* Tell parent we are ready */
597 CHILD_TO_PARENT("Message 1", parent_tracee, msg);
599 _exit(exitval_tracer);
602 printf("Wait for the tracer to become ready\n");
603 PARENT_TO_CHILD("Message 1", parent_tracee, msg);
604 printf("Allow the tracer to exit now\n");
605 PARENT_FROM_CHILD("Message 1", parent_tracee, msg);
607 printf("Wait for tracer to exit with %s()\n", TWAIT_FNAME);
608 TWAIT_REQUIRE_SUCCESS(
609 wpid = TWAIT_GENERIC(tracer, &status, 0), tracer);
611 validate_status_exited(status, exitval_tracer);
613 printf("Before calling %s() for tracer\n", TWAIT_FNAME);
614 TWAIT_REQUIRE_FAILURE(ECHILD,
615 wpid = TWAIT_GENERIC(tracer, &status, 0));
617 msg_close(&parent_tracee);
620 #if defined(TWAIT_HAVE_PID)
622 ATF_TC_HEAD(attach5, tc)
624 atf_tc_set_md_var(tc, "descr",
625 "Assert that tracer sees its parent when attached to tracer "
626 "(check getppid(2))");
629 ATF_TC_BODY(attach5, tc)
631 struct msg_fds parent_tracer, parent_tracee;
632 const int exitval_tracee = 5;
633 const int exitval_tracer = 10;
634 pid_t parent, tracee, tracer, wpid;
635 uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
636 #if defined(TWAIT_HAVE_STATUS)
640 printf("Spawn tracee\n");
641 ATF_REQUIRE(msg_open(&parent_tracer) == 0);
642 ATF_REQUIRE(msg_open(&parent_tracee) == 0);
643 tracee = atf_utils_fork();
647 /* Emit message to the parent */
648 CHILD_TO_PARENT("tracee ready", parent_tracee, msg);
649 CHILD_FROM_PARENT("exit tracee", parent_tracee, msg);
651 FORKEE_ASSERT_EQ(parent, getppid());
653 _exit(exitval_tracee);
655 printf("Wait for child to record its parent identifier (pid)\n");
656 PARENT_FROM_CHILD("tracee ready", parent_tracee, msg);
658 printf("Spawn debugger\n");
659 tracer = atf_utils_fork();
661 /* No IPC to communicate with the child */
662 printf("Before calling PT_ATTACH from tracee %d\n", getpid());
663 FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
665 /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
666 FORKEE_REQUIRE_SUCCESS(
667 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
669 forkee_status_stopped(status, SIGSTOP);
671 /* Resume tracee with PT_CONTINUE */
672 FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
674 /* Inform parent that tracer has attached to tracee */
675 CHILD_TO_PARENT("tracer ready", parent_tracer, msg);
677 /* Wait for parent to tell use that tracee should have exited */
678 CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg);
680 /* Wait for tracee and assert that it exited */
681 FORKEE_REQUIRE_SUCCESS(
682 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
684 forkee_status_exited(status, exitval_tracee);
686 printf("Before exiting of the tracer process\n");
687 _exit(exitval_tracer);
690 printf("Wait for the tracer to attach to the tracee\n");
691 PARENT_FROM_CHILD("tracer ready", parent_tracer, msg);
693 printf("Resume the tracee and let it exit\n");
694 PARENT_TO_CHILD("exit tracee", parent_tracee, msg);
696 printf("Detect that tracee is zombie\n");
697 await_zombie(tracee);
699 printf("Assert that there is no status about tracee - "
700 "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
701 TWAIT_REQUIRE_SUCCESS(
702 wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
704 printf("Tell the tracer child should have exited\n");
705 PARENT_TO_CHILD("wait for tracee exit", parent_tracer, msg);
707 printf("Wait from tracer child to complete waiting for tracee\n");
708 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
711 validate_status_exited(status, exitval_tracer);
713 printf("Wait for tracee to finish its job and exit - calling %s()\n",
715 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
718 validate_status_exited(status, exitval_tracee);
720 msg_close(&parent_tracer);
721 msg_close(&parent_tracee);
725 #if defined(TWAIT_HAVE_PID)
727 ATF_TC_HEAD(attach6, tc)
729 atf_tc_set_md_var(tc, "descr",
730 "Assert that tracer sees its parent when attached to tracer "
731 "(check sysctl(7) and struct kinfo_proc2)");
734 ATF_TC_BODY(attach6, tc)
736 struct msg_fds parent_tracee, parent_tracer;
737 const int exitval_tracee = 5;
738 const int exitval_tracer = 10;
739 pid_t parent, tracee, tracer, wpid;
740 uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
741 #if defined(TWAIT_HAVE_STATUS)
744 int name[CTL_MAXNAME];
745 struct kinfo_proc2 kp;
746 size_t len = sizeof(kp);
747 unsigned int namelen;
749 printf("Spawn tracee\n");
750 ATF_REQUIRE(msg_open(&parent_tracee) == 0);
751 ATF_REQUIRE(msg_open(&parent_tracer) == 0);
752 tracee = atf_utils_fork();
756 /* Emit message to the parent */
757 CHILD_TO_PARENT("Message 1", parent_tracee, msg);
758 CHILD_FROM_PARENT("Message 2", parent_tracee, msg);
761 name[namelen++] = CTL_KERN;
762 name[namelen++] = KERN_PROC2;
763 name[namelen++] = KERN_PROC_PID;
764 name[namelen++] = getpid();
765 name[namelen++] = len;
768 FORKEE_ASSERT(sysctl(name, namelen, &kp, &len, NULL, 0) == 0);
769 FORKEE_ASSERT_EQ(parent, kp.p_ppid);
771 _exit(exitval_tracee);
774 printf("Wait for child to record its parent identifier (pid)\n");
775 PARENT_FROM_CHILD("Message 1", parent_tracee, msg);
777 printf("Spawn debugger\n");
778 tracer = atf_utils_fork();
780 /* No IPC to communicate with the child */
781 printf("Before calling PT_ATTACH from tracee %d\n", getpid());
782 FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
784 /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
785 FORKEE_REQUIRE_SUCCESS(
786 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
788 forkee_status_stopped(status, SIGSTOP);
790 /* Resume tracee with PT_CONTINUE */
791 FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
793 /* Inform parent that tracer has attached to tracee */
794 CHILD_TO_PARENT("Message 1", parent_tracer, msg);
796 CHILD_FROM_PARENT("Message 2", parent_tracer, msg);
798 /* Wait for tracee and assert that it exited */
799 FORKEE_REQUIRE_SUCCESS(
800 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
802 forkee_status_exited(status, exitval_tracee);
804 printf("Before exiting of the tracer process\n");
805 _exit(exitval_tracer);
808 printf("Wait for the tracer to attach to the tracee\n");
809 PARENT_FROM_CHILD("Message 1", parent_tracer, msg);
811 printf("Resume the tracee and let it exit\n");
812 PARENT_TO_CHILD("Message 1", parent_tracee, msg);
814 printf("Detect that tracee is zombie\n");
815 await_zombie(tracee);
817 printf("Assert that there is no status about tracee - "
818 "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
819 TWAIT_REQUIRE_SUCCESS(
820 wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
822 printf("Resume the tracer and let it detect exited tracee\n");
823 PARENT_TO_CHILD("Message 2", parent_tracer, msg);
825 printf("Wait for tracer to finish its job and exit - calling %s()\n",
827 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
830 validate_status_exited(status, exitval_tracer);
832 printf("Wait for tracee to finish its job and exit - calling %s()\n",
834 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
837 validate_status_exited(status, exitval_tracee);
839 msg_close(&parent_tracee);
840 msg_close(&parent_tracer);
844 #if defined(TWAIT_HAVE_PID)
846 ATF_TC_HEAD(attach7, tc)
848 atf_tc_set_md_var(tc, "descr",
849 "Assert that tracer sees its parent when attached to tracer "
850 "(check /proc/curproc/status 3rd column)");
853 ATF_TC_BODY(attach7, tc)
855 struct msg_fds parent_tracee, parent_tracer;
857 const int exitval_tracee = 5;
858 const int exitval_tracer = 10;
859 pid_t parent, tracee, tracer, wpid;
860 uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
861 #if defined(TWAIT_HAVE_STATUS)
866 const char *fname = "/proc/curproc/status";
867 char s_executable[MAXPATHLEN];
871 * EXECUTABLE PID PPID ...
874 ATF_REQUIRE((rv = stat(fname, &st)) == 0 || (errno == ENOENT));
876 atf_tc_skip("/proc/curproc/status not found");
879 printf("Spawn tracee\n");
880 ATF_REQUIRE(msg_open(&parent_tracee) == 0);
881 ATF_REQUIRE(msg_open(&parent_tracer) == 0);
882 tracee = atf_utils_fork();
886 // Wait for parent to let us exit
887 CHILD_TO_PARENT("tracee ready", parent_tracee, msg);
888 CHILD_FROM_PARENT("tracee exit", parent_tracee, msg);
890 FORKEE_ASSERT((fp = fopen(fname, "r")) != NULL);
891 fscanf(fp, "%s %d %d", s_executable, &s_pid, &s_ppid);
892 FORKEE_ASSERT(fclose(fp) == 0);
893 FORKEE_ASSERT_EQ(parent, s_ppid);
895 _exit(exitval_tracee);
898 printf("Wait for child to record its parent identifier (pid)\n");
899 PARENT_FROM_CHILD("tracee ready", parent_tracee, msg);
901 printf("Spawn debugger\n");
902 tracer = atf_utils_fork();
904 printf("Before calling PT_ATTACH from tracee %d\n", getpid());
905 FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
907 /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
908 FORKEE_REQUIRE_SUCCESS(
909 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
911 forkee_status_stopped(status, SIGSTOP);
913 /* Resume tracee with PT_CONTINUE */
914 FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
916 /* Inform parent that tracer has attached to tracee */
917 CHILD_TO_PARENT("tracer ready", parent_tracer, msg);
919 /* Wait for parent to tell use that tracee should have exited */
920 CHILD_FROM_PARENT("wait for tracee exit", parent_tracer, msg);
922 /* Wait for tracee and assert that it exited */
923 FORKEE_REQUIRE_SUCCESS(
924 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
926 forkee_status_exited(status, exitval_tracee);
928 printf("Before exiting of the tracer process\n");
929 _exit(exitval_tracer);
931 printf("Wait for the tracer to attach to the tracee\n");
932 PARENT_FROM_CHILD("tracer ready", parent_tracer, msg);
933 printf("Resume the tracee and let it exit\n");
934 PARENT_TO_CHILD("tracee exit", parent_tracee, msg);
936 printf("Detect that tracee is zombie\n");
937 await_zombie(tracee);
939 printf("Assert that there is no status about tracee - "
940 "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
941 TWAIT_REQUIRE_SUCCESS(
942 wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
944 printf("Resume the tracer and let it detect exited tracee\n");
945 PARENT_TO_CHILD("Message 2", parent_tracer, msg);
947 printf("Wait for tracer to finish its job and exit - calling %s()\n",
949 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
952 validate_status_exited(status, exitval_tracer);
954 printf("Wait for tracee to finish its job and exit - calling %s()\n",
956 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
959 validate_status_exited(status, exitval_tracee);
961 msg_close(&parent_tracee);
962 msg_close(&parent_tracer);
967 ATF_TC_HEAD(eventmask1, tc)
969 atf_tc_set_md_var(tc, "descr",
970 "Verify that empty EVENT_MASK is preserved");
973 ATF_TC_BODY(eventmask1, tc)
975 const int exitval = 5;
976 const int sigval = SIGSTOP;
978 #if defined(TWAIT_HAVE_STATUS)
981 ptrace_event_t set_event, get_event;
982 const int len = sizeof(ptrace_event_t);
984 printf("Before forking process PID=%d\n", getpid());
985 ATF_REQUIRE((child = fork()) != -1);
987 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
988 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
990 printf("Before raising %s from child\n", strsignal(sigval));
991 FORKEE_ASSERT(raise(sigval) == 0);
993 printf("Before exiting of the child process\n");
996 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
998 printf("Before calling %s() for the child\n", TWAIT_FNAME);
999 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1001 validate_status_stopped(status, sigval);
1003 set_event.pe_set_event = 0;
1004 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
1005 ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
1006 ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
1008 printf("Before resuming the child process where it left off and "
1009 "without signal to be sent\n");
1010 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1012 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1013 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1015 validate_status_exited(status, exitval);
1017 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1018 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1022 ATF_TC_HEAD(eventmask2, tc)
1024 atf_tc_set_md_var(tc, "descr",
1025 "Verify that PTRACE_FORK in EVENT_MASK is preserved");
1028 ATF_TC_BODY(eventmask2, tc)
1030 const int exitval = 5;
1031 const int sigval = SIGSTOP;
1033 #if defined(TWAIT_HAVE_STATUS)
1036 ptrace_event_t set_event, get_event;
1037 const int len = sizeof(ptrace_event_t);
1039 printf("Before forking process PID=%d\n", getpid());
1040 ATF_REQUIRE((child = fork()) != -1);
1042 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1043 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1045 printf("Before raising %s from child\n", strsignal(sigval));
1046 FORKEE_ASSERT(raise(sigval) == 0);
1048 printf("Before exiting of the child process\n");
1051 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1053 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1054 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1056 validate_status_stopped(status, sigval);
1058 set_event.pe_set_event = PTRACE_FORK;
1059 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
1060 ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
1061 ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
1063 printf("Before resuming the child process where it left off and "
1064 "without signal to be sent\n");
1065 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1067 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1068 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1070 validate_status_exited(status, exitval);
1072 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1073 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1077 ATF_TC_HEAD(eventmask3, tc)
1079 atf_tc_set_md_var(tc, "descr",
1080 "Verify that PTRACE_VFORK in EVENT_MASK is preserved");
1083 ATF_TC_BODY(eventmask3, tc)
1085 const int exitval = 5;
1086 const int sigval = SIGSTOP;
1088 #if defined(TWAIT_HAVE_STATUS)
1091 ptrace_event_t set_event, get_event;
1092 const int len = sizeof(ptrace_event_t);
1094 atf_tc_expect_fail("PR kern/51630");
1096 printf("Before forking process PID=%d\n", getpid());
1097 ATF_REQUIRE((child = fork()) != -1);
1099 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1100 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1102 printf("Before raising %s from child\n", strsignal(sigval));
1103 FORKEE_ASSERT(raise(sigval) == 0);
1105 printf("Before exiting of the child process\n");
1108 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1110 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1111 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1113 validate_status_stopped(status, sigval);
1115 set_event.pe_set_event = PTRACE_VFORK;
1116 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
1117 ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
1118 ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
1120 printf("Before resuming the child process where it left off and "
1121 "without signal to be sent\n");
1122 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1124 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1125 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1127 validate_status_exited(status, exitval);
1129 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1130 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1134 ATF_TC_HEAD(eventmask4, tc)
1136 atf_tc_set_md_var(tc, "descr",
1137 "Verify that PTRACE_VFORK_DONE in EVENT_MASK is preserved");
1140 ATF_TC_BODY(eventmask4, tc)
1142 const int exitval = 5;
1143 const int sigval = SIGSTOP;
1145 #if defined(TWAIT_HAVE_STATUS)
1148 ptrace_event_t set_event, get_event;
1149 const int len = sizeof(ptrace_event_t);
1151 printf("Before forking process PID=%d\n", getpid());
1152 ATF_REQUIRE((child = fork()) != -1);
1154 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1155 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1157 printf("Before raising %s from child\n", strsignal(sigval));
1158 FORKEE_ASSERT(raise(sigval) == 0);
1160 printf("Before exiting of the child process\n");
1163 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1165 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1166 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1168 validate_status_stopped(status, sigval);
1170 set_event.pe_set_event = PTRACE_VFORK_DONE;
1171 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
1172 ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
1173 ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
1175 printf("Before resuming the child process where it left off and "
1176 "without signal to be sent\n");
1177 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1179 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1180 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1182 validate_status_exited(status, exitval);
1184 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1185 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1189 ATF_TC_HEAD(eventmask5, tc)
1191 atf_tc_set_md_var(tc, "descr",
1192 "Verify that PTRACE_LWP_CREATE in EVENT_MASK is preserved");
1195 ATF_TC_BODY(eventmask5, tc)
1197 const int exitval = 5;
1198 const int sigval = SIGSTOP;
1200 #if defined(TWAIT_HAVE_STATUS)
1203 ptrace_event_t set_event, get_event;
1204 const int len = sizeof(ptrace_event_t);
1206 printf("Before forking process PID=%d\n", getpid());
1207 ATF_REQUIRE((child = fork()) != -1);
1209 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1210 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1212 printf("Before raising %s from child\n", strsignal(sigval));
1213 FORKEE_ASSERT(raise(sigval) == 0);
1215 printf("Before exiting of the child process\n");
1218 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1220 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1221 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1223 validate_status_stopped(status, sigval);
1225 set_event.pe_set_event = PTRACE_LWP_CREATE;
1226 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
1227 ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
1228 ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
1230 printf("Before resuming the child process where it left off and "
1231 "without signal to be sent\n");
1232 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1234 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1235 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1237 validate_status_exited(status, exitval);
1239 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1240 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1244 ATF_TC_HEAD(eventmask6, tc)
1246 atf_tc_set_md_var(tc, "descr",
1247 "Verify that PTRACE_LWP_EXIT in EVENT_MASK is preserved");
1250 ATF_TC_BODY(eventmask6, tc)
1252 const int exitval = 5;
1253 const int sigval = SIGSTOP;
1255 #if defined(TWAIT_HAVE_STATUS)
1258 ptrace_event_t set_event, get_event;
1259 const int len = sizeof(ptrace_event_t);
1261 printf("Before forking process PID=%d\n", getpid());
1262 ATF_REQUIRE((child = fork()) != -1);
1264 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1265 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1267 printf("Before raising %s from child\n", strsignal(sigval));
1268 FORKEE_ASSERT(raise(sigval) == 0);
1270 printf("Before exiting of the child process\n");
1273 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1275 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1276 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1278 validate_status_stopped(status, sigval);
1280 set_event.pe_set_event = PTRACE_LWP_EXIT;
1281 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &set_event, len) != -1);
1282 ATF_REQUIRE(ptrace(PT_GET_EVENT_MASK, child, &get_event, len) != -1);
1283 ATF_REQUIRE(memcmp(&set_event, &get_event, len) == 0);
1285 printf("Before resuming the child process where it left off and "
1286 "without signal to be sent\n");
1287 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1289 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1290 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1292 validate_status_exited(status, exitval);
1294 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1295 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1298 #if defined(TWAIT_HAVE_PID)
1300 ATF_TC_HEAD(fork1, tc)
1302 atf_tc_set_md_var(tc, "descr",
1303 "Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK "
1304 "set to PTRACE_FORK");
1307 ATF_TC_BODY(fork1, tc)
1309 const int exitval = 5;
1310 const int exitval2 = 15;
1311 const int sigval = SIGSTOP;
1312 pid_t child, child2, wpid;
1313 #if defined(TWAIT_HAVE_STATUS)
1316 ptrace_state_t state;
1317 const int slen = sizeof(state);
1318 ptrace_event_t event;
1319 const int elen = sizeof(event);
1321 printf("Before forking process PID=%d\n", getpid());
1322 ATF_REQUIRE((child = fork()) != -1);
1324 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1325 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1327 printf("Before raising %s from child\n", strsignal(sigval));
1328 FORKEE_ASSERT(raise(sigval) == 0);
1330 FORKEE_ASSERT((child2 = fork()) != 1);
1335 FORKEE_REQUIRE_SUCCESS
1336 (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
1338 forkee_status_exited(status, exitval2);
1340 printf("Before exiting of the child process\n");
1343 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1345 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1346 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1348 validate_status_stopped(status, sigval);
1350 printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child);
1351 event.pe_set_event = PTRACE_FORK;
1352 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
1354 printf("Before resuming the child process where it left off and "
1355 "without signal to be sent\n");
1356 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1358 printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
1359 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1361 validate_status_stopped(status, SIGTRAP);
1363 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
1364 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
1366 child2 = state.pe_other_pid;
1367 printf("Reported PTRACE_FORK event with forkee %d\n", child2);
1369 printf("Before calling %s() for the forkee %d of the child %d\n",
1370 TWAIT_FNAME, child2, child);
1371 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
1374 validate_status_stopped(status, SIGTRAP);
1376 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1);
1377 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
1378 ATF_REQUIRE_EQ(state.pe_other_pid, child);
1380 printf("Before resuming the forkee process where it left off and "
1381 "without signal to be sent\n");
1382 ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
1384 printf("Before resuming the child process where it left off and "
1385 "without signal to be sent\n");
1386 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1388 printf("Before calling %s() for the forkee - expected exited\n",
1390 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
1393 validate_status_exited(status, exitval2);
1395 printf("Before calling %s() for the forkee - expected no process\n",
1397 TWAIT_REQUIRE_FAILURE(ECHILD,
1398 wpid = TWAIT_GENERIC(child2, &status, 0));
1400 printf("Before calling %s() for the child - expected stopped "
1401 "SIGCHLD\n", TWAIT_FNAME);
1402 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1404 validate_status_stopped(status, SIGCHLD);
1406 printf("Before resuming the child process where it left off and "
1407 "without signal to be sent\n");
1408 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1410 printf("Before calling %s() for the child - expected exited\n",
1412 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1414 validate_status_exited(status, exitval);
1416 printf("Before calling %s() for the child - expected no process\n",
1418 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1423 ATF_TC_HEAD(fork2, tc)
1425 atf_tc_set_md_var(tc, "descr",
1426 "Verify that fork(2) is not intercepted by ptrace(2) with empty "
1430 ATF_TC_BODY(fork2, tc)
1432 const int exitval = 5;
1433 const int exitval2 = 15;
1434 const int sigval = SIGSTOP;
1435 pid_t child, child2, wpid;
1436 #if defined(TWAIT_HAVE_STATUS)
1439 ptrace_event_t event;
1440 const int elen = sizeof(event);
1442 printf("Before forking process PID=%d\n", getpid());
1443 ATF_REQUIRE((child = fork()) != -1);
1445 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1446 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1448 printf("Before raising %s from child\n", strsignal(sigval));
1449 FORKEE_ASSERT(raise(sigval) == 0);
1451 FORKEE_ASSERT((child2 = fork()) != 1);
1456 FORKEE_REQUIRE_SUCCESS
1457 (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
1459 forkee_status_exited(status, exitval2);
1461 printf("Before exiting of the child process\n");
1464 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1466 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1467 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1469 validate_status_stopped(status, sigval);
1471 printf("Set empty EVENT_MASK for the child %d\n", child);
1472 event.pe_set_event = 0;
1473 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
1475 printf("Before resuming the child process where it left off and "
1476 "without signal to be sent\n");
1477 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1479 printf("Before calling %s() for the child - expected stopped "
1480 "SIGCHLD\n", TWAIT_FNAME);
1481 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1483 validate_status_stopped(status, SIGCHLD);
1485 printf("Before resuming the child process where it left off and "
1486 "without signal to be sent\n");
1487 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1489 printf("Before calling %s() for the child - expected exited\n",
1491 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1493 validate_status_exited(status, exitval);
1495 printf("Before calling %s() for the child - expected no process\n",
1497 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1500 #if defined(TWAIT_HAVE_PID)
1502 ATF_TC_HEAD(vfork1, tc)
1504 atf_tc_set_md_var(tc, "descr",
1505 "Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK "
1506 "set to PTRACE_VFORK");
1509 ATF_TC_BODY(vfork1, tc)
1511 const int exitval = 5;
1512 const int exitval2 = 15;
1513 const int sigval = SIGSTOP;
1514 pid_t child, child2, wpid;
1515 #if defined(TWAIT_HAVE_STATUS)
1518 ptrace_state_t state;
1519 const int slen = sizeof(state);
1520 ptrace_event_t event;
1521 const int elen = sizeof(event);
1523 atf_tc_expect_fail("PR kern/51630");
1525 printf("Before forking process PID=%d\n", getpid());
1526 ATF_REQUIRE((child = fork()) != -1);
1528 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1529 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1531 printf("Before raising %s from child\n", strsignal(sigval));
1532 FORKEE_ASSERT(raise(sigval) == 0);
1534 FORKEE_ASSERT((child2 = vfork()) != 1);
1539 FORKEE_REQUIRE_SUCCESS
1540 (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
1542 forkee_status_exited(status, exitval2);
1544 printf("Before exiting of the child process\n");
1547 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1549 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1550 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1552 validate_status_stopped(status, sigval);
1554 printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child);
1555 event.pe_set_event = PTRACE_VFORK;
1556 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
1558 printf("Before resuming the child process where it left off and "
1559 "without signal to be sent\n");
1560 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1562 printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
1563 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1565 validate_status_stopped(status, SIGTRAP);
1567 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
1568 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK);
1570 child2 = state.pe_other_pid;
1571 printf("Reported PTRACE_VFORK event with forkee %d\n", child2);
1573 printf("Before calling %s() for the forkee %d of the child %d\n",
1574 TWAIT_FNAME, child2, child);
1575 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
1578 validate_status_stopped(status, SIGTRAP);
1580 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1);
1581 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK);
1582 ATF_REQUIRE_EQ(state.pe_other_pid, child);
1584 printf("Before resuming the forkee process where it left off and "
1585 "without signal to be sent\n");
1586 ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
1588 printf("Before resuming the child process where it left off and "
1589 "without signal to be sent\n");
1590 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1592 printf("Before calling %s() for the forkee - expected exited\n",
1594 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
1597 validate_status_exited(status, exitval2);
1599 printf("Before calling %s() for the forkee - expected no process\n",
1601 TWAIT_REQUIRE_FAILURE(ECHILD,
1602 wpid = TWAIT_GENERIC(child2, &status, 0));
1604 printf("Before calling %s() for the child - expected stopped "
1605 "SIGCHLD\n", TWAIT_FNAME);
1606 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1608 validate_status_stopped(status, SIGCHLD);
1610 printf("Before resuming the child process where it left off and "
1611 "without signal to be sent\n");
1612 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1614 printf("Before calling %s() for the child - expected exited\n",
1616 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1618 validate_status_exited(status, exitval);
1620 printf("Before calling %s() for the child - expected no process\n",
1622 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1627 ATF_TC_HEAD(vfork2, tc)
1629 atf_tc_set_md_var(tc, "descr",
1630 "Verify that vfork(2) is not intercepted by ptrace(2) with empty "
1634 ATF_TC_BODY(vfork2, tc)
1636 const int exitval = 5;
1637 const int exitval2 = 15;
1638 const int sigval = SIGSTOP;
1639 pid_t child, child2, wpid;
1640 #if defined(TWAIT_HAVE_STATUS)
1643 ptrace_event_t event;
1644 const int elen = sizeof(event);
1646 printf("Before forking process PID=%d\n", getpid());
1647 ATF_REQUIRE((child = fork()) != -1);
1649 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1650 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1652 printf("Before raising %s from child\n", strsignal(sigval));
1653 FORKEE_ASSERT(raise(sigval) == 0);
1655 FORKEE_ASSERT((child2 = vfork()) != 1);
1660 FORKEE_REQUIRE_SUCCESS
1661 (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
1663 forkee_status_exited(status, exitval2);
1665 printf("Before exiting of the child process\n");
1668 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1670 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1671 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1673 validate_status_stopped(status, sigval);
1675 printf("Set empty EVENT_MASK for the child %d\n", child);
1676 event.pe_set_event = 0;
1677 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
1679 printf("Before resuming the child process where it left off and "
1680 "without signal to be sent\n");
1681 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1683 printf("Before calling %s() for the child - expected stopped "
1684 "SIGCHLD\n", TWAIT_FNAME);
1685 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1687 validate_status_stopped(status, SIGCHLD);
1689 printf("Before resuming the child process where it left off and "
1690 "without signal to be sent\n");
1691 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1693 printf("Before calling %s() for the child - expected exited\n",
1695 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1697 validate_status_exited(status, exitval);
1699 printf("Before calling %s() for the child - expected no process\n",
1701 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1705 ATF_TC_HEAD(vforkdone1, tc)
1707 atf_tc_set_md_var(tc, "descr",
1708 "Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK "
1709 "set to PTRACE_VFORK_DONE");
1712 ATF_TC_BODY(vforkdone1, tc)
1714 const int exitval = 5;
1715 const int exitval2 = 15;
1716 const int sigval = SIGSTOP;
1717 pid_t child, child2, wpid;
1718 #if defined(TWAIT_HAVE_STATUS)
1721 ptrace_state_t state;
1722 const int slen = sizeof(state);
1723 ptrace_event_t event;
1724 const int elen = sizeof(event);
1726 printf("Before forking process PID=%d\n", getpid());
1727 ATF_REQUIRE((child = fork()) != -1);
1729 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1730 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1732 printf("Before raising %s from child\n", strsignal(sigval));
1733 FORKEE_ASSERT(raise(sigval) == 0);
1735 FORKEE_ASSERT((child2 = vfork()) != 1);
1740 FORKEE_REQUIRE_SUCCESS
1741 (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
1743 forkee_status_exited(status, exitval2);
1745 printf("Before exiting of the child process\n");
1748 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1750 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1751 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1753 validate_status_stopped(status, sigval);
1755 printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child);
1756 event.pe_set_event = PTRACE_VFORK_DONE;
1757 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
1759 printf("Before resuming the child process where it left off and "
1760 "without signal to be sent\n");
1761 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1763 printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
1764 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1766 validate_status_stopped(status, SIGTRAP);
1768 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
1769 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK_DONE);
1771 child2 = state.pe_other_pid;
1772 printf("Reported PTRACE_VFORK_DONE event with forkee %d\n", child2);
1774 printf("Before resuming the child process where it left off and "
1775 "without signal to be sent\n");
1776 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1778 printf("Before calling %s() for the child - expected stopped "
1779 "SIGCHLD\n", TWAIT_FNAME);
1780 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1782 validate_status_stopped(status, SIGCHLD);
1784 printf("Before resuming the child process where it left off and "
1785 "without signal to be sent\n");
1786 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1788 printf("Before calling %s() for the child - expected exited\n",
1790 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1792 validate_status_exited(status, exitval);
1794 printf("Before calling %s() for the child - expected no process\n",
1796 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1800 ATF_TC_HEAD(vforkdone2, tc)
1802 atf_tc_set_md_var(tc, "descr",
1803 "Verify that vfork(2) is intercepted by ptrace(2) with EVENT_MASK "
1804 "set to PTRACE_FORK | PTRACE_VFORK_DONE");
1807 ATF_TC_BODY(vforkdone2, tc)
1809 const int exitval = 5;
1810 const int exitval2 = 15;
1811 const int sigval = SIGSTOP;
1812 pid_t child, child2, wpid;
1813 #if defined(TWAIT_HAVE_STATUS)
1816 ptrace_state_t state;
1817 const int slen = sizeof(state);
1818 ptrace_event_t event;
1819 const int elen = sizeof(event);
1821 printf("Before forking process PID=%d\n", getpid());
1822 ATF_REQUIRE((child = fork()) != -1);
1824 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1825 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1827 printf("Before raising %s from child\n", strsignal(sigval));
1828 FORKEE_ASSERT(raise(sigval) == 0);
1830 FORKEE_ASSERT((child2 = vfork()) != 1);
1835 FORKEE_REQUIRE_SUCCESS
1836 (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
1838 forkee_status_exited(status, exitval2);
1840 printf("Before exiting of the child process\n");
1843 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1845 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1846 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1848 validate_status_stopped(status, sigval);
1850 printf("Enable PTRACE_VFORK in EVENT_MASK for the child %d\n", child);
1851 event.pe_set_event = PTRACE_FORK | PTRACE_VFORK_DONE;
1852 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
1854 printf("Before resuming the child process where it left off and "
1855 "without signal to be sent\n");
1856 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1858 printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
1859 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1861 validate_status_stopped(status, SIGTRAP);
1863 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
1864 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_VFORK_DONE);
1866 child2 = state.pe_other_pid;
1867 printf("Reported PTRACE_VFORK_DONE event with forkee %d\n", child2);
1869 printf("Before resuming the child process where it left off and "
1870 "without signal to be sent\n");
1871 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1873 printf("Before calling %s() for the child - expected stopped "
1874 "SIGCHLD\n", TWAIT_FNAME);
1875 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1877 validate_status_stopped(status, SIGCHLD);
1879 printf("Before resuming the child process where it left off and "
1880 "without signal to be sent\n");
1881 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1883 printf("Before calling %s() for the child - expected exited\n",
1885 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1887 validate_status_exited(status, exitval);
1889 printf("Before calling %s() for the child - expected no process\n",
1891 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1895 ATF_TC_HEAD(io_read_d1, tc)
1897 atf_tc_set_md_var(tc, "descr",
1898 "Verify PT_IO with PIOD_READ_D and len = sizeof(uint8_t)");
1901 ATF_TC_BODY(io_read_d1, tc)
1903 const int exitval = 5;
1904 const int sigval = SIGSTOP;
1906 uint8_t lookup_me = 0;
1907 const uint8_t magic = 0xab;
1908 struct ptrace_io_desc io = {
1909 .piod_op = PIOD_READ_D,
1910 .piod_offs = &lookup_me,
1911 .piod_addr = &lookup_me,
1912 .piod_len = sizeof(lookup_me)
1914 #if defined(TWAIT_HAVE_STATUS)
1918 printf("Before forking process PID=%d\n", getpid());
1919 ATF_REQUIRE((child = fork()) != -1);
1921 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1922 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1926 printf("Before raising %s from child\n", strsignal(sigval));
1927 FORKEE_ASSERT(raise(sigval) == 0);
1929 printf("Before exiting of the child process\n");
1932 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1934 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1935 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1937 validate_status_stopped(status, sigval);
1939 printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
1941 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
1943 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
1944 "got value %" PRIx8 " != expected %" PRIx8, lookup_me, magic);
1946 printf("Before resuming the child process where it left off and "
1947 "without signal to be sent\n");
1948 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
1950 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1951 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
1953 validate_status_exited(status, exitval);
1955 printf("Before calling %s() for the child\n", TWAIT_FNAME);
1956 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
1960 ATF_TC_HEAD(io_read_d2, tc)
1962 atf_tc_set_md_var(tc, "descr",
1963 "Verify PT_IO with PIOD_READ_D and len = sizeof(uint16_t)");
1966 ATF_TC_BODY(io_read_d2, tc)
1968 const int exitval = 5;
1969 const int sigval = SIGSTOP;
1971 uint16_t lookup_me = 0;
1972 const uint16_t magic = 0x1234;
1973 struct ptrace_io_desc io = {
1974 .piod_op = PIOD_READ_D,
1975 .piod_offs = &lookup_me,
1976 .piod_addr = &lookup_me,
1977 .piod_len = sizeof(lookup_me)
1979 #if defined(TWAIT_HAVE_STATUS)
1983 printf("Before forking process PID=%d\n", getpid());
1984 ATF_REQUIRE((child = fork()) != -1);
1986 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
1987 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
1991 printf("Before raising %s from child\n", strsignal(sigval));
1992 FORKEE_ASSERT(raise(sigval) == 0);
1994 printf("Before exiting of the child process\n");
1997 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
1999 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2000 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2002 validate_status_stopped(status, sigval);
2004 printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
2006 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
2008 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
2009 "got value %" PRIx16 " != expected %" PRIx16, lookup_me, magic);
2011 printf("Before resuming the child process where it left off and "
2012 "without signal to be sent\n");
2013 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2015 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2016 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2018 validate_status_exited(status, exitval);
2020 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2021 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2025 ATF_TC_HEAD(io_read_d3, tc)
2027 atf_tc_set_md_var(tc, "descr",
2028 "Verify PT_IO with PIOD_READ_D and len = sizeof(uint32_t)");
2031 ATF_TC_BODY(io_read_d3, tc)
2033 const int exitval = 5;
2034 const int sigval = SIGSTOP;
2036 uint32_t lookup_me = 0;
2037 const uint32_t magic = 0x1234abcd;
2038 struct ptrace_io_desc io = {
2039 .piod_op = PIOD_READ_D,
2040 .piod_offs = &lookup_me,
2041 .piod_addr = &lookup_me,
2042 .piod_len = sizeof(lookup_me)
2044 #if defined(TWAIT_HAVE_STATUS)
2048 printf("Before forking process PID=%d\n", getpid());
2049 ATF_REQUIRE((child = fork()) != -1);
2051 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2052 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2056 printf("Before raising %s from child\n", strsignal(sigval));
2057 FORKEE_ASSERT(raise(sigval) == 0);
2059 printf("Before exiting of the child process\n");
2062 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2064 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2065 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2067 validate_status_stopped(status, sigval);
2069 printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
2071 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
2073 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
2074 "got value %" PRIx32 " != expected %" PRIx32, lookup_me, magic);
2076 printf("Before resuming the child process where it left off and "
2077 "without signal to be sent\n");
2078 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2080 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2081 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2083 validate_status_exited(status, exitval);
2085 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2086 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2090 ATF_TC_HEAD(io_read_d4, tc)
2092 atf_tc_set_md_var(tc, "descr",
2093 "Verify PT_IO with PIOD_READ_D and len = sizeof(uint64_t)");
2096 ATF_TC_BODY(io_read_d4, tc)
2098 const int exitval = 5;
2099 const int sigval = SIGSTOP;
2101 uint64_t lookup_me = 0;
2102 const uint64_t magic = 0x1234abcd9876dcfa;
2103 struct ptrace_io_desc io = {
2104 .piod_op = PIOD_READ_D,
2105 .piod_offs = &lookup_me,
2106 .piod_addr = &lookup_me,
2107 .piod_len = sizeof(lookup_me)
2109 #if defined(TWAIT_HAVE_STATUS)
2113 printf("Before forking process PID=%d\n", getpid());
2114 ATF_REQUIRE((child = fork()) != -1);
2116 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2117 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2121 printf("Before raising %s from child\n", strsignal(sigval));
2122 FORKEE_ASSERT(raise(sigval) == 0);
2124 printf("Before exiting of the child process\n");
2127 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2129 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2130 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2132 validate_status_stopped(status, sigval);
2134 printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
2136 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
2138 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
2139 "got value %" PRIx64 " != expected %" PRIx64, lookup_me, magic);
2141 printf("Before resuming the child process where it left off and "
2142 "without signal to be sent\n");
2143 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2145 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2146 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2148 validate_status_exited(status, exitval);
2150 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2151 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2154 ATF_TC(io_write_d1);
2155 ATF_TC_HEAD(io_write_d1, tc)
2157 atf_tc_set_md_var(tc, "descr",
2158 "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint8_t)");
2161 ATF_TC_BODY(io_write_d1, tc)
2163 const int exitval = 5;
2164 const int sigval = SIGSTOP;
2166 uint8_t lookup_me = 0;
2167 const uint8_t magic = 0xab;
2168 struct ptrace_io_desc io = {
2169 .piod_op = PIOD_WRITE_D,
2170 .piod_offs = &lookup_me,
2171 .piod_addr = &lookup_me,
2172 .piod_len = sizeof(lookup_me)
2174 #if defined(TWAIT_HAVE_STATUS)
2178 printf("Before forking process PID=%d\n", getpid());
2179 ATF_REQUIRE((child = fork()) != -1);
2181 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2182 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2184 printf("Before raising %s from child\n", strsignal(sigval));
2185 FORKEE_ASSERT(raise(sigval) == 0);
2187 FORKEE_ASSERT_EQ(lookup_me, magic);
2189 printf("Before exiting of the child process\n");
2192 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2194 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2195 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2197 validate_status_stopped(status, sigval);
2201 printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
2203 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
2205 printf("Before resuming the child process where it left off and "
2206 "without signal to be sent\n");
2207 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2209 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2210 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2212 validate_status_exited(status, exitval);
2214 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2215 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2218 ATF_TC(io_write_d2);
2219 ATF_TC_HEAD(io_write_d2, tc)
2221 atf_tc_set_md_var(tc, "descr",
2222 "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint16_t)");
2225 ATF_TC_BODY(io_write_d2, tc)
2227 const int exitval = 5;
2228 const int sigval = SIGSTOP;
2230 uint16_t lookup_me = 0;
2231 const uint16_t magic = 0xab12;
2232 struct ptrace_io_desc io = {
2233 .piod_op = PIOD_WRITE_D,
2234 .piod_offs = &lookup_me,
2235 .piod_addr = &lookup_me,
2236 .piod_len = sizeof(lookup_me)
2238 #if defined(TWAIT_HAVE_STATUS)
2242 printf("Before forking process PID=%d\n", getpid());
2243 ATF_REQUIRE((child = fork()) != -1);
2245 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2246 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2248 printf("Before raising %s from child\n", strsignal(sigval));
2249 FORKEE_ASSERT(raise(sigval) == 0);
2251 FORKEE_ASSERT_EQ(lookup_me, magic);
2253 printf("Before exiting of the child process\n");
2256 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2258 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2259 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2261 validate_status_stopped(status, sigval);
2265 printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
2267 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
2269 printf("Before resuming the child process where it left off and "
2270 "without signal to be sent\n");
2271 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2273 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2274 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2276 validate_status_exited(status, exitval);
2278 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2279 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2282 ATF_TC(io_write_d3);
2283 ATF_TC_HEAD(io_write_d3, tc)
2285 atf_tc_set_md_var(tc, "descr",
2286 "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint32_t)");
2289 ATF_TC_BODY(io_write_d3, tc)
2291 const int exitval = 5;
2292 const int sigval = SIGSTOP;
2294 uint32_t lookup_me = 0;
2295 const uint32_t magic = 0xab127643;
2296 struct ptrace_io_desc io = {
2297 .piod_op = PIOD_WRITE_D,
2298 .piod_offs = &lookup_me,
2299 .piod_addr = &lookup_me,
2300 .piod_len = sizeof(lookup_me)
2302 #if defined(TWAIT_HAVE_STATUS)
2306 printf("Before forking process PID=%d\n", getpid());
2307 ATF_REQUIRE((child = fork()) != -1);
2309 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2310 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2312 printf("Before raising %s from child\n", strsignal(sigval));
2313 FORKEE_ASSERT(raise(sigval) == 0);
2315 FORKEE_ASSERT_EQ(lookup_me, magic);
2317 printf("Before exiting of the child process\n");
2320 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2322 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2323 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2325 validate_status_stopped(status, sigval);
2329 printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
2331 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
2333 printf("Before resuming the child process where it left off and "
2334 "without signal to be sent\n");
2335 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2337 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2338 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2340 validate_status_exited(status, exitval);
2342 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2343 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2346 ATF_TC(io_write_d4);
2347 ATF_TC_HEAD(io_write_d4, tc)
2349 atf_tc_set_md_var(tc, "descr",
2350 "Verify PT_IO with PIOD_WRITE_D and len = sizeof(uint64_t)");
2353 ATF_TC_BODY(io_write_d4, tc)
2355 const int exitval = 5;
2356 const int sigval = SIGSTOP;
2358 uint64_t lookup_me = 0;
2359 const uint64_t magic = 0xab12764376490123;
2360 struct ptrace_io_desc io = {
2361 .piod_op = PIOD_WRITE_D,
2362 .piod_offs = &lookup_me,
2363 .piod_addr = &lookup_me,
2364 .piod_len = sizeof(lookup_me)
2366 #if defined(TWAIT_HAVE_STATUS)
2370 printf("Before forking process PID=%d\n", getpid());
2371 ATF_REQUIRE((child = fork()) != -1);
2373 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2374 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2376 printf("Before raising %s from child\n", strsignal(sigval));
2377 FORKEE_ASSERT(raise(sigval) == 0);
2379 FORKEE_ASSERT_EQ(lookup_me, magic);
2381 printf("Before exiting of the child process\n");
2384 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2386 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2387 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2389 validate_status_stopped(status, sigval);
2393 printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
2395 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
2397 printf("Before resuming the child process where it left off and "
2398 "without signal to be sent\n");
2399 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2401 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2402 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2404 validate_status_exited(status, exitval);
2406 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2407 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2411 ATF_TC_HEAD(read_d1, tc)
2413 atf_tc_set_md_var(tc, "descr",
2414 "Verify PT_READ_D called once");
2417 ATF_TC_BODY(read_d1, tc)
2419 const int exitval = 5;
2420 const int sigval = SIGSTOP;
2423 const int magic = (int)random();
2424 #if defined(TWAIT_HAVE_STATUS)
2428 printf("Before forking process PID=%d\n", getpid());
2429 ATF_REQUIRE((child = fork()) != -1);
2431 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2432 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2436 printf("Before raising %s from child\n", strsignal(sigval));
2437 FORKEE_ASSERT(raise(sigval) == 0);
2439 printf("Before exiting of the child process\n");
2442 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2444 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2445 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2447 validate_status_stopped(status, sigval);
2449 printf("Read new lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
2452 lookup_me = ptrace(PT_READ_D, child, &lookup_me, 0);
2453 ATF_REQUIRE_EQ(errno, 0);
2455 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
2456 "got value %#x != expected %#x", lookup_me, magic);
2458 printf("Before resuming the child process where it left off and "
2459 "without signal to be sent\n");
2460 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2462 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2463 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2465 validate_status_exited(status, exitval);
2467 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2468 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2472 ATF_TC_HEAD(read_d2, tc)
2474 atf_tc_set_md_var(tc, "descr",
2475 "Verify PT_READ_D called twice");
2478 ATF_TC_BODY(read_d2, tc)
2480 const int exitval = 5;
2481 const int sigval = SIGSTOP;
2485 const int magic1 = (int)random();
2486 const int magic2 = (int)random();
2487 #if defined(TWAIT_HAVE_STATUS)
2491 printf("Before forking process PID=%d\n", getpid());
2492 ATF_REQUIRE((child = fork()) != -1);
2494 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2495 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2497 lookup_me1 = magic1;
2498 lookup_me2 = magic2;
2500 printf("Before raising %s from child\n", strsignal(sigval));
2501 FORKEE_ASSERT(raise(sigval) == 0);
2503 printf("Before exiting of the child process\n");
2506 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2508 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2509 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2511 validate_status_stopped(status, sigval);
2513 printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
2516 lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0);
2517 ATF_REQUIRE_EQ(errno, 0);
2519 ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
2520 "got value %#x != expected %#x", lookup_me1, magic1);
2522 printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
2525 lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0);
2526 ATF_REQUIRE_EQ(errno, 0);
2528 ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
2529 "got value %#x != expected %#x", lookup_me2, magic2);
2531 printf("Before resuming the child process where it left off and "
2532 "without signal to be sent\n");
2533 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2535 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2536 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2538 validate_status_exited(status, exitval);
2540 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2541 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2545 ATF_TC_HEAD(read_d3, tc)
2547 atf_tc_set_md_var(tc, "descr",
2548 "Verify PT_READ_D called three times");
2551 ATF_TC_BODY(read_d3, tc)
2553 const int exitval = 5;
2554 const int sigval = SIGSTOP;
2559 const int magic1 = (int)random();
2560 const int magic2 = (int)random();
2561 const int magic3 = (int)random();
2562 #if defined(TWAIT_HAVE_STATUS)
2566 printf("Before forking process PID=%d\n", getpid());
2567 ATF_REQUIRE((child = fork()) != -1);
2569 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2570 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2572 lookup_me1 = magic1;
2573 lookup_me2 = magic2;
2574 lookup_me3 = magic3;
2576 printf("Before raising %s from child\n", strsignal(sigval));
2577 FORKEE_ASSERT(raise(sigval) == 0);
2579 printf("Before exiting of the child process\n");
2582 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2584 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2585 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2587 validate_status_stopped(status, sigval);
2589 printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
2592 lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0);
2593 ATF_REQUIRE_EQ(errno, 0);
2595 ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
2596 "got value %#x != expected %#x", lookup_me1, magic1);
2598 printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
2601 lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0);
2602 ATF_REQUIRE_EQ(errno, 0);
2604 ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
2605 "got value %#x != expected %#x", lookup_me2, magic2);
2607 printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n",
2610 lookup_me3 = ptrace(PT_READ_D, child, &lookup_me3, 0);
2611 ATF_REQUIRE_EQ(errno, 0);
2613 ATF_REQUIRE_EQ_MSG(lookup_me3, magic3,
2614 "got value %#x != expected %#x", lookup_me3, magic3);
2616 printf("Before resuming the child process where it left off and "
2617 "without signal to be sent\n");
2618 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2620 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2621 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2623 validate_status_exited(status, exitval);
2625 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2626 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2630 ATF_TC_HEAD(read_d4, tc)
2632 atf_tc_set_md_var(tc, "descr",
2633 "Verify PT_READ_D called four times");
2636 ATF_TC_BODY(read_d4, tc)
2638 const int exitval = 5;
2639 const int sigval = SIGSTOP;
2645 const int magic1 = (int)random();
2646 const int magic2 = (int)random();
2647 const int magic3 = (int)random();
2648 const int magic4 = (int)random();
2649 #if defined(TWAIT_HAVE_STATUS)
2653 printf("Before forking process PID=%d\n", getpid());
2654 ATF_REQUIRE((child = fork()) != -1);
2656 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2657 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2659 lookup_me1 = magic1;
2660 lookup_me2 = magic2;
2661 lookup_me3 = magic3;
2662 lookup_me4 = magic4;
2664 printf("Before raising %s from child\n", strsignal(sigval));
2665 FORKEE_ASSERT(raise(sigval) == 0);
2667 printf("Before exiting of the child process\n");
2670 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2672 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2673 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2675 validate_status_stopped(status, sigval);
2677 printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
2680 lookup_me1 = ptrace(PT_READ_D, child, &lookup_me1, 0);
2681 ATF_REQUIRE_EQ(errno, 0);
2683 ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
2684 "got value %#x != expected %#x", lookup_me1, magic1);
2686 printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
2689 lookup_me2 = ptrace(PT_READ_D, child, &lookup_me2, 0);
2690 ATF_REQUIRE_EQ(errno, 0);
2692 ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
2693 "got value %#x != expected %#x", lookup_me2, magic2);
2695 printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n",
2698 lookup_me3 = ptrace(PT_READ_D, child, &lookup_me3, 0);
2699 ATF_REQUIRE_EQ(errno, 0);
2701 ATF_REQUIRE_EQ_MSG(lookup_me3, magic3,
2702 "got value %#x != expected %#x", lookup_me3, magic3);
2704 printf("Read new lookup_me4 from tracee (PID=%d) by tracer (PID=%d)\n",
2707 lookup_me4 = ptrace(PT_READ_D, child, &lookup_me4, 0);
2708 ATF_REQUIRE_EQ(errno, 0);
2710 ATF_REQUIRE_EQ_MSG(lookup_me4, magic4,
2711 "got value %#x != expected %#x", lookup_me4, magic4);
2713 printf("Before resuming the child process where it left off and "
2714 "without signal to be sent\n");
2715 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2717 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2718 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2720 validate_status_exited(status, exitval);
2722 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2723 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2727 ATF_TC_HEAD(write_d1, tc)
2729 atf_tc_set_md_var(tc, "descr",
2730 "Verify PT_WRITE_D called once");
2733 ATF_TC_BODY(write_d1, tc)
2735 const int exitval = 5;
2736 const int sigval = SIGSTOP;
2739 const int magic = (int)random();
2740 #if defined(TWAIT_HAVE_STATUS)
2744 printf("Before forking process PID=%d\n", getpid());
2745 ATF_REQUIRE((child = fork()) != -1);
2747 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2748 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2750 printf("Before raising %s from child\n", strsignal(sigval));
2751 FORKEE_ASSERT(raise(sigval) == 0);
2753 FORKEE_ASSERT_EQ(lookup_me, magic);
2755 printf("Before exiting of the child process\n");
2758 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2760 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2761 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2763 validate_status_stopped(status, sigval);
2765 printf("Write new lookup_me to tracee (PID=%d) from tracer (PID=%d)\n",
2767 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me, magic) != -1);
2769 printf("Before resuming the child process where it left off and "
2770 "without signal to be sent\n");
2771 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2773 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2774 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2776 validate_status_exited(status, exitval);
2778 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2779 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2783 ATF_TC_HEAD(write_d2, tc)
2785 atf_tc_set_md_var(tc, "descr",
2786 "Verify PT_WRITE_D called twice");
2789 ATF_TC_BODY(write_d2, tc)
2791 const int exitval = 5;
2792 const int sigval = SIGSTOP;
2796 const int magic1 = (int)random();
2797 const int magic2 = (int)random();
2798 #if defined(TWAIT_HAVE_STATUS)
2802 printf("Before forking process PID=%d\n", getpid());
2803 ATF_REQUIRE((child = fork()) != -1);
2805 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2806 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2808 printf("Before raising %s from child\n", strsignal(sigval));
2809 FORKEE_ASSERT(raise(sigval) == 0);
2811 FORKEE_ASSERT_EQ(lookup_me1, magic1);
2812 FORKEE_ASSERT_EQ(lookup_me2, magic2);
2814 printf("Before exiting of the child process\n");
2817 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2819 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2820 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2822 validate_status_stopped(status, sigval);
2824 printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n",
2826 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1);
2828 printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n",
2830 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1);
2832 printf("Before resuming the child process where it left off and "
2833 "without signal to be sent\n");
2834 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2836 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2837 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2839 validate_status_exited(status, exitval);
2841 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2842 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2846 ATF_TC_HEAD(write_d3, tc)
2848 atf_tc_set_md_var(tc, "descr",
2849 "Verify PT_WRITE_D called three times");
2852 ATF_TC_BODY(write_d3, tc)
2854 const int exitval = 5;
2855 const int sigval = SIGSTOP;
2860 const int magic1 = (int)random();
2861 const int magic2 = (int)random();
2862 const int magic3 = (int)random();
2863 #if defined(TWAIT_HAVE_STATUS)
2867 printf("Before forking process PID=%d\n", getpid());
2868 ATF_REQUIRE((child = fork()) != -1);
2870 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2871 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2873 printf("Before raising %s from child\n", strsignal(sigval));
2874 FORKEE_ASSERT(raise(sigval) == 0);
2876 FORKEE_ASSERT_EQ(lookup_me1, magic1);
2877 FORKEE_ASSERT_EQ(lookup_me2, magic2);
2878 FORKEE_ASSERT_EQ(lookup_me3, magic3);
2880 printf("Before exiting of the child process\n");
2883 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2885 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2886 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2888 validate_status_stopped(status, sigval);
2890 printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n",
2892 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1);
2894 printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n",
2896 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1);
2898 printf("Write new lookup_me3 to tracee (PID=%d) from tracer (PID=%d)\n",
2900 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me3, magic3) != -1);
2902 printf("Before resuming the child process where it left off and "
2903 "without signal to be sent\n");
2904 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2906 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2907 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2909 validate_status_exited(status, exitval);
2911 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2912 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2916 ATF_TC_HEAD(write_d4, tc)
2918 atf_tc_set_md_var(tc, "descr",
2919 "Verify PT_WRITE_D called four times");
2922 ATF_TC_BODY(write_d4, tc)
2924 const int exitval = 5;
2925 const int sigval = SIGSTOP;
2931 const int magic1 = (int)random();
2932 const int magic2 = (int)random();
2933 const int magic3 = (int)random();
2934 const int magic4 = (int)random();
2935 #if defined(TWAIT_HAVE_STATUS)
2939 printf("Before forking process PID=%d\n", getpid());
2940 ATF_REQUIRE((child = fork()) != -1);
2942 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
2943 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
2945 printf("Before raising %s from child\n", strsignal(sigval));
2946 FORKEE_ASSERT(raise(sigval) == 0);
2948 FORKEE_ASSERT_EQ(lookup_me1, magic1);
2949 FORKEE_ASSERT_EQ(lookup_me2, magic2);
2950 FORKEE_ASSERT_EQ(lookup_me3, magic3);
2951 FORKEE_ASSERT_EQ(lookup_me4, magic4);
2953 printf("Before exiting of the child process\n");
2956 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
2958 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2959 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2961 validate_status_stopped(status, sigval);
2963 printf("Write new lookup_me1 to tracee (PID=%d) from tracer (PID=%d)\n",
2965 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me1, magic1) != -1);
2967 printf("Write new lookup_me2 to tracee (PID=%d) from tracer (PID=%d)\n",
2969 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me2, magic2) != -1);
2971 printf("Write new lookup_me3 to tracee (PID=%d) from tracer (PID=%d)\n",
2973 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me3, magic3) != -1);
2975 printf("Write new lookup_me4 to tracee (PID=%d) from tracer (PID=%d)\n",
2977 ATF_REQUIRE(ptrace(PT_WRITE_D, child, &lookup_me4, magic4) != -1);
2979 printf("Before resuming the child process where it left off and "
2980 "without signal to be sent\n");
2981 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
2983 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2984 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
2986 validate_status_exited(status, exitval);
2988 printf("Before calling %s() for the child\n", TWAIT_FNAME);
2989 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
2992 ATF_TC(io_read_d_write_d_handshake1);
2993 ATF_TC_HEAD(io_read_d_write_d_handshake1, tc)
2995 atf_tc_set_md_var(tc, "descr",
2996 "Verify PT_IO with PIOD_READ_D and PIOD_WRITE_D handshake");
2999 ATF_TC_BODY(io_read_d_write_d_handshake1, tc)
3001 const int exitval = 5;
3002 const int sigval = SIGSTOP;
3004 uint8_t lookup_me_fromtracee = 0;
3005 const uint8_t magic_fromtracee = (uint8_t)random();
3006 uint8_t lookup_me_totracee = 0;
3007 const uint8_t magic_totracee = (uint8_t)random();
3008 struct ptrace_io_desc io_fromtracee = {
3009 .piod_op = PIOD_READ_D,
3010 .piod_offs = &lookup_me_fromtracee,
3011 .piod_addr = &lookup_me_fromtracee,
3012 .piod_len = sizeof(lookup_me_fromtracee)
3014 struct ptrace_io_desc io_totracee = {
3015 .piod_op = PIOD_WRITE_D,
3016 .piod_offs = &lookup_me_totracee,
3017 .piod_addr = &lookup_me_totracee,
3018 .piod_len = sizeof(lookup_me_totracee)
3020 #if defined(TWAIT_HAVE_STATUS)
3024 printf("Before forking process PID=%d\n", getpid());
3025 ATF_REQUIRE((child = fork()) != -1);
3027 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3028 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3030 lookup_me_fromtracee = magic_fromtracee;
3032 printf("Before raising %s from child\n", strsignal(sigval));
3033 FORKEE_ASSERT(raise(sigval) == 0);
3035 FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee);
3037 printf("Before exiting of the child process\n");
3040 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3042 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3043 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3045 validate_status_stopped(status, sigval);
3047 printf("Read lookup_me_fromtracee PID=%d by tracer (PID=%d)\n",
3049 ATF_REQUIRE(ptrace(PT_IO, child, &io_fromtracee, 0) != -1);
3051 ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee,
3052 "got value %" PRIx8 " != expected %" PRIx8, lookup_me_fromtracee,
3055 lookup_me_totracee = magic_totracee;
3057 printf("Write lookup_me_totracee to PID=%d by tracer (PID=%d)\n",
3059 ATF_REQUIRE(ptrace(PT_IO, child, &io_totracee, 0) != -1);
3061 ATF_REQUIRE_EQ_MSG(lookup_me_totracee, magic_totracee,
3062 "got value %" PRIx8 " != expected %" PRIx8, lookup_me_totracee,
3065 printf("Before resuming the child process where it left off and "
3066 "without signal to be sent\n");
3067 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3069 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3070 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3072 validate_status_exited(status, exitval);
3074 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3075 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3078 ATF_TC(io_read_d_write_d_handshake2);
3079 ATF_TC_HEAD(io_read_d_write_d_handshake2, tc)
3081 atf_tc_set_md_var(tc, "descr",
3082 "Verify PT_IO with PIOD_WRITE_D and PIOD_READ_D handshake");
3085 ATF_TC_BODY(io_read_d_write_d_handshake2, tc)
3087 const int exitval = 5;
3088 const int sigval = SIGSTOP;
3090 uint8_t lookup_me_fromtracee = 0;
3091 const uint8_t magic_fromtracee = (uint8_t)random();
3092 uint8_t lookup_me_totracee = 0;
3093 const uint8_t magic_totracee = (uint8_t)random();
3094 struct ptrace_io_desc io_fromtracee = {
3095 .piod_op = PIOD_READ_D,
3096 .piod_offs = &lookup_me_fromtracee,
3097 .piod_addr = &lookup_me_fromtracee,
3098 .piod_len = sizeof(lookup_me_fromtracee)
3100 struct ptrace_io_desc io_totracee = {
3101 .piod_op = PIOD_WRITE_D,
3102 .piod_offs = &lookup_me_totracee,
3103 .piod_addr = &lookup_me_totracee,
3104 .piod_len = sizeof(lookup_me_totracee)
3106 #if defined(TWAIT_HAVE_STATUS)
3110 printf("Before forking process PID=%d\n", getpid());
3111 ATF_REQUIRE((child = fork()) != -1);
3113 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3114 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3116 lookup_me_fromtracee = magic_fromtracee;
3118 printf("Before raising %s from child\n", strsignal(sigval));
3119 FORKEE_ASSERT(raise(sigval) == 0);
3121 FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee);
3123 printf("Before exiting of the child process\n");
3126 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3128 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3129 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3131 validate_status_stopped(status, sigval);
3133 lookup_me_totracee = magic_totracee;
3135 printf("Write lookup_me_totracee to PID=%d by tracer (PID=%d)\n",
3137 ATF_REQUIRE(ptrace(PT_IO, child, &io_totracee, 0) != -1);
3139 ATF_REQUIRE_EQ_MSG(lookup_me_totracee, magic_totracee,
3140 "got value %" PRIx8 " != expected %" PRIx8, lookup_me_totracee,
3143 printf("Read lookup_me_fromtracee PID=%d by tracer (PID=%d)\n",
3145 ATF_REQUIRE(ptrace(PT_IO, child, &io_fromtracee, 0) != -1);
3147 ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee,
3148 "got value %" PRIx8 " != expected %" PRIx8, lookup_me_fromtracee,
3151 printf("Before resuming the child process where it left off and "
3152 "without signal to be sent\n");
3153 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3155 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3156 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3158 validate_status_exited(status, exitval);
3160 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3161 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3164 ATF_TC(read_d_write_d_handshake1);
3165 ATF_TC_HEAD(read_d_write_d_handshake1, tc)
3167 atf_tc_set_md_var(tc, "descr",
3168 "Verify PT_READ_D with PT_WRITE_D handshake");
3171 ATF_TC_BODY(read_d_write_d_handshake1, tc)
3173 const int exitval = 5;
3174 const int sigval = SIGSTOP;
3176 int lookup_me_fromtracee = 0;
3177 const int magic_fromtracee = (int)random();
3178 int lookup_me_totracee = 0;
3179 const int magic_totracee = (int)random();
3180 #if defined(TWAIT_HAVE_STATUS)
3184 printf("Before forking process PID=%d\n", getpid());
3185 ATF_REQUIRE((child = fork()) != -1);
3187 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3188 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3190 lookup_me_fromtracee = magic_fromtracee;
3192 printf("Before raising %s from child\n", strsignal(sigval));
3193 FORKEE_ASSERT(raise(sigval) == 0);
3195 FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee);
3197 printf("Before exiting of the child process\n");
3200 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3202 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3203 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3205 validate_status_stopped(status, sigval);
3207 printf("Read new lookup_me_fromtracee PID=%d by tracer (PID=%d)\n",
3210 lookup_me_fromtracee =
3211 ptrace(PT_READ_D, child, &lookup_me_fromtracee, 0);
3212 ATF_REQUIRE_EQ(errno, 0);
3214 ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee,
3215 "got value %#x != expected %#x", lookup_me_fromtracee,
3218 printf("Write new lookup_me_totracee to PID=%d from tracer (PID=%d)\n",
3221 (ptrace(PT_WRITE_D, child, &lookup_me_totracee, magic_totracee)
3224 printf("Before resuming the child process where it left off and "
3225 "without signal to be sent\n");
3226 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3228 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3229 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3231 validate_status_exited(status, exitval);
3233 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3234 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3237 ATF_TC(read_d_write_d_handshake2);
3238 ATF_TC_HEAD(read_d_write_d_handshake2, tc)
3240 atf_tc_set_md_var(tc, "descr",
3241 "Verify PT_WRITE_D with PT_READ_D handshake");
3244 ATF_TC_BODY(read_d_write_d_handshake2, tc)
3246 const int exitval = 5;
3247 const int sigval = SIGSTOP;
3249 int lookup_me_fromtracee = 0;
3250 const int magic_fromtracee = (int)random();
3251 int lookup_me_totracee = 0;
3252 const int magic_totracee = (int)random();
3253 #if defined(TWAIT_HAVE_STATUS)
3257 printf("Before forking process PID=%d\n", getpid());
3258 ATF_REQUIRE((child = fork()) != -1);
3260 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3261 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3263 lookup_me_fromtracee = magic_fromtracee;
3265 printf("Before raising %s from child\n", strsignal(sigval));
3266 FORKEE_ASSERT(raise(sigval) == 0);
3268 FORKEE_ASSERT_EQ(lookup_me_totracee, magic_totracee);
3270 printf("Before exiting of the child process\n");
3273 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3275 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3276 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3278 validate_status_stopped(status, sigval);
3280 printf("Write new lookup_me_totracee to PID=%d from tracer (PID=%d)\n",
3283 (ptrace(PT_WRITE_D, child, &lookup_me_totracee, magic_totracee)
3286 printf("Read new lookup_me_fromtracee PID=%d by tracer (PID=%d)\n",
3289 lookup_me_fromtracee =
3290 ptrace(PT_READ_D, child, &lookup_me_fromtracee, 0);
3291 ATF_REQUIRE_EQ(errno, 0);
3293 ATF_REQUIRE_EQ_MSG(lookup_me_fromtracee, magic_fromtracee,
3294 "got value %#x != expected %#x", lookup_me_fromtracee,
3297 printf("Before resuming the child process where it left off and "
3298 "without signal to be sent\n");
3299 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3301 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3302 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3304 validate_status_exited(status, exitval);
3306 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3307 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3310 /* These dummy functions are used to be copied with ptrace(2) calls */
3312 dummy_fn1(int a, int b, int c, int d)
3320 return a + b * c - d;
3324 dummy_fn2(int a, int b, int c, int d)
3332 return a + b * c - d;
3336 dummy_fn3(int a, int b, int c, int d)
3344 return a + b * c - d;
3348 dummy_fn4(int a, int b, int c, int d)
3356 return a + b * c - d;
3360 ATF_TC_HEAD(io_read_i1, tc)
3362 atf_tc_set_md_var(tc, "descr",
3363 "Verify PT_IO with PIOD_READ_I and len = sizeof(uint8_t)");
3366 ATF_TC_BODY(io_read_i1, tc)
3368 const int exitval = 5;
3369 const int sigval = SIGSTOP;
3371 uint8_t lookup_me = 0;
3373 memcpy(&magic, dummy_fn1, sizeof(magic));
3374 struct ptrace_io_desc io = {
3375 .piod_op = PIOD_READ_I,
3376 .piod_offs = dummy_fn1,
3377 .piod_addr = &lookup_me,
3378 .piod_len = sizeof(lookup_me)
3380 #if defined(TWAIT_HAVE_STATUS)
3384 printf("Before forking process PID=%d\n", getpid());
3385 ATF_REQUIRE((child = fork()) != -1);
3387 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3388 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3390 printf("Before raising %s from child\n", strsignal(sigval));
3391 FORKEE_ASSERT(raise(sigval) == 0);
3393 printf("Before exiting of the child process\n");
3396 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3398 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3399 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3401 validate_status_stopped(status, sigval);
3403 printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
3405 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
3407 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
3408 "got value %" PRIx8 " != expected %" PRIx8, lookup_me, magic);
3410 printf("Before resuming the child process where it left off and "
3411 "without signal to be sent\n");
3412 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3414 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3415 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3417 validate_status_exited(status, exitval);
3419 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3420 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3424 ATF_TC_HEAD(io_read_i2, tc)
3426 atf_tc_set_md_var(tc, "descr",
3427 "Verify PT_IO with PIOD_READ_I and len = sizeof(uint16_t)");
3430 ATF_TC_BODY(io_read_i2, tc)
3432 const int exitval = 5;
3433 const int sigval = SIGSTOP;
3435 uint16_t lookup_me = 0;
3437 memcpy(&magic, dummy_fn1, sizeof(magic));
3438 struct ptrace_io_desc io = {
3439 .piod_op = PIOD_READ_I,
3440 .piod_offs = dummy_fn1,
3441 .piod_addr = &lookup_me,
3442 .piod_len = sizeof(lookup_me)
3444 #if defined(TWAIT_HAVE_STATUS)
3448 printf("Before forking process PID=%d\n", getpid());
3449 ATF_REQUIRE((child = fork()) != -1);
3451 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3452 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3454 printf("Before raising %s from child\n", strsignal(sigval));
3455 FORKEE_ASSERT(raise(sigval) == 0);
3457 printf("Before exiting of the child process\n");
3460 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3462 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3463 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3465 validate_status_stopped(status, sigval);
3467 printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
3469 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
3471 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
3472 "got value %" PRIx16 " != expected %" PRIx16, lookup_me, magic);
3474 printf("Before resuming the child process where it left off and "
3475 "without signal to be sent\n");
3476 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3478 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3479 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3481 validate_status_exited(status, exitval);
3483 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3484 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3488 ATF_TC_HEAD(io_read_i3, tc)
3490 atf_tc_set_md_var(tc, "descr",
3491 "Verify PT_IO with PIOD_READ_I and len = sizeof(uint32_t)");
3494 ATF_TC_BODY(io_read_i3, tc)
3496 const int exitval = 5;
3497 const int sigval = SIGSTOP;
3499 uint32_t lookup_me = 0;
3501 memcpy(&magic, dummy_fn1, sizeof(magic));
3502 struct ptrace_io_desc io = {
3503 .piod_op = PIOD_READ_I,
3504 .piod_offs = dummy_fn1,
3505 .piod_addr = &lookup_me,
3506 .piod_len = sizeof(lookup_me)
3508 #if defined(TWAIT_HAVE_STATUS)
3512 printf("Before forking process PID=%d\n", getpid());
3513 ATF_REQUIRE((child = fork()) != -1);
3515 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3516 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3518 printf("Before raising %s from child\n", strsignal(sigval));
3519 FORKEE_ASSERT(raise(sigval) == 0);
3521 printf("Before exiting of the child process\n");
3524 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3526 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3527 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3529 validate_status_stopped(status, sigval);
3531 printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
3533 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
3535 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
3536 "got value %" PRIx32 " != expected %" PRIx32, lookup_me, magic);
3538 printf("Before resuming the child process where it left off and "
3539 "without signal to be sent\n");
3540 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3542 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3543 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3545 validate_status_exited(status, exitval);
3547 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3548 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3552 ATF_TC_HEAD(io_read_i4, tc)
3554 atf_tc_set_md_var(tc, "descr",
3555 "Verify PT_IO with PIOD_READ_I and len = sizeof(uint64_t)");
3558 ATF_TC_BODY(io_read_i4, tc)
3560 const int exitval = 5;
3561 const int sigval = SIGSTOP;
3563 uint64_t lookup_me = 0;
3565 memcpy(&magic, dummy_fn1, sizeof(magic));
3566 struct ptrace_io_desc io = {
3567 .piod_op = PIOD_READ_I,
3568 .piod_offs = dummy_fn1,
3569 .piod_addr = &lookup_me,
3570 .piod_len = sizeof(lookup_me)
3572 #if defined(TWAIT_HAVE_STATUS)
3576 printf("Before forking process PID=%d\n", getpid());
3577 ATF_REQUIRE((child = fork()) != -1);
3579 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3580 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3582 printf("Before raising %s from child\n", strsignal(sigval));
3583 FORKEE_ASSERT(raise(sigval) == 0);
3585 printf("Before exiting of the child process\n");
3588 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3590 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3591 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3593 validate_status_stopped(status, sigval);
3595 printf("Read lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
3597 ATF_REQUIRE(ptrace(PT_IO, child, &io, 0) != -1);
3599 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
3600 "got value %" PRIx64 " != expected %" PRIx64, lookup_me, magic);
3602 printf("Before resuming the child process where it left off and "
3603 "without signal to be sent\n");
3604 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3606 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3607 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3609 validate_status_exited(status, exitval);
3611 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3612 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3616 ATF_TC_HEAD(read_i1, tc)
3618 atf_tc_set_md_var(tc, "descr",
3619 "Verify PT_READ_I called once");
3622 ATF_TC_BODY(read_i1, tc)
3624 const int exitval = 5;
3625 const int sigval = SIGSTOP;
3629 memcpy(&magic, dummy_fn1, sizeof(magic));
3630 #if defined(TWAIT_HAVE_STATUS)
3634 printf("Before forking process PID=%d\n", getpid());
3635 ATF_REQUIRE((child = fork()) != -1);
3637 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3638 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3640 printf("Before raising %s from child\n", strsignal(sigval));
3641 FORKEE_ASSERT(raise(sigval) == 0);
3643 printf("Before exiting of the child process\n");
3646 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3648 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3649 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3651 validate_status_stopped(status, sigval);
3653 printf("Read new lookup_me from tracee (PID=%d) by tracer (PID=%d)\n",
3656 lookup_me = ptrace(PT_READ_I, child, dummy_fn1, 0);
3657 ATF_REQUIRE_EQ(errno, 0);
3659 ATF_REQUIRE_EQ_MSG(lookup_me, magic,
3660 "got value %#x != expected %#x", lookup_me, magic);
3662 printf("Before resuming the child process where it left off and "
3663 "without signal to be sent\n");
3664 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3666 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3667 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3669 validate_status_exited(status, exitval);
3671 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3672 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3676 ATF_TC_HEAD(read_i2, tc)
3678 atf_tc_set_md_var(tc, "descr",
3679 "Verify PT_READ_I called twice");
3682 ATF_TC_BODY(read_i2, tc)
3684 const int exitval = 5;
3685 const int sigval = SIGSTOP;
3691 memcpy(&magic1, dummy_fn1, sizeof(magic1));
3692 memcpy(&magic2, dummy_fn2, sizeof(magic2));
3693 #if defined(TWAIT_HAVE_STATUS)
3697 printf("Before forking process PID=%d\n", getpid());
3698 ATF_REQUIRE((child = fork()) != -1);
3700 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3701 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3703 printf("Before raising %s from child\n", strsignal(sigval));
3704 FORKEE_ASSERT(raise(sigval) == 0);
3706 printf("Before exiting of the child process\n");
3709 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3711 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3712 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3714 validate_status_stopped(status, sigval);
3716 printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
3719 lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0);
3720 ATF_REQUIRE_EQ(errno, 0);
3722 ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
3723 "got value %#x != expected %#x", lookup_me1, magic1);
3725 printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
3728 lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0);
3729 ATF_REQUIRE_EQ(errno, 0);
3731 ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
3732 "got value %#x != expected %#x", lookup_me2, magic2);
3734 printf("Before resuming the child process where it left off and "
3735 "without signal to be sent\n");
3736 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3738 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3739 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3741 validate_status_exited(status, exitval);
3743 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3744 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3748 ATF_TC_HEAD(read_i3, tc)
3750 atf_tc_set_md_var(tc, "descr",
3751 "Verify PT_READ_I called three times");
3754 ATF_TC_BODY(read_i3, tc)
3756 const int exitval = 5;
3757 const int sigval = SIGSTOP;
3765 memcpy(&magic1, dummy_fn1, sizeof(magic1));
3766 memcpy(&magic2, dummy_fn2, sizeof(magic2));
3767 memcpy(&magic3, dummy_fn3, sizeof(magic3));
3768 #if defined(TWAIT_HAVE_STATUS)
3772 printf("Before forking process PID=%d\n", getpid());
3773 ATF_REQUIRE((child = fork()) != -1);
3775 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3776 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3778 printf("Before raising %s from child\n", strsignal(sigval));
3779 FORKEE_ASSERT(raise(sigval) == 0);
3781 printf("Before exiting of the child process\n");
3784 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3786 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3787 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3789 validate_status_stopped(status, sigval);
3791 printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
3794 lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0);
3795 ATF_REQUIRE_EQ(errno, 0);
3797 ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
3798 "got value %#x != expected %#x", lookup_me1, magic1);
3800 printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
3803 lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0);
3804 ATF_REQUIRE_EQ(errno, 0);
3806 ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
3807 "got value %#x != expected %#x", lookup_me2, magic2);
3809 printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n",
3812 lookup_me3 = ptrace(PT_READ_I, child, dummy_fn3, 0);
3813 ATF_REQUIRE_EQ(errno, 0);
3815 ATF_REQUIRE_EQ_MSG(lookup_me3, magic3,
3816 "got value %#x != expected %#x", lookup_me3, magic3);
3818 printf("Before resuming the child process where it left off and "
3819 "without signal to be sent\n");
3820 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3822 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3823 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3825 validate_status_exited(status, exitval);
3827 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3828 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3832 ATF_TC_HEAD(read_i4, tc)
3834 atf_tc_set_md_var(tc, "descr",
3835 "Verify PT_READ_I called four times");
3838 ATF_TC_BODY(read_i4, tc)
3840 const int exitval = 5;
3841 const int sigval = SIGSTOP;
3851 memcpy(&magic1, dummy_fn1, sizeof(magic1));
3852 memcpy(&magic2, dummy_fn2, sizeof(magic2));
3853 memcpy(&magic3, dummy_fn3, sizeof(magic3));
3854 memcpy(&magic4, dummy_fn4, sizeof(magic4));
3855 #if defined(TWAIT_HAVE_STATUS)
3859 printf("Before forking process PID=%d\n", getpid());
3860 ATF_REQUIRE((child = fork()) != -1);
3862 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3863 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3865 printf("Before raising %s from child\n", strsignal(sigval));
3866 FORKEE_ASSERT(raise(sigval) == 0);
3868 printf("Before exiting of the child process\n");
3871 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3873 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3874 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3876 validate_status_stopped(status, sigval);
3878 printf("Read new lookup_me1 from tracee (PID=%d) by tracer (PID=%d)\n",
3881 lookup_me1 = ptrace(PT_READ_I, child, dummy_fn1, 0);
3882 ATF_REQUIRE_EQ(errno, 0);
3884 ATF_REQUIRE_EQ_MSG(lookup_me1, magic1,
3885 "got value %#x != expected %#x", lookup_me1, magic1);
3887 printf("Read new lookup_me2 from tracee (PID=%d) by tracer (PID=%d)\n",
3890 lookup_me2 = ptrace(PT_READ_I, child, dummy_fn2, 0);
3891 ATF_REQUIRE_EQ(errno, 0);
3893 ATF_REQUIRE_EQ_MSG(lookup_me2, magic2,
3894 "got value %#x != expected %#x", lookup_me2, magic2);
3896 printf("Read new lookup_me3 from tracee (PID=%d) by tracer (PID=%d)\n",
3899 lookup_me3 = ptrace(PT_READ_I, child, dummy_fn3, 0);
3900 ATF_REQUIRE_EQ(errno, 0);
3902 ATF_REQUIRE_EQ_MSG(lookup_me3, magic3,
3903 "got value %#x != expected %#x", lookup_me3, magic3);
3905 printf("Read new lookup_me4 from tracee (PID=%d) by tracer (PID=%d)\n",
3908 lookup_me4 = ptrace(PT_READ_I, child, dummy_fn4, 0);
3909 ATF_REQUIRE_EQ(errno, 0);
3911 ATF_REQUIRE_EQ_MSG(lookup_me4, magic4,
3912 "got value %#x != expected %#x", lookup_me4, magic4);
3914 printf("Before resuming the child process where it left off and "
3915 "without signal to be sent\n");
3916 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3918 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3919 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3921 validate_status_exited(status, exitval);
3923 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3924 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3927 #if defined(HAVE_GPREGS)
3929 ATF_TC_HEAD(regs1, tc)
3931 atf_tc_set_md_var(tc, "descr",
3932 "Verify plain PT_GETREGS call without further steps");
3935 ATF_TC_BODY(regs1, tc)
3937 const int exitval = 5;
3938 const int sigval = SIGSTOP;
3940 #if defined(TWAIT_HAVE_STATUS)
3945 printf("Before forking process PID=%d\n", getpid());
3946 ATF_REQUIRE((child = fork()) != -1);
3948 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
3949 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
3951 printf("Before raising %s from child\n", strsignal(sigval));
3952 FORKEE_ASSERT(raise(sigval) == 0);
3954 printf("Before exiting of the child process\n");
3957 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
3959 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3960 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3962 validate_status_stopped(status, sigval);
3964 printf("Call GETREGS for the child process\n");
3965 ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
3967 printf("Before resuming the child process where it left off and "
3968 "without signal to be sent\n");
3969 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
3971 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3972 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
3974 validate_status_exited(status, exitval);
3976 printf("Before calling %s() for the child\n", TWAIT_FNAME);
3977 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
3981 #if defined(HAVE_GPREGS)
3983 ATF_TC_HEAD(regs2, tc)
3985 atf_tc_set_md_var(tc, "descr",
3986 "Verify plain PT_GETREGS call and retrieve PC");
3989 ATF_TC_BODY(regs2, tc)
3991 const int exitval = 5;
3992 const int sigval = SIGSTOP;
3994 #if defined(TWAIT_HAVE_STATUS)
3999 printf("Before forking process PID=%d\n", getpid());
4000 ATF_REQUIRE((child = fork()) != -1);
4002 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4003 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4005 printf("Before raising %s from child\n", strsignal(sigval));
4006 FORKEE_ASSERT(raise(sigval) == 0);
4008 printf("Before exiting of the child process\n");
4011 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4013 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4014 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4016 validate_status_stopped(status, sigval);
4018 printf("Call GETREGS for the child process\n");
4019 ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
4021 printf("Retrieved PC=%" PRIxREGISTER "\n", PTRACE_REG_PC(&r));
4023 printf("Before resuming the child process where it left off and "
4024 "without signal to be sent\n");
4025 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4027 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4028 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4030 validate_status_exited(status, exitval);
4032 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4033 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4037 #if defined(HAVE_GPREGS)
4039 ATF_TC_HEAD(regs3, tc)
4041 atf_tc_set_md_var(tc, "descr",
4042 "Verify plain PT_GETREGS call and retrieve SP");
4045 ATF_TC_BODY(regs3, tc)
4047 const int exitval = 5;
4048 const int sigval = SIGSTOP;
4050 #if defined(TWAIT_HAVE_STATUS)
4055 printf("Before forking process PID=%d\n", getpid());
4056 ATF_REQUIRE((child = fork()) != -1);
4058 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4059 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4061 printf("Before raising %s from child\n", strsignal(sigval));
4062 FORKEE_ASSERT(raise(sigval) == 0);
4064 printf("Before exiting of the child process\n");
4067 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4069 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4070 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4072 validate_status_stopped(status, sigval);
4074 printf("Call GETREGS for the child process\n");
4075 ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
4077 printf("Retrieved SP=%" PRIxREGISTER "\n", PTRACE_REG_SP(&r));
4079 printf("Before resuming the child process where it left off and "
4080 "without signal to be sent\n");
4081 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4083 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4084 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4086 validate_status_exited(status, exitval);
4088 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4089 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4093 #if defined(HAVE_GPREGS)
4095 ATF_TC_HEAD(regs4, tc)
4097 atf_tc_set_md_var(tc, "descr",
4098 "Verify plain PT_GETREGS call and retrieve INTRV");
4101 ATF_TC_BODY(regs4, tc)
4103 const int exitval = 5;
4104 const int sigval = SIGSTOP;
4106 #if defined(TWAIT_HAVE_STATUS)
4111 printf("Before forking process PID=%d\n", getpid());
4112 ATF_REQUIRE((child = fork()) != -1);
4114 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4115 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4117 printf("Before raising %s from child\n", strsignal(sigval));
4118 FORKEE_ASSERT(raise(sigval) == 0);
4120 printf("Before exiting of the child process\n");
4123 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4125 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4126 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4128 validate_status_stopped(status, sigval);
4130 printf("Call GETREGS for the child process\n");
4131 ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
4133 printf("Retrieved INTRV=%" PRIxREGISTER "\n", PTRACE_REG_INTRV(&r));
4135 printf("Before resuming the child process where it left off and "
4136 "without signal to be sent\n");
4137 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4139 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4140 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4142 validate_status_exited(status, exitval);
4144 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4145 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4149 #if defined(HAVE_GPREGS)
4151 ATF_TC_HEAD(regs5, tc)
4153 atf_tc_set_md_var(tc, "descr",
4154 "Verify PT_GETREGS and PT_SETREGS calls without changing regs");
4157 ATF_TC_BODY(regs5, tc)
4159 const int exitval = 5;
4160 const int sigval = SIGSTOP;
4162 #if defined(TWAIT_HAVE_STATUS)
4167 printf("Before forking process PID=%d\n", getpid());
4168 ATF_REQUIRE((child = fork()) != -1);
4170 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4171 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4173 printf("Before raising %s from child\n", strsignal(sigval));
4174 FORKEE_ASSERT(raise(sigval) == 0);
4176 printf("Before exiting of the child process\n");
4179 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4181 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4182 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4184 validate_status_stopped(status, sigval);
4186 printf("Call GETREGS for the child process\n");
4187 ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
4189 printf("Call SETREGS for the child process (without changed regs)\n");
4190 ATF_REQUIRE(ptrace(PT_GETREGS, child, &r, 0) != -1);
4192 printf("Before resuming the child process where it left off and "
4193 "without signal to be sent\n");
4194 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4196 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4197 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4199 validate_status_exited(status, exitval);
4201 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4202 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4206 #if defined(HAVE_FPREGS)
4208 ATF_TC_HEAD(fpregs1, tc)
4210 atf_tc_set_md_var(tc, "descr",
4211 "Verify plain PT_GETFPREGS call without further steps");
4214 ATF_TC_BODY(fpregs1, tc)
4216 const int exitval = 5;
4217 const int sigval = SIGSTOP;
4219 #if defined(TWAIT_HAVE_STATUS)
4224 printf("Before forking process PID=%d\n", getpid());
4225 ATF_REQUIRE((child = fork()) != -1);
4227 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4228 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4230 printf("Before raising %s from child\n", strsignal(sigval));
4231 FORKEE_ASSERT(raise(sigval) == 0);
4233 printf("Before exiting of the child process\n");
4236 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4238 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4239 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4241 validate_status_stopped(status, sigval);
4243 printf("Call GETFPREGS for the child process\n");
4244 ATF_REQUIRE(ptrace(PT_GETFPREGS, child, &r, 0) != -1);
4246 printf("Before resuming the child process where it left off and "
4247 "without signal to be sent\n");
4248 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4250 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4251 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4253 validate_status_exited(status, exitval);
4255 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4256 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4260 #if defined(HAVE_FPREGS)
4262 ATF_TC_HEAD(fpregs2, tc)
4264 atf_tc_set_md_var(tc, "descr",
4265 "Verify PT_GETFPREGS and PT_SETFPREGS calls without changing "
4269 ATF_TC_BODY(fpregs2, tc)
4271 const int exitval = 5;
4272 const int sigval = SIGSTOP;
4274 #if defined(TWAIT_HAVE_STATUS)
4279 printf("Before forking process PID=%d\n", getpid());
4280 ATF_REQUIRE((child = fork()) != -1);
4282 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4283 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4285 printf("Before raising %s from child\n", strsignal(sigval));
4286 FORKEE_ASSERT(raise(sigval) == 0);
4288 printf("Before exiting of the child process\n");
4291 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4293 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4294 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4296 validate_status_stopped(status, sigval);
4298 printf("Call GETFPREGS for the child process\n");
4299 ATF_REQUIRE(ptrace(PT_GETFPREGS, child, &r, 0) != -1);
4301 printf("Call SETFPREGS for the child (without changed regs)\n");
4302 ATF_REQUIRE(ptrace(PT_SETFPREGS, child, &r, 0) != -1);
4304 printf("Before resuming the child process where it left off and "
4305 "without signal to be sent\n");
4306 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4308 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4309 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4311 validate_status_exited(status, exitval);
4313 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4314 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4318 #if defined(PT_STEP)
4320 ATF_TC_HEAD(step1, tc)
4322 atf_tc_set_md_var(tc, "descr",
4323 "Verify single PT_STEP call");
4326 ATF_TC_BODY(step1, tc)
4328 const int exitval = 5;
4329 const int sigval = SIGSTOP;
4331 #if defined(TWAIT_HAVE_STATUS)
4336 printf("Before forking process PID=%d\n", getpid());
4337 ATF_REQUIRE((child = fork()) != -1);
4339 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4340 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4342 happy = check_happy(100);
4344 printf("Before raising %s from child\n", strsignal(sigval));
4345 FORKEE_ASSERT(raise(sigval) == 0);
4347 FORKEE_ASSERT_EQ(happy, check_happy(100));
4349 printf("Before exiting of the child process\n");
4352 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4354 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4355 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4357 validate_status_stopped(status, sigval);
4359 printf("Before resuming the child process where it left off and "
4360 "without signal to be sent (use PT_STEP)\n");
4361 ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
4363 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4364 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4366 validate_status_stopped(status, SIGTRAP);
4368 printf("Before resuming the child process where it left off and "
4369 "without signal to be sent\n");
4370 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4372 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4373 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4375 validate_status_exited(status, exitval);
4377 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4378 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4382 #if defined(PT_STEP)
4384 ATF_TC_HEAD(step2, tc)
4386 atf_tc_set_md_var(tc, "descr",
4387 "Verify PT_STEP called twice");
4390 ATF_TC_BODY(step2, tc)
4392 const int exitval = 5;
4393 const int sigval = SIGSTOP;
4395 #if defined(TWAIT_HAVE_STATUS)
4401 printf("Before forking process PID=%d\n", getpid());
4402 ATF_REQUIRE((child = fork()) != -1);
4404 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4405 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4407 happy = check_happy(999);
4409 printf("Before raising %s from child\n", strsignal(sigval));
4410 FORKEE_ASSERT(raise(sigval) == 0);
4412 FORKEE_ASSERT_EQ(happy, check_happy(999));
4414 printf("Before exiting of the child process\n");
4417 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4419 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4420 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4422 validate_status_stopped(status, sigval);
4425 printf("Before resuming the child process where it left off "
4426 "and without signal to be sent (use PT_STEP)\n");
4427 ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
4429 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4430 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
4433 validate_status_stopped(status, SIGTRAP);
4436 printf("Before resuming the child process where it left off and "
4437 "without signal to be sent\n");
4438 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4440 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4441 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4443 validate_status_exited(status, exitval);
4445 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4446 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4450 #if defined(PT_STEP)
4452 ATF_TC_HEAD(step3, tc)
4454 atf_tc_set_md_var(tc, "descr",
4455 "Verify PT_STEP called three times");
4458 ATF_TC_BODY(step3, tc)
4460 const int exitval = 5;
4461 const int sigval = SIGSTOP;
4463 #if defined(TWAIT_HAVE_STATUS)
4469 printf("Before forking process PID=%d\n", getpid());
4470 ATF_REQUIRE((child = fork()) != -1);
4472 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4473 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4475 happy = check_happy(999);
4477 printf("Before raising %s from child\n", strsignal(sigval));
4478 FORKEE_ASSERT(raise(sigval) == 0);
4480 FORKEE_ASSERT_EQ(happy, check_happy(999));
4482 printf("Before exiting of the child process\n");
4485 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4487 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4488 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4490 validate_status_stopped(status, sigval);
4493 printf("Before resuming the child process where it left off "
4494 "and without signal to be sent (use PT_STEP)\n");
4495 ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
4497 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4498 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
4501 validate_status_stopped(status, SIGTRAP);
4504 printf("Before resuming the child process where it left off and "
4505 "without signal to be sent\n");
4506 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4508 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4509 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4511 validate_status_exited(status, exitval);
4513 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4514 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4518 #if defined(PT_STEP)
4520 ATF_TC_HEAD(step4, tc)
4522 atf_tc_set_md_var(tc, "descr",
4523 "Verify PT_STEP called four times");
4526 ATF_TC_BODY(step4, tc)
4528 const int exitval = 5;
4529 const int sigval = SIGSTOP;
4531 #if defined(TWAIT_HAVE_STATUS)
4537 printf("Before forking process PID=%d\n", getpid());
4538 ATF_REQUIRE((child = fork()) != -1);
4540 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4541 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4543 happy = check_happy(999);
4545 printf("Before raising %s from child\n", strsignal(sigval));
4546 FORKEE_ASSERT(raise(sigval) == 0);
4548 FORKEE_ASSERT_EQ(happy, check_happy(999));
4550 printf("Before exiting of the child process\n");
4553 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4555 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4556 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4558 validate_status_stopped(status, sigval);
4561 printf("Before resuming the child process where it left off "
4562 "and without signal to be sent (use PT_STEP)\n");
4563 ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
4565 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4566 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0),
4569 validate_status_stopped(status, SIGTRAP);
4572 printf("Before resuming the child process where it left off and "
4573 "without signal to be sent\n");
4574 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4576 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4577 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4579 validate_status_exited(status, exitval);
4581 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4582 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4587 ATF_TC_HEAD(kill1, tc)
4589 atf_tc_set_md_var(tc, "descr",
4590 "Verify that PT_CONTINUE with SIGKILL terminates child");
4593 ATF_TC_BODY(kill1, tc)
4595 const int sigval = SIGSTOP, sigsent = SIGKILL;
4597 #if defined(TWAIT_HAVE_STATUS)
4601 printf("Before forking process PID=%d\n", getpid());
4602 ATF_REQUIRE((child = fork()) != -1);
4604 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4605 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4607 printf("Before raising %s from child\n", strsignal(sigval));
4608 FORKEE_ASSERT(raise(sigval) == 0);
4612 "Child should be terminated by a signal from its parent");
4614 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4616 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4617 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4619 validate_status_stopped(status, sigval);
4621 printf("Before resuming the child process where it left off and "
4622 "without signal to be sent\n");
4623 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigsent) != -1);
4625 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4626 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4628 validate_status_signaled(status, sigsent, 0);
4630 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4631 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4635 ATF_TC_HEAD(kill2, tc)
4637 atf_tc_set_md_var(tc, "descr",
4638 "Verify that PT_KILL terminates child");
4641 ATF_TC_BODY(kill2, tc)
4643 const int sigval = SIGSTOP;
4645 #if defined(TWAIT_HAVE_STATUS)
4649 printf("Before forking process PID=%d\n", getpid());
4650 ATF_REQUIRE((child = fork()) != -1);
4652 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4653 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4655 printf("Before raising %s from child\n", strsignal(sigval));
4656 FORKEE_ASSERT(raise(sigval) == 0);
4660 "Child should be terminated by a signal from its parent");
4662 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4664 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4665 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4667 validate_status_stopped(status, sigval);
4669 printf("Before resuming the child process where it left off and "
4670 "without signal to be sent\n");
4671 ATF_REQUIRE(ptrace(PT_KILL, child, (void*)1, 0) != -1);
4673 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4674 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4676 validate_status_signaled(status, SIGKILL, 0);
4678 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4679 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4683 ATF_TC_HEAD(lwpinfo1, tc)
4685 atf_tc_set_md_var(tc, "descr",
4686 "Verify basic LWPINFO call for single thread (PT_TRACE_ME)");
4689 ATF_TC_BODY(lwpinfo1, tc)
4691 const int exitval = 5;
4692 const int sigval = SIGSTOP;
4694 #if defined(TWAIT_HAVE_STATUS)
4697 struct ptrace_lwpinfo info = {0, 0};
4699 printf("Before forking process PID=%d\n", getpid());
4700 ATF_REQUIRE((child = fork()) != -1);
4702 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4703 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4705 printf("Before raising %s from child\n", strsignal(sigval));
4706 FORKEE_ASSERT(raise(sigval) == 0);
4708 printf("Before exiting of the child process\n");
4711 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4713 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4714 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4716 validate_status_stopped(status, sigval);
4718 printf("Before calling ptrace(2) with PT_LWPINFO for child\n");
4719 ATF_REQUIRE(ptrace(PT_LWPINFO, child, &info, sizeof(info)) != -1);
4721 printf("Assert that there exists a thread\n");
4722 ATF_REQUIRE(info.pl_lwpid > 0);
4724 printf("Assert that lwp thread %d received event PL_EVENT_SIGNAL\n",
4726 ATF_REQUIRE_EQ_MSG(info.pl_event, PL_EVENT_SIGNAL,
4727 "Received event %d != expected event %d",
4728 info.pl_event, PL_EVENT_SIGNAL);
4730 printf("Before calling ptrace(2) with PT_LWPINFO for child\n");
4731 ATF_REQUIRE(ptrace(PT_LWPINFO, child, &info, sizeof(info)) != -1);
4733 printf("Assert that there are no more lwp threads in child\n");
4734 ATF_REQUIRE_EQ(info.pl_lwpid, 0);
4736 printf("Before resuming the child process where it left off and "
4737 "without signal to be sent\n");
4738 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4740 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4741 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4743 validate_status_exited(status, exitval);
4745 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4746 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4749 #if defined(TWAIT_HAVE_PID)
4751 ATF_TC_HEAD(lwpinfo2, tc)
4753 atf_tc_set_md_var(tc, "descr",
4754 "Verify basic LWPINFO call for single thread (PT_ATTACH from "
4758 ATF_TC_BODY(lwpinfo2, tc)
4760 struct msg_fds parent_tracee, parent_tracer;
4761 const int exitval_tracee = 5;
4762 const int exitval_tracer = 10;
4763 pid_t tracee, tracer, wpid;
4764 uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
4765 #if defined(TWAIT_HAVE_STATUS)
4768 struct ptrace_lwpinfo info = {0, 0};
4770 printf("Spawn tracee\n");
4771 ATF_REQUIRE(msg_open(&parent_tracee) == 0);
4772 ATF_REQUIRE(msg_open(&parent_tracer) == 0);
4773 tracee = atf_utils_fork();
4776 /* Wait for message from the parent */
4777 CHILD_TO_PARENT("tracee ready", parent_tracee, msg);
4778 CHILD_FROM_PARENT("tracee exit", parent_tracee, msg);
4780 _exit(exitval_tracee);
4782 PARENT_FROM_CHILD("tracee ready", parent_tracee, msg);
4784 printf("Spawn debugger\n");
4785 tracer = atf_utils_fork();
4787 /* No IPC to communicate with the child */
4788 printf("Before calling PT_ATTACH from tracee %d\n", getpid());
4789 FORKEE_ASSERT(ptrace(PT_ATTACH, tracee, NULL, 0) != -1);
4791 /* Wait for tracee and assert that it was stopped w/ SIGSTOP */
4792 FORKEE_REQUIRE_SUCCESS(
4793 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
4795 forkee_status_stopped(status, SIGSTOP);
4797 printf("Before calling ptrace(2) with PT_LWPINFO for child\n");
4798 FORKEE_ASSERT(ptrace(PT_LWPINFO, tracee, &info, sizeof(info))
4801 printf("Assert that there exists a thread\n");
4802 FORKEE_ASSERTX(info.pl_lwpid > 0);
4804 printf("Assert that lwp thread %d received event "
4805 "PL_EVENT_SIGNAL\n", info.pl_lwpid);
4806 FORKEE_ASSERT_EQ(info.pl_event, PL_EVENT_SIGNAL);
4808 printf("Before calling ptrace(2) with PT_LWPINFO for child\n");
4809 FORKEE_ASSERT(ptrace(PT_LWPINFO, tracee, &info, sizeof(info))
4812 printf("Assert that there are no more lwp threads in child\n");
4813 FORKEE_ASSERTX(info.pl_lwpid == 0);
4815 /* Resume tracee with PT_CONTINUE */
4816 FORKEE_ASSERT(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
4818 /* Inform parent that tracer has attached to tracee */
4819 CHILD_TO_PARENT("tracer ready", parent_tracer, msg);
4820 /* Wait for parent */
4821 CHILD_FROM_PARENT("tracer wait", parent_tracer, msg);
4823 /* Wait for tracee and assert that it exited */
4824 FORKEE_REQUIRE_SUCCESS(
4825 wpid = TWAIT_GENERIC(tracee, &status, 0), tracee);
4827 forkee_status_exited(status, exitval_tracee);
4829 printf("Before exiting of the tracer process\n");
4830 _exit(exitval_tracer);
4833 printf("Wait for the tracer to attach to the tracee\n");
4834 PARENT_FROM_CHILD("tracer ready", parent_tracer, msg);
4836 printf("Resume the tracee and let it exit\n");
4837 PARENT_TO_CHILD("tracee exit", parent_tracee, msg);
4839 printf("Detect that tracee is zombie\n");
4840 await_zombie(tracee);
4842 printf("Assert that there is no status about tracee - "
4843 "Tracer must detect zombie first - calling %s()\n", TWAIT_FNAME);
4844 TWAIT_REQUIRE_SUCCESS(
4845 wpid = TWAIT_GENERIC(tracee, &status, WNOHANG), 0);
4847 printf("Resume the tracer and let it detect exited tracee\n");
4848 PARENT_TO_CHILD("tracer wait", parent_tracer, msg);
4850 printf("Wait for tracer to finish its job and exit - calling %s()\n",
4852 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracer, &status, 0),
4855 validate_status_exited(status, exitval_tracer);
4857 printf("Wait for tracee to finish its job and exit - calling %s()\n",
4859 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, &status, WNOHANG),
4862 validate_status_exited(status, exitval_tracee);
4864 msg_close(&parent_tracer);
4865 msg_close(&parent_tracee);
4870 ATF_TC_HEAD(siginfo1, tc)
4872 atf_tc_set_md_var(tc, "descr",
4873 "Verify basic PT_GET_SIGINFO call for SIGTRAP from tracee");
4876 ATF_TC_BODY(siginfo1, tc)
4878 const int exitval = 5;
4879 const int sigval = SIGTRAP;
4881 #if defined(TWAIT_HAVE_STATUS)
4884 struct ptrace_siginfo info;
4885 memset(&info, 0, sizeof(info));
4887 printf("Before forking process PID=%d\n", getpid());
4888 ATF_REQUIRE((child = fork()) != -1);
4890 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4891 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4893 printf("Before raising %s from child\n", strsignal(sigval));
4894 FORKEE_ASSERT(raise(sigval) == 0);
4896 printf("Before exiting of the child process\n");
4899 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4901 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4902 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4904 validate_status_stopped(status, sigval);
4906 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
4907 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
4909 printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
4910 printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
4911 info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
4912 info.psi_siginfo.si_errno);
4914 printf("Before resuming the child process where it left off and "
4915 "without signal to be sent\n");
4916 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
4918 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4919 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4921 validate_status_exited(status, exitval);
4923 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4924 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
4928 ATF_TC_HEAD(siginfo2, tc)
4930 atf_tc_set_md_var(tc, "descr",
4931 "Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls without "
4932 "modification of SIGINT from tracee");
4935 static int siginfo2_caught = 0;
4938 siginfo2_sighandler(int sig)
4940 FORKEE_ASSERT_EQ(sig, SIGINT);
4945 ATF_TC_BODY(siginfo2, tc)
4947 const int exitval = 5;
4948 const int sigval = SIGINT;
4950 struct sigaction sa;
4951 #if defined(TWAIT_HAVE_STATUS)
4954 struct ptrace_siginfo info;
4955 memset(&info, 0, sizeof(info));
4957 printf("Before forking process PID=%d\n", getpid());
4958 ATF_REQUIRE((child = fork()) != -1);
4960 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
4961 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
4963 sa.sa_handler = siginfo2_sighandler;
4964 sa.sa_flags = SA_SIGINFO;
4965 sigemptyset(&sa.sa_mask);
4967 FORKEE_ASSERT(sigaction(sigval, &sa, NULL) != -1);
4969 printf("Before raising %s from child\n", strsignal(sigval));
4970 FORKEE_ASSERT(raise(sigval) == 0);
4972 FORKEE_ASSERT_EQ(siginfo2_caught, 1);
4974 printf("Before exiting of the child process\n");
4977 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
4979 printf("Before calling %s() for the child\n", TWAIT_FNAME);
4980 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
4982 validate_status_stopped(status, sigval);
4984 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
4985 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
4987 printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
4988 printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
4989 info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
4990 info.psi_siginfo.si_errno);
4992 printf("Before calling ptrace(2) with PT_SET_SIGINFO for child\n");
4993 ATF_REQUIRE(ptrace(PT_SET_SIGINFO, child, &info, sizeof(info)) != -1);
4995 printf("Before resuming the child process where it left off and "
4996 "without signal to be sent\n");
4997 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigval) != -1);
4999 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5000 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5002 validate_status_exited(status, exitval);
5004 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5005 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
5009 ATF_TC_HEAD(siginfo3, tc)
5011 atf_tc_set_md_var(tc, "descr",
5012 "Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls with "
5013 "setting signal to new value");
5016 static int siginfo3_caught = 0;
5019 siginfo3_sigaction(int sig, siginfo_t *info, void *ctx)
5021 FORKEE_ASSERT_EQ(sig, SIGTRAP);
5023 FORKEE_ASSERT_EQ(info->si_signo, SIGTRAP);
5024 FORKEE_ASSERT_EQ(info->si_code, TRAP_BRKPT);
5029 ATF_TC_BODY(siginfo3, tc)
5031 const int exitval = 5;
5032 const int sigval = SIGINT;
5033 const int sigfaked = SIGTRAP;
5034 const int sicodefaked = TRAP_BRKPT;
5036 struct sigaction sa;
5037 #if defined(TWAIT_HAVE_STATUS)
5040 struct ptrace_siginfo info;
5041 memset(&info, 0, sizeof(info));
5043 printf("Before forking process PID=%d\n", getpid());
5044 ATF_REQUIRE((child = fork()) != -1);
5046 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
5047 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
5049 sa.sa_sigaction = siginfo3_sigaction;
5050 sa.sa_flags = SA_SIGINFO;
5051 sigemptyset(&sa.sa_mask);
5053 FORKEE_ASSERT(sigaction(sigfaked, &sa, NULL) != -1);
5055 printf("Before raising %s from child\n", strsignal(sigval));
5056 FORKEE_ASSERT(raise(sigval) == 0);
5058 FORKEE_ASSERT_EQ(siginfo3_caught, 1);
5060 printf("Before exiting of the child process\n");
5063 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
5065 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5066 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5068 validate_status_stopped(status, sigval);
5070 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5071 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5073 printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
5074 printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
5075 info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
5076 info.psi_siginfo.si_errno);
5078 printf("Before setting new faked signal to signo=%d si_code=%d\n",
5079 sigfaked, sicodefaked);
5080 info.psi_siginfo.si_signo = sigfaked;
5081 info.psi_siginfo.si_code = sicodefaked;
5083 printf("Before calling ptrace(2) with PT_SET_SIGINFO for child\n");
5084 ATF_REQUIRE(ptrace(PT_SET_SIGINFO, child, &info, sizeof(info)) != -1);
5086 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5087 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5089 printf("Before checking siginfo_t\n");
5090 ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigfaked);
5091 ATF_REQUIRE_EQ(info.psi_siginfo.si_code, sicodefaked);
5093 printf("Before resuming the child process where it left off and "
5094 "without signal to be sent\n");
5095 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, sigfaked) != -1);
5097 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5098 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5100 validate_status_exited(status, exitval);
5102 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5103 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
5107 ATF_TC_HEAD(siginfo4, tc)
5109 atf_tc_set_md_var(tc, "descr",
5110 "Detect SIGTRAP TRAP_EXEC from tracee");
5113 ATF_TC_BODY(siginfo4, tc)
5115 const int sigval = SIGTRAP;
5117 #if defined(TWAIT_HAVE_STATUS)
5121 struct ptrace_siginfo info;
5122 memset(&info, 0, sizeof(info));
5124 printf("Before forking process PID=%d\n", getpid());
5125 ATF_REQUIRE((child = fork()) != -1);
5127 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
5128 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
5130 printf("Before calling execve(2) from child\n");
5131 execlp("/bin/echo", "/bin/echo", NULL);
5133 FORKEE_ASSERT(0 && "Not reached");
5135 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
5137 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5138 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5140 validate_status_stopped(status, sigval);
5142 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5143 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5145 printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
5146 printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
5147 info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
5148 info.psi_siginfo.si_errno);
5150 ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
5151 ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_EXEC);
5153 printf("Before resuming the child process where it left off and "
5154 "without signal to be sent\n");
5155 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5157 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5158 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5160 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5161 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
5164 #if defined(TWAIT_HAVE_PID)
5166 ATF_TC_HEAD(siginfo5, tc)
5168 atf_tc_set_md_var(tc, "descr",
5169 "Verify that fork(2) is intercepted by ptrace(2) with EVENT_MASK "
5170 "set to PTRACE_FORK and reports correct signal information");
5173 ATF_TC_BODY(siginfo5, tc)
5175 const int exitval = 5;
5176 const int exitval2 = 15;
5177 const int sigval = SIGSTOP;
5178 pid_t child, child2, wpid;
5179 #if defined(TWAIT_HAVE_STATUS)
5182 ptrace_state_t state;
5183 const int slen = sizeof(state);
5184 ptrace_event_t event;
5185 const int elen = sizeof(event);
5186 struct ptrace_siginfo info;
5188 memset(&info, 0, sizeof(info));
5190 printf("Before forking process PID=%d\n", getpid());
5191 ATF_REQUIRE((child = fork()) != -1);
5193 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
5194 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
5196 printf("Before raising %s from child\n", strsignal(sigval));
5197 FORKEE_ASSERT(raise(sigval) == 0);
5199 FORKEE_ASSERT((child2 = fork()) != 1);
5204 FORKEE_REQUIRE_SUCCESS
5205 (wpid = TWAIT_GENERIC(child2, &status, 0), child2);
5207 forkee_status_exited(status, exitval2);
5209 printf("Before exiting of the child process\n");
5212 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
5214 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5215 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5217 validate_status_stopped(status, sigval);
5219 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5220 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5222 printf("Before checking siginfo_t\n");
5223 ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
5224 ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
5226 printf("Enable PTRACE_FORK in EVENT_MASK for the child %d\n", child);
5227 event.pe_set_event = PTRACE_FORK;
5228 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
5230 printf("Before resuming the child process where it left off and "
5231 "without signal to be sent\n");
5232 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5234 printf("Before calling %s() for the child %d\n", TWAIT_FNAME, child);
5235 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5237 validate_status_stopped(status, SIGTRAP);
5239 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5240 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5242 printf("Before checking siginfo_t\n");
5243 ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
5244 ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_CHLD);
5246 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
5247 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
5249 child2 = state.pe_other_pid;
5250 printf("Reported PTRACE_FORK event with forkee %d\n", child2);
5252 printf("Before calling %s() for the forkee %d of the child %d\n",
5253 TWAIT_FNAME, child2, child);
5254 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
5257 validate_status_stopped(status, SIGTRAP);
5259 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5260 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5262 printf("Before checking siginfo_t\n");
5263 ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
5264 ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_CHLD);
5266 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child2, &state, slen) != -1);
5267 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_FORK);
5268 ATF_REQUIRE_EQ(state.pe_other_pid, child);
5270 printf("Before resuming the forkee process where it left off and "
5271 "without signal to be sent\n");
5272 ATF_REQUIRE(ptrace(PT_CONTINUE, child2, (void *)1, 0) != -1);
5274 printf("Before resuming the child process where it left off and "
5275 "without signal to be sent\n");
5276 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5278 printf("Before calling %s() for the forkee - expected exited\n",
5280 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, &status, 0),
5283 validate_status_exited(status, exitval2);
5285 printf("Before calling %s() for the forkee - expected no process\n",
5287 TWAIT_REQUIRE_FAILURE(ECHILD,
5288 wpid = TWAIT_GENERIC(child2, &status, 0));
5290 printf("Before calling %s() for the child - expected stopped "
5291 "SIGCHLD\n", TWAIT_FNAME);
5292 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5294 validate_status_stopped(status, SIGCHLD);
5296 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5297 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5299 printf("Before checking siginfo_t\n");
5300 ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGCHLD);
5301 ATF_REQUIRE_EQ(info.psi_siginfo.si_code, CLD_EXITED);
5303 printf("Before resuming the child process where it left off and "
5304 "without signal to be sent\n");
5305 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5307 printf("Before calling %s() for the child - expected exited\n",
5309 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5311 validate_status_exited(status, exitval);
5313 printf("Before calling %s() for the child - expected no process\n",
5315 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
5319 #if defined(PT_STEP)
5321 ATF_TC_HEAD(siginfo6, tc)
5323 atf_tc_set_md_var(tc, "descr",
5324 "Verify single PT_STEP call with signal information check");
5327 ATF_TC_BODY(siginfo6, tc)
5329 const int exitval = 5;
5330 const int sigval = SIGSTOP;
5332 #if defined(TWAIT_HAVE_STATUS)
5336 struct ptrace_siginfo info;
5338 memset(&info, 0, sizeof(info));
5340 printf("Before forking process PID=%d\n", getpid());
5341 ATF_REQUIRE((child = fork()) != -1);
5343 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
5344 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
5346 happy = check_happy(100);
5348 printf("Before raising %s from child\n", strsignal(sigval));
5349 FORKEE_ASSERT(raise(sigval) == 0);
5351 FORKEE_ASSERT_EQ(happy, check_happy(100));
5353 printf("Before exiting of the child process\n");
5356 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
5358 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5359 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5361 validate_status_stopped(status, sigval);
5363 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5364 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5366 printf("Before checking siginfo_t\n");
5367 ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
5368 ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
5370 printf("Before resuming the child process where it left off and "
5371 "without signal to be sent (use PT_STEP)\n");
5372 ATF_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0) != -1);
5374 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5375 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5377 validate_status_stopped(status, SIGTRAP);
5379 printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
5380 ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
5382 printf("Before checking siginfo_t\n");
5383 ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
5384 ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_TRACE);
5386 printf("Before resuming the child process where it left off and "
5387 "without signal to be sent\n");
5388 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5390 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5391 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5393 validate_status_exited(status, exitval);
5395 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5396 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
5400 volatile lwpid_t the_lwp_id = 0;
5403 lwp_main_func(void *arg)
5405 the_lwp_id = _lwp_self();
5409 ATF_TC(lwp_create1);
5410 ATF_TC_HEAD(lwp_create1, tc)
5412 atf_tc_set_md_var(tc, "descr",
5413 "Verify that 1 LWP creation is intercepted by ptrace(2) with "
5414 "EVENT_MASK set to PTRACE_LWP_CREATE");
5417 ATF_TC_BODY(lwp_create1, tc)
5419 const int exitval = 5;
5420 const int sigval = SIGSTOP;
5422 #if defined(TWAIT_HAVE_STATUS)
5425 ptrace_state_t state;
5426 const int slen = sizeof(state);
5427 ptrace_event_t event;
5428 const int elen = sizeof(event);
5431 static const size_t ssize = 16*1024;
5434 printf("Before forking process PID=%d\n", getpid());
5435 ATF_REQUIRE((child = fork()) != -1);
5437 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
5438 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
5440 printf("Before raising %s from child\n", strsignal(sigval));
5441 FORKEE_ASSERT(raise(sigval) == 0);
5443 printf("Before allocating memory for stack in child\n");
5444 FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
5446 printf("Before making context for new lwp in child\n");
5447 _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
5449 printf("Before creating new in child\n");
5450 FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
5452 printf("Before waiting for lwp %d to exit\n", lid);
5453 FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
5455 printf("Before verifying that reported %d and running lid %d "
5456 "are the same\n", lid, the_lwp_id);
5457 FORKEE_ASSERT_EQ(lid, the_lwp_id);
5459 printf("Before exiting of the child process\n");
5462 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
5464 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5465 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5467 validate_status_stopped(status, sigval);
5469 printf("Set empty EVENT_MASK for the child %d\n", child);
5470 event.pe_set_event = PTRACE_LWP_CREATE;
5471 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
5473 printf("Before resuming the child process where it left off and "
5474 "without signal to be sent\n");
5475 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5477 printf("Before calling %s() for the child - expected stopped "
5478 "SIGTRAP\n", TWAIT_FNAME);
5479 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5481 validate_status_stopped(status, SIGTRAP);
5483 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
5485 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_CREATE);
5488 printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
5490 printf("Before resuming the child process where it left off and "
5491 "without signal to be sent\n");
5492 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5494 printf("Before calling %s() for the child - expected exited\n",
5496 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5498 validate_status_exited(status, exitval);
5500 printf("Before calling %s() for the child - expected no process\n",
5502 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
5506 ATF_TC_HEAD(lwp_exit1, tc)
5508 atf_tc_set_md_var(tc, "descr",
5509 "Verify that 1 LWP creation is intercepted by ptrace(2) with "
5510 "EVENT_MASK set to PTRACE_LWP_EXIT");
5513 ATF_TC_BODY(lwp_exit1, tc)
5515 const int exitval = 5;
5516 const int sigval = SIGSTOP;
5518 #if defined(TWAIT_HAVE_STATUS)
5521 ptrace_state_t state;
5522 const int slen = sizeof(state);
5523 ptrace_event_t event;
5524 const int elen = sizeof(event);
5527 static const size_t ssize = 16*1024;
5530 printf("Before forking process PID=%d\n", getpid());
5531 ATF_REQUIRE((child = fork()) != -1);
5533 printf("Before calling PT_TRACE_ME from child %d\n", getpid());
5534 FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
5536 printf("Before raising %s from child\n", strsignal(sigval));
5537 FORKEE_ASSERT(raise(sigval) == 0);
5539 printf("Before allocating memory for stack in child\n");
5540 FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
5542 printf("Before making context for new lwp in child\n");
5543 _lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
5545 printf("Before creating new in child\n");
5546 FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
5548 printf("Before waiting for lwp %d to exit\n", lid);
5549 FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
5551 printf("Before verifying that reported %d and running lid %d "
5552 "are the same\n", lid, the_lwp_id);
5553 FORKEE_ASSERT_EQ(lid, the_lwp_id);
5555 printf("Before exiting of the child process\n");
5558 printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
5560 printf("Before calling %s() for the child\n", TWAIT_FNAME);
5561 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5563 validate_status_stopped(status, sigval);
5565 printf("Set empty EVENT_MASK for the child %d\n", child);
5566 event.pe_set_event = PTRACE_LWP_EXIT;
5567 ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
5569 printf("Before resuming the child process where it left off and "
5570 "without signal to be sent\n");
5571 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5573 printf("Before calling %s() for the child - expected stopped "
5574 "SIGTRAP\n", TWAIT_FNAME);
5575 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5577 validate_status_stopped(status, SIGTRAP);
5579 ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
5581 ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_EXIT);
5584 printf("Reported PTRACE_LWP_EXIT event with lid %d\n", lid);
5586 printf("Before resuming the child process where it left off and "
5587 "without signal to be sent\n");
5588 ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
5590 printf("Before calling %s() for the child - expected exited\n",
5592 TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
5594 validate_status_exited(status, exitval);
5596 printf("Before calling %s() for the child - expected no process\n",
5598 TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
5603 setvbuf(stdout, NULL, _IONBF, 0);
5604 setvbuf(stderr, NULL, _IONBF, 0);
5605 ATF_TP_ADD_TC(tp, traceme1);
5606 ATF_TP_ADD_TC(tp, traceme2);
5607 ATF_TP_ADD_TC(tp, traceme3);
5608 ATF_TP_ADD_TC(tp, traceme4);
5610 ATF_TP_ADD_TC_HAVE_PID(tp, attach1);
5611 ATF_TP_ADD_TC_HAVE_PID(tp, attach2);
5612 ATF_TP_ADD_TC(tp, attach3);
5613 ATF_TP_ADD_TC(tp, attach4);
5614 ATF_TP_ADD_TC_HAVE_PID(tp, attach5);
5615 ATF_TP_ADD_TC_HAVE_PID(tp, attach6);
5616 ATF_TP_ADD_TC_HAVE_PID(tp, attach7);
5618 ATF_TP_ADD_TC(tp, eventmask1);
5619 ATF_TP_ADD_TC(tp, eventmask2);
5620 ATF_TP_ADD_TC(tp, eventmask3);
5621 ATF_TP_ADD_TC(tp, eventmask4);
5622 ATF_TP_ADD_TC(tp, eventmask5);
5623 ATF_TP_ADD_TC(tp, eventmask6);
5625 ATF_TP_ADD_TC_HAVE_PID(tp, fork1);
5626 ATF_TP_ADD_TC(tp, fork2);
5628 ATF_TP_ADD_TC_HAVE_PID(tp, vfork1);
5629 ATF_TP_ADD_TC(tp, vfork2);
5631 ATF_TP_ADD_TC(tp, vforkdone1);
5632 ATF_TP_ADD_TC(tp, vforkdone2);
5634 ATF_TP_ADD_TC(tp, io_read_d1);
5635 ATF_TP_ADD_TC(tp, io_read_d2);
5636 ATF_TP_ADD_TC(tp, io_read_d3);
5637 ATF_TP_ADD_TC(tp, io_read_d4);
5639 ATF_TP_ADD_TC(tp, io_write_d1);
5640 ATF_TP_ADD_TC(tp, io_write_d2);
5641 ATF_TP_ADD_TC(tp, io_write_d3);
5642 ATF_TP_ADD_TC(tp, io_write_d4);
5644 ATF_TP_ADD_TC(tp, read_d1);
5645 ATF_TP_ADD_TC(tp, read_d2);
5646 ATF_TP_ADD_TC(tp, read_d3);
5647 ATF_TP_ADD_TC(tp, read_d4);
5649 ATF_TP_ADD_TC(tp, write_d1);
5650 ATF_TP_ADD_TC(tp, write_d2);
5651 ATF_TP_ADD_TC(tp, write_d3);
5652 ATF_TP_ADD_TC(tp, write_d4);
5654 ATF_TP_ADD_TC(tp, io_read_d_write_d_handshake1);
5655 ATF_TP_ADD_TC(tp, io_read_d_write_d_handshake2);
5657 ATF_TP_ADD_TC(tp, read_d_write_d_handshake1);
5658 ATF_TP_ADD_TC(tp, read_d_write_d_handshake2);
5660 ATF_TP_ADD_TC(tp, io_read_i1);
5661 ATF_TP_ADD_TC(tp, io_read_i2);
5662 ATF_TP_ADD_TC(tp, io_read_i3);
5663 ATF_TP_ADD_TC(tp, io_read_i4);
5665 ATF_TP_ADD_TC(tp, read_i1);
5666 ATF_TP_ADD_TC(tp, read_i2);
5667 ATF_TP_ADD_TC(tp, read_i3);
5668 ATF_TP_ADD_TC(tp, read_i4);
5670 ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs1);
5671 ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs2);
5672 ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs3);
5673 ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs4);
5674 ATF_TP_ADD_TC_HAVE_GPREGS(tp, regs5);
5676 ATF_TP_ADD_TC_HAVE_FPREGS(tp, fpregs1);
5677 ATF_TP_ADD_TC_HAVE_FPREGS(tp, fpregs2);
5679 ATF_TP_ADD_TC_PT_STEP(tp, step1);
5680 ATF_TP_ADD_TC_PT_STEP(tp, step2);
5681 ATF_TP_ADD_TC_PT_STEP(tp, step3);
5682 ATF_TP_ADD_TC_PT_STEP(tp, step4);
5684 ATF_TP_ADD_TC(tp, kill1);
5685 ATF_TP_ADD_TC(tp, kill2);
5687 ATF_TP_ADD_TC(tp, lwpinfo1);
5688 ATF_TP_ADD_TC_HAVE_PID(tp, lwpinfo2);
5690 ATF_TP_ADD_TC(tp, siginfo1);
5691 ATF_TP_ADD_TC(tp, siginfo2);
5692 ATF_TP_ADD_TC(tp, siginfo3);
5693 ATF_TP_ADD_TC(tp, siginfo4);
5694 ATF_TP_ADD_TC_HAVE_PID(tp, siginfo5);
5695 ATF_TP_ADD_TC_PT_STEP(tp, siginfo6);
5697 ATF_TP_ADD_TC(tp, lwp_create1);
5699 ATF_TP_ADD_TC(tp, lwp_exit1);
5701 return atf_no_error();