Module Name: src
Committed By: kamil
Date: Wed Jan 18 05:14:34 UTC 2017
Modified Files:
src/tests/kernel/arch/amd64: t_ptrace_wait.c
Log Message:
Use siginfo_t to validate tests/kernel/arch/amd64/t_ptrace_wait*
This change makes sure that the fired expected watchpoint with expected
property. It's done with PT_GET_SIGINFO and checking SIGTRAP codes.
Sponsored by <The NetBSD Foundation>
To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.11
--- src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.10 Mon Jan 16 21:35:59 2017
+++ src/tests/kernel/arch/amd64/t_ptrace_wait.c Wed Jan 18 05:14:34 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.10 2017/01/16 21:35:59 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.11 2017/01/18 05:14:34 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.10 2017/01/16 21:35:59 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.11 2017/01/18 05:14:34 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -366,6 +366,8 @@ ATF_TC_BODY(watchpoint_trap_code0, tc)
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -418,6 +420,20 @@ ATF_TC_BODY(watchpoint_trap_code0, tc)
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 0);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
pw.pw_md.md_address = NULL;
printf("Before writing watchpoint %d (disable it)\n", i);
ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1);
@@ -456,6 +472,8 @@ ATF_TC_BODY(watchpoint_trap_code1, tc)
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -508,6 +526,20 @@ ATF_TC_BODY(watchpoint_trap_code1, tc)
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 1);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
pw.pw_md.md_address = NULL;
printf("Before writing watchpoint %d (disable it)\n", i);
ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1);
@@ -546,6 +578,8 @@ ATF_TC_BODY(watchpoint_trap_code2, tc)
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -598,6 +632,20 @@ ATF_TC_BODY(watchpoint_trap_code2, tc)
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 2);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
pw.pw_md.md_address = NULL;
printf("Before writing watchpoint %d (disable it)\n", i);
ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1);
@@ -636,6 +684,8 @@ ATF_TC_BODY(watchpoint_trap_code3, tc)
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -688,6 +738,20 @@ ATF_TC_BODY(watchpoint_trap_code3, tc)
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 3);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
pw.pw_md.md_address = NULL;
printf("Before writing watchpoint %d (disable it)\n", i);
ATF_REQUIRE(ptrace(PT_WRITE_WATCHPOINT, child, &pw, len) != -1);
@@ -726,6 +790,8 @@ ATF_TC_BODY(watchpoint_trap_data_write0,
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -777,6 +843,20 @@ ATF_TC_BODY(watchpoint_trap_data_write0,
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 0);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
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);
@@ -811,6 +891,8 @@ ATF_TC_BODY(watchpoint_trap_data_write1,
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -862,6 +944,20 @@ ATF_TC_BODY(watchpoint_trap_data_write1,
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 1);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
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);
@@ -896,6 +992,8 @@ ATF_TC_BODY(watchpoint_trap_data_write2,
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -947,6 +1045,20 @@ ATF_TC_BODY(watchpoint_trap_data_write2,
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 2);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
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);
@@ -982,6 +1094,8 @@ ATF_TC_BODY(watchpoint_trap_data_write3,
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -1033,6 +1147,20 @@ ATF_TC_BODY(watchpoint_trap_data_write3,
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 3);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
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);
@@ -1067,6 +1195,8 @@ ATF_TC_BODY(watchpoint_trap_data_rw0, tc
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -1118,6 +1248,20 @@ ATF_TC_BODY(watchpoint_trap_data_rw0, tc
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 0);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
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);
@@ -1152,6 +1296,8 @@ ATF_TC_BODY(watchpoint_trap_data_rw1, tc
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -1203,6 +1349,20 @@ ATF_TC_BODY(watchpoint_trap_data_rw1, tc
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 1);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
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);
@@ -1237,6 +1397,8 @@ ATF_TC_BODY(watchpoint_trap_data_rw2, tc
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -1288,6 +1450,20 @@ ATF_TC_BODY(watchpoint_trap_data_rw2, tc
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 2);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
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);
@@ -1322,6 +1498,8 @@ ATF_TC_BODY(watchpoint_trap_data_rw3, tc
struct ptrace_watchpoint pw;
int len = sizeof(pw);
int watchme = 1234;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
printf("Before forking process PID=%d\n", getpid());
ATF_REQUIRE((child = fork()) != -1);
@@ -1373,6 +1551,20 @@ ATF_TC_BODY(watchpoint_trap_data_rw3, tc
validate_status_stopped(status, SIGTRAP);
+ printf("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
+ ATF_REQUIRE(ptrace(PT_GET_SIGINFO, child, &info, sizeof(info)) != -1);
+
+ printf("Signal traced to lwpid=%d\n", info.psi_lwpid);
+ printf("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
+ info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
+ info.psi_siginfo.si_errno);
+
+ printf("Before checking siginfo_t\n");
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_HWWPT);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap2, 3);
+ ATF_REQUIRE_EQ(info.psi_siginfo.si_trap3, X86_HW_WATCHPOINT_EVENT_FIRED);
+
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);