Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/kernel/arch/amd64 Add checks for si_code in dbregs_dr[...
details: https://anonhg.NetBSD.org/src/rev/a1e132993ac8
branches: trunk
changeset: 351602:a1e132993ac8
user: kamil <kamil%NetBSD.org@localhost>
date: Sun Feb 19 22:09:29 2017 +0000
description:
Add checks for si_code in dbregs_dr[0123]_trap_variable in ATF arch/amd64
Validate that debug register traps generate appropriate SIGTRAP signal with
TRAP_DBREG property in si_code.
Sponsored by <The NetBSD Foundation>
diffstat:
tests/kernel/arch/amd64/t_ptrace_wait.c | 64 +++++++++++++++++++++++++++++++-
1 files changed, 62 insertions(+), 2 deletions(-)
diffs (134 lines):
diff -r f0ab202b3394 -r a1e132993ac8 tests/kernel/arch/amd64/t_ptrace_wait.c
--- a/tests/kernel/arch/amd64/t_ptrace_wait.c Sun Feb 19 20:27:22 2017 +0000
+++ b/tests/kernel/arch/amd64/t_ptrace_wait.c Sun Feb 19 22:09:29 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.14 2017/02/18 04:30:34 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.15 2017/02/19 22:09:29 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.14 2017/02/18 04:30:34 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.15 2017/02/19 22:09:29 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -1330,6 +1330,9 @@
volatile int watchme;
union u dr7;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
dr7.raw = 0;
dr7.bits.global_dr0_breakpoint = 1;
dr7.bits.condition_dr0 = 3; /* 0b11 -- break on data write&read */
@@ -1392,6 +1395,18 @@
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_DBREG);
+
printf("Call CONTINUE for the child process\n");
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1444,6 +1459,9 @@
volatile int watchme;
union u dr7;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
dr7.raw = 0;
dr7.bits.global_dr1_breakpoint = 1;
dr7.bits.condition_dr1 = 3; /* 0b11 -- break on data write&read */
@@ -1506,6 +1524,18 @@
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_DBREG);
+
printf("Call CONTINUE for the child process\n");
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1558,6 +1588,9 @@
volatile int watchme;
union u dr7;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
dr7.raw = 0;
dr7.bits.global_dr2_breakpoint = 1;
dr7.bits.condition_dr2 = 3; /* 0b11 -- break on data write&read */
@@ -1620,6 +1653,18 @@
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_DBREG);
+
printf("Call CONTINUE for the child process\n");
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1672,6 +1717,9 @@
volatile int watchme;
union u dr7;
+ struct ptrace_siginfo info;
+ memset(&info, 0, sizeof(info));
+
dr7.raw = 0;
dr7.bits.global_dr3_breakpoint = 1;
dr7.bits.condition_dr3 = 3; /* 0b11 -- break on data write&read */
@@ -1734,6 +1782,18 @@
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_DBREG);
+
printf("Call CONTINUE for the child process\n");
ATF_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
Home |
Main Index |
Thread Index |
Old Index