Module Name:    src
Committed By:   kamil
Date:           Mon Feb 20 05:40:51 UTC 2017

Modified Files:
        src/tests/kernel/arch/amd64: t_ptrace_wait.c

Log Message:
Add new tests dbregs_dr*_dont_inherit_lwp and improve i386 compat

Add new tests:
 - dbregs_dr0_dont_inherit_lwp
 - dbregs_dr1_dont_inherit_lwp
 - dbregs_dr2_dont_inherit_lwp
 - dbregs_dr3_dont_inherit_lwp

Fix memcmp(3) usage when comparing registers. Comparing with len is
incorrect as it should be len*sizeof(register) or just sizeof(registers).

Don't check for 16 Debug Registers, it's amd64 specific and not portable
to i386.

Don't compare registers before and after triggering a trap, it's a bug that
was hidden by incorrect usage of memcmp(3).

Sponsored by <The NetBSD Foundation>


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/tests/kernel/arch/amd64/t_ptrace_wait.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/kernel/arch/amd64/t_ptrace_wait.c
diff -u src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.19 src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.20
--- src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.19	Mon Feb 20 02:56:03 2017
+++ src/tests/kernel/arch/amd64/t_ptrace_wait.c	Mon Feb 20 05:40:51 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.19 2017/02/20 02:56:03 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.20 2017/02/20 05:40:51 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.19 2017/02/20 02:56:03 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.20 2017/02/20 05:40:51 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -39,6 +39,7 @@ __RCSID("$NetBSD: t_ptrace_wait.c,v 1.19
 #include <machine/reg.h>
 #include <err.h>
 #include <errno.h>
+#include <lwp.h>
 #include <sched.h>
 #include <signal.h>
 #include <stdint.h>
@@ -294,7 +295,7 @@ ATF_TC_BODY(dbregs_preserve_dr0, tc)
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -378,7 +379,7 @@ ATF_TC_BODY(dbregs_preserve_dr1, tc)
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -462,7 +463,7 @@ ATF_TC_BODY(dbregs_preserve_dr2, tc)
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -546,7 +547,7 @@ ATF_TC_BODY(dbregs_preserve_dr3, tc)
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -636,7 +637,7 @@ ATF_TC_BODY(dbregs_preserve_dr0_yield, t
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -726,7 +727,7 @@ ATF_TC_BODY(dbregs_preserve_dr1_yield, t
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -816,7 +817,7 @@ ATF_TC_BODY(dbregs_preserve_dr2_yield, t
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -906,7 +907,7 @@ ATF_TC_BODY(dbregs_preserve_dr3_yield, t
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -1002,7 +1003,7 @@ ATF_TC_BODY(dbregs_preserve_dr0_continue
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -1098,7 +1099,7 @@ ATF_TC_BODY(dbregs_preserve_dr1_continue
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -1194,7 +1195,7 @@ ATF_TC_BODY(dbregs_preserve_dr2_continue
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -1290,7 +1291,7 @@ ATF_TC_BODY(dbregs_preserve_dr3_continue
 	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
 
 	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) == 0);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
@@ -1324,9 +1325,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -1339,11 +1337,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 	dr7.bits.condition_dr0 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr0 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -1416,12 +1409,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1454,9 +1441,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -1469,11 +1453,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 	dr7.bits.condition_dr1 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr1 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -1546,12 +1525,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1584,9 +1557,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -1599,11 +1569,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 	dr7.bits.condition_dr2 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr2 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -1676,12 +1641,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1714,9 +1673,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -1729,11 +1685,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 	dr7.bits.condition_dr3 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr3 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -1806,12 +1757,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1844,9 +1789,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -1859,11 +1801,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 	dr7.bits.condition_dr0 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr0 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -1936,12 +1873,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1974,9 +1905,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -1989,11 +1917,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 	dr7.bits.condition_dr1 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr1 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -2066,12 +1989,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -2104,9 +2021,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -2119,11 +2033,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 	dr7.bits.condition_dr2 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr2 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -2196,12 +2105,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -2234,9 +2137,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -2249,11 +2149,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 	dr7.bits.condition_dr3 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr3 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -2326,12 +2221,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -2364,9 +2253,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -2379,11 +2265,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 	dr7.bits.condition_dr0 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr0 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -2456,12 +2337,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -2494,9 +2369,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -2509,11 +2381,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 	dr7.bits.condition_dr1 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr1 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -2586,12 +2453,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -2624,9 +2485,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -2639,11 +2497,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 	dr7.bits.condition_dr2 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr2 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -2716,12 +2569,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -2754,9 +2601,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -2769,11 +2613,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 	dr7.bits.condition_dr3 = 1;	/* 0b01 -- break on data write only */
 	dr7.bits.len_dr3 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -2846,12 +2685,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_wri
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -2884,9 +2717,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -2899,11 +2729,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	dr7.bits.condition_dr0 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr0 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -2976,12 +2801,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -3014,9 +2833,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -3029,11 +2845,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	dr7.bits.condition_dr1 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr1 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3106,12 +2917,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -3144,9 +2949,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -3159,11 +2961,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	dr7.bits.condition_dr2 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr2 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3236,12 +3033,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -3274,9 +3065,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -3289,11 +3077,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	dr7.bits.condition_dr3 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr3 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3366,12 +3149,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -3404,9 +3181,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -3419,11 +3193,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	dr7.bits.condition_dr0 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr0 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3496,12 +3265,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -3534,9 +3297,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -3549,11 +3309,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	dr7.bits.condition_dr1 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr1 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3626,12 +3381,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -3664,9 +3413,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -3679,11 +3425,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	dr7.bits.condition_dr2 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr2 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3756,12 +3497,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -3794,9 +3529,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -3809,11 +3541,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	dr7.bits.condition_dr3 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr3 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -3886,12 +3613,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -3924,9 +3645,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -3939,11 +3657,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	dr7.bits.condition_dr0 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr0 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -4016,12 +3729,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -4054,9 +3761,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -4069,11 +3773,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	dr7.bits.condition_dr1 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr1 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -4146,12 +3845,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -4184,9 +3877,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -4199,11 +3889,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	dr7.bits.condition_dr2 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr2 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -4276,12 +3961,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -4314,9 +3993,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme;
 	union u dr7;
@@ -4329,11 +4005,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	dr7.bits.condition_dr3 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr3 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -4406,12 +4077,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -4444,9 +4109,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -4459,11 +4121,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	dr7.bits.condition_dr0 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr0 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -4536,12 +4193,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -4574,9 +4225,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -4589,11 +4237,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	dr7.bits.condition_dr1 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr1 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -4666,12 +4309,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -4704,9 +4341,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -4719,11 +4353,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	dr7.bits.condition_dr2 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr2 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -4796,12 +4425,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -4834,9 +4457,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -4849,11 +4469,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	dr7.bits.condition_dr3 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr3 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -4926,12 +4541,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -4964,9 +4573,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -4979,11 +4585,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	dr7.bits.condition_dr0 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr0 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -5056,12 +4657,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -5094,9 +4689,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -5109,11 +4701,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	dr7.bits.condition_dr1 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr1 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -5186,12 +4773,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -5224,9 +4805,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -5239,11 +4817,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	dr7.bits.condition_dr2 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr2 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -5316,12 +4889,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -5354,9 +4921,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -5369,11 +4933,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	dr7.bits.condition_dr3 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr3 = 1;		/* 0b01 -- 2 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -5446,12 +5005,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -5484,9 +5037,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -5499,11 +5049,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 	dr7.bits.condition_dr0 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr0 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -5576,12 +5121,6 @@ ATF_TC_BODY(dbregs_dr0_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -5614,9 +5153,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -5629,11 +5165,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 	dr7.bits.condition_dr1 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr1 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -5706,12 +5237,6 @@ ATF_TC_BODY(dbregs_dr1_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -5744,9 +5269,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -5759,11 +5281,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 	dr7.bits.condition_dr2 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr2 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -5836,12 +5353,6 @@ ATF_TC_BODY(dbregs_dr2_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -5874,9 +5385,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -5889,11 +5397,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 	dr7.bits.condition_dr3 = 3;	/* 0b11 -- break on data write&read */
 	dr7.bits.len_dr3 = 3;		/* 0b11 -- 4 bytes */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -5966,12 +5469,6 @@ ATF_TC_BODY(dbregs_dr3_trap_variable_rea
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -6004,9 +5501,6 @@ ATF_TC_BODY(dbregs_dr0_trap_code, tc)
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -6019,11 +5513,6 @@ ATF_TC_BODY(dbregs_dr0_trap_code, tc)
 	dr7.bits.condition_dr0 = 0;	/* 0b00 -- break on code execution */
 	dr7.bits.len_dr0 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -6104,12 +5593,6 @@ ATF_TC_BODY(dbregs_dr0_trap_code, tc)
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -6142,9 +5625,6 @@ ATF_TC_BODY(dbregs_dr1_trap_code, tc)
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -6157,11 +5637,6 @@ ATF_TC_BODY(dbregs_dr1_trap_code, tc)
 	dr7.bits.condition_dr1 = 0;	/* 0b00 -- break on code execution */
 	dr7.bits.len_dr1 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -6242,12 +5717,6 @@ ATF_TC_BODY(dbregs_dr1_trap_code, tc)
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -6280,9 +5749,6 @@ ATF_TC_BODY(dbregs_dr2_trap_code, tc)
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -6295,11 +5761,6 @@ ATF_TC_BODY(dbregs_dr2_trap_code, tc)
 	dr7.bits.condition_dr2 = 0;	/* 0b00 -- break on code execution */
 	dr7.bits.len_dr2 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -6380,12 +5841,6 @@ ATF_TC_BODY(dbregs_dr2_trap_code, tc)
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
-
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
-
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -6418,9 +5873,6 @@ ATF_TC_BODY(dbregs_dr3_trap_code, tc)
 	int status;
 #endif
 	struct dbreg r1;
-	struct dbreg r2;
-	/* Number of available CPU Debug Registers on AMD64 */
-	const size_t len = 16;
 	size_t i;
 	volatile int watchme = 1;
 	union u dr7;
@@ -6433,11 +5885,6 @@ ATF_TC_BODY(dbregs_dr3_trap_code, tc)
 	dr7.bits.condition_dr3 = 0;	/* 0b00 -- break on code execution */
 	dr7.bits.len_dr3 = 0;		/* 0b00 -- 1 byte */
 
-	printf("Assert that known number of Debug Registers (%zu) is valid\n",
-	    len);
-	ATF_REQUIRE_EQ(__arraycount(r1.dr), len);
-	ATF_REQUIRE_EQ(__arraycount(r2.dr), len);
-
 	printf("Before forking process PID=%d\n", getpid());
 	ATF_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
@@ -6518,25 +5965,536 @@ ATF_TC_BODY(dbregs_dr3_trap_code, tc)
 
 	validate_status_stopped(status, sigval);
 
-	printf("Call GETDBREGS for the child process (r2)\n");
-	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, 0) != -1);
+	printf("Before resuming the child process where it left off and "
+	    "without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 
-	printf("Assert that (r1) and (r2) are the same\n");
-	ATF_REQUIRE(memcmp(&r1, &r2, len) == 0);
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_exited(status, exitval);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+#endif
+
+volatile lwpid_t the_lwp_id = 0;
+
+static void
+lwp_main_func(void *arg)
+{
+	the_lwp_id = _lwp_self();
+	_lwp_exit();
+}
+
+ATF_TC(dbregs_dr0_dont_inherit_lwp);
+ATF_TC_HEAD(dbregs_dr0_dont_inherit_lwp, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	    "Verify that 1 LWP creation is intercepted by ptrace(2) with "
+	    "EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 0 from "
+	    "the forker thread is not inherited");
+}
+
+ATF_TC_BODY(dbregs_dr0_dont_inherit_lwp, tc)
+{
+	const int exitval = 5;
+	const int sigval = SIGSTOP;
+	pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	ptrace_state_t state;
+	const int slen = sizeof(state);
+	ptrace_event_t event;
+	const int elen = sizeof(event);
+	ucontext_t uc;
+	lwpid_t lid;
+	static const size_t ssize = 16*1024;
+	void *stack;
+	size_t i;
+	struct dbreg r1;
+	struct dbreg r2;
+
+	printf("Before forking process PID=%d\n", getpid());
+	ATF_REQUIRE((child = fork()) != -1);
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		printf("Before allocating memory for stack in child\n");
+		FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
+
+		printf("Before making context for new lwp in child\n");
+		_lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
+
+		printf("Before creating new in child\n");
+		FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
+
+		printf("Before waiting for lwp %d to exit\n", lid);
+		FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
+
+		printf("Before verifying that reported %d and running lid %d "
+		    "are the same\n", lid, the_lwp_id);
+		FORKEE_ASSERT_EQ(lid, the_lwp_id);
+
+		printf("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Set empty EVENT_MASK for the child %d\n", child);
+	event.pe_set_event = PTRACE_LWP_CREATE;
+	ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+	printf("Call GETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
+
+	printf("State of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	r1.dr[0] = (long)(intptr_t)check_happy;
+	printf("Set DR0 (r1.dr[0]) to new value %#lx\n", r1.dr[0]);
+
+	printf("New state of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	printf("Call SETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
 
 	printf("Before resuming the child process where it left off and "
 	    "without signal to be sent\n");
 	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 
+	printf("Before calling %s() for the child - expected stopped "
+	    "SIGTRAP\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+
+	ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_CREATE);
+
+	lid = state.pe_lwp;
+	printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
+
+	printf("Call GETDBREGS for the child process new lwp (r2)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, lid) != -1);
+
+	printf("State of the debug registers (r2):\n");
+	for (i = 0; i < __arraycount(r2.dr); i++)
+		printf("r2[%zu]=%#lx\n", i, r2.dr[i]);
+
+	printf("Assert that (r1) and (r2) are not the same\n");
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) != 0);
+
+	printf("Before resuming the child process where it left off and "
+	    "without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected exited\n",
+	    TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_exited(status, exitval);
+
+	printf("Before calling %s() for the child - expected no process\n",
+	    TWAIT_FNAME);
+	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(dbregs_dr1_dont_inherit_lwp);
+ATF_TC_HEAD(dbregs_dr1_dont_inherit_lwp, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	    "Verify that 1 LWP creation is intercepted by ptrace(2) with "
+	    "EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 1 from "
+	    "the forker thread is not inherited");
+}
+
+ATF_TC_BODY(dbregs_dr1_dont_inherit_lwp, tc)
+{
+	const int exitval = 5;
+	const int sigval = SIGSTOP;
+	pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	ptrace_state_t state;
+	const int slen = sizeof(state);
+	ptrace_event_t event;
+	const int elen = sizeof(event);
+	ucontext_t uc;
+	lwpid_t lid;
+	static const size_t ssize = 16*1024;
+	void *stack;
+	size_t i;
+	struct dbreg r1;
+	struct dbreg r2;
+
+	printf("Before forking process PID=%d\n", getpid());
+	ATF_REQUIRE((child = fork()) != -1);
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		printf("Before allocating memory for stack in child\n");
+		FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
+
+		printf("Before making context for new lwp in child\n");
+		_lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
+
+		printf("Before creating new in child\n");
+		FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
+
+		printf("Before waiting for lwp %d to exit\n", lid);
+		FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
+
+		printf("Before verifying that reported %d and running lid %d "
+		    "are the same\n", lid, the_lwp_id);
+		FORKEE_ASSERT_EQ(lid, the_lwp_id);
+
+		printf("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
 	printf("Before calling %s() for the child\n", TWAIT_FNAME);
 	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
 
+	validate_status_stopped(status, sigval);
+
+	printf("Set empty EVENT_MASK for the child %d\n", child);
+	event.pe_set_event = PTRACE_LWP_CREATE;
+	ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+	printf("Call GETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
+
+	printf("State of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	r1.dr[1] = (long)(intptr_t)check_happy;
+	printf("Set DR1 (r1.dr[1]) to new value %#lx\n", r1.dr[1]);
+
+	printf("New state of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	printf("Call SETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	    "without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected stopped "
+	    "SIGTRAP\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+
+	ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_CREATE);
+
+	lid = state.pe_lwp;
+	printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
+
+	printf("Call GETDBREGS for the child process new lwp (r2)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, lid) != -1);
+
+	printf("State of the debug registers (r2):\n");
+	for (i = 0; i < __arraycount(r2.dr); i++)
+		printf("r2[%zu]=%#lx\n", i, r2.dr[i]);
+
+	printf("Assert that (r1) and (r2) are not the same\n");
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) != 0);
+
+	printf("Before resuming the child process where it left off and "
+	    "without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected exited\n",
+	    TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
 	validate_status_exited(status, exitval);
 
+	printf("Before calling %s() for the child - expected no process\n",
+	    TWAIT_FNAME);
+	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
+
+ATF_TC(dbregs_dr2_dont_inherit_lwp);
+ATF_TC_HEAD(dbregs_dr2_dont_inherit_lwp, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	    "Verify that 1 LWP creation is intercepted by ptrace(2) with "
+	    "EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 2 from "
+	    "the forker thread is not inherited");
+}
+
+ATF_TC_BODY(dbregs_dr2_dont_inherit_lwp, tc)
+{
+	const int exitval = 5;
+	const int sigval = SIGSTOP;
+	pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
+#endif
+	ptrace_state_t state;
+	const int slen = sizeof(state);
+	ptrace_event_t event;
+	const int elen = sizeof(event);
+	ucontext_t uc;
+	lwpid_t lid;
+	static const size_t ssize = 16*1024;
+	void *stack;
+	size_t i;
+	struct dbreg r1;
+	struct dbreg r2;
+
+	printf("Before forking process PID=%d\n", getpid());
+	ATF_REQUIRE((child = fork()) != -1);
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		printf("Before allocating memory for stack in child\n");
+		FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
+
+		printf("Before making context for new lwp in child\n");
+		_lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
+
+		printf("Before creating new in child\n");
+		FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
+
+		printf("Before waiting for lwp %d to exit\n", lid);
+		FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
+
+		printf("Before verifying that reported %d and running lid %d "
+		    "are the same\n", lid, the_lwp_id);
+		FORKEE_ASSERT_EQ(lid, the_lwp_id);
+
+		printf("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
 	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Set empty EVENT_MASK for the child %d\n", child);
+	event.pe_set_event = PTRACE_LWP_CREATE;
+	ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+	printf("Call GETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
+
+	printf("State of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	r1.dr[2] = (long)(intptr_t)check_happy;
+	printf("Set DR2 (r1.dr[2]) to new value %#lx\n", r1.dr[2]);
+
+	printf("New state of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	printf("Call SETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	    "without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected stopped "
+	    "SIGTRAP\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+
+	ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_CREATE);
+
+	lid = state.pe_lwp;
+	printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
+
+	printf("Call GETDBREGS for the child process new lwp (r2)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, lid) != -1);
+
+	printf("State of the debug registers (r2):\n");
+	for (i = 0; i < __arraycount(r2.dr); i++)
+		printf("r2[%zu]=%#lx\n", i, r2.dr[i]);
+
+	printf("Assert that (r1) and (r2) are not the same\n");
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) != 0);
+
+	printf("Before resuming the child process where it left off and "
+	    "without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected exited\n",
+	    TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_exited(status, exitval);
+
+	printf("Before calling %s() for the child - expected no process\n",
+	    TWAIT_FNAME);
 	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
 }
+
+ATF_TC(dbregs_dr3_dont_inherit_lwp);
+ATF_TC_HEAD(dbregs_dr3_dont_inherit_lwp, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	    "Verify that 1 LWP creation is intercepted by ptrace(2) with "
+	    "EVENT_MASK set to PTRACE_LWP_CREATE and Debug Register 3 from "
+	    "the forker thread is not inherited");
+}
+
+ATF_TC_BODY(dbregs_dr3_dont_inherit_lwp, tc)
+{
+	const int exitval = 5;
+	const int sigval = SIGSTOP;
+	pid_t child, wpid;
+#if defined(TWAIT_HAVE_STATUS)
+	int status;
 #endif
+	ptrace_state_t state;
+	const int slen = sizeof(state);
+	ptrace_event_t event;
+	const int elen = sizeof(event);
+	ucontext_t uc;
+	lwpid_t lid;
+	static const size_t ssize = 16*1024;
+	void *stack;
+	size_t i;
+	struct dbreg r1;
+	struct dbreg r2;
+
+	printf("Before forking process PID=%d\n", getpid());
+	ATF_REQUIRE((child = fork()) != -1);
+	if (child == 0) {
+		printf("Before calling PT_TRACE_ME from child %d\n", getpid());
+		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
+
+		printf("Before raising %s from child\n", strsignal(sigval));
+		FORKEE_ASSERT(raise(sigval) == 0);
+
+		printf("Before allocating memory for stack in child\n");
+		FORKEE_ASSERT((stack = malloc(ssize)) != NULL);
+
+		printf("Before making context for new lwp in child\n");
+		_lwp_makecontext(&uc, lwp_main_func, NULL, NULL, stack, ssize);
+
+		printf("Before creating new in child\n");
+		FORKEE_ASSERT(_lwp_create(&uc, 0, &lid) == 0);
+
+		printf("Before waiting for lwp %d to exit\n", lid);
+		FORKEE_ASSERT(_lwp_wait(lid, NULL) == 0);
+
+		printf("Before verifying that reported %d and running lid %d "
+		    "are the same\n", lid, the_lwp_id);
+		FORKEE_ASSERT_EQ(lid, the_lwp_id);
+
+		printf("Before exiting of the child process\n");
+		_exit(exitval);
+	}
+	printf("Parent process PID=%d, child's PID=%d\n", getpid(), child);
+
+	printf("Before calling %s() for the child\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_stopped(status, sigval);
+
+	printf("Set empty EVENT_MASK for the child %d\n", child);
+	event.pe_set_event = PTRACE_LWP_CREATE;
+	ATF_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, &event, elen) != -1);
+
+	printf("Call GETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r1, 0) != -1);
+
+	printf("State of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	r1.dr[3] = (long)(intptr_t)check_happy;
+	printf("Set DR3 (r1.dr[3]) to new value %#lx\n", r1.dr[3]);
+
+	printf("New state of the debug registers (r1):\n");
+	for (i = 0; i < __arraycount(r1.dr); i++)
+		printf("r1[%zu]=%#lx\n", i, r1.dr[i]);
+
+	printf("Call SETDBREGS for the child process (r1)\n");
+	ATF_REQUIRE(ptrace(PT_SETDBREGS, child, &r1, 0) != -1);
+
+	printf("Before resuming the child process where it left off and "
+	    "without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected stopped "
+	    "SIGTRAP\n", TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_stopped(status, SIGTRAP);
+
+	ATF_REQUIRE(ptrace(PT_GET_PROCESS_STATE, child, &state, slen) != -1);
+
+	ATF_REQUIRE_EQ(state.pe_report_event, PTRACE_LWP_CREATE);
+
+	lid = state.pe_lwp;
+	printf("Reported PTRACE_LWP_CREATE event with lid %d\n", lid);
+
+	printf("Call GETDBREGS for the child process new lwp (r2)\n");
+	ATF_REQUIRE(ptrace(PT_GETDBREGS, child, &r2, lid) != -1);
+
+	printf("State of the debug registers (r2):\n");
+	for (i = 0; i < __arraycount(r2.dr); i++)
+		printf("r2[%zu]=%#lx\n", i, r2.dr[i]);
+
+	printf("Assert that (r1) and (r2) are not the same\n");
+	ATF_REQUIRE(memcmp(&r1, &r2, sizeof(r1)) != 0);
+
+	printf("Before resuming the child process where it left off and "
+	    "without signal to be sent\n");
+	ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+
+	printf("Before calling %s() for the child - expected exited\n",
+	    TWAIT_FNAME);
+	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, &status, 0), child);
+
+	validate_status_exited(status, exitval);
+
+	printf("Before calling %s() for the child - expected no process\n",
+	    TWAIT_FNAME);
+	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, &status, 0));
+}
 
 ATF_TP_ADD_TCS(tp)
 {
@@ -6612,5 +6570,10 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_trap_code);
 	ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_trap_code);
 
+	ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr0_dont_inherit_lwp);
+	ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr1_dont_inherit_lwp);
+	ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr2_dont_inherit_lwp);
+	ATF_TP_ADD_TC_HAVE_DBREGS(tp, dbregs_dr3_dont_inherit_lwp);
+
 	return atf_no_error();
 }

Reply via email to