Module Name:    src
Committed By:   kamil
Date:           Mon Jan 16 21:35:59 UTC 2017

Modified Files:
        src/sys/arch/amd64/amd64: process_machdep.c
        src/sys/arch/amd64/include: ptrace.h
        src/sys/arch/i386/i386: process_machdep.c
        src/sys/arch/i386/include: ptrace.h
        src/sys/sys: ptrace.h
        src/tests/kernel/arch/amd64: t_ptrace_wait.c

Log Message:
Refactor ptrace_watchpoint structure to allow extensions

Add new field pw_type in the ptrace_watchpoint structure.

amd64 and i386 offer the current set of watchpoints as
PTRACE_PW_TYPE_DBREGS.

On other archs than x86, there are readily available different types of
hardware assisted watchpoints like for code-only or data-only registers on
ARM. Also in future there is an option to implement MMU-based watchpoints
and future per-port or per-cpu extensions.

Next step is to alter this interface on x86 to generate SIGTRAP with
si_code TRAP_HWWTRAP with additional information on occurred event:
 - which watchpoint fired,
 - additional watchpoint-type specific information, like on amd64 with
   PTRACE_PW_TYPE_DBREGS.:
   * only watchpoint fired
   * watchpoint fired and single step occurred

Adjust ATF tests for the pw_type change.

Sponsored by <The NetBSD Foundation>


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/amd64/amd64/process_machdep.c
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amd64/include/ptrace.h
cvs rdiff -u -r1.87 -r1.88 src/sys/arch/i386/i386/process_machdep.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/include/ptrace.h
cvs rdiff -u -r1.54 -r1.55 src/sys/sys/ptrace.h
cvs rdiff -u -r1.9 -r1.10 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/sys/arch/amd64/amd64/process_machdep.c
diff -u src/sys/arch/amd64/amd64/process_machdep.c:1.30 src/sys/arch/amd64/amd64/process_machdep.c:1.31
--- src/sys/arch/amd64/amd64/process_machdep.c:1.30	Thu Dec 15 12:04:17 2016
+++ src/sys/arch/amd64/amd64/process_machdep.c	Mon Jan 16 21:35:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.30 2016/12/15 12:04:17 kamil Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.31 2017/01/16 21:35:59 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.30 2016/12/15 12:04:17 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.31 2017/01/16 21:35:59 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -182,6 +182,7 @@ int
 process_read_watchpoint(struct lwp *l, struct ptrace_watchpoint *pw)
 {
 
+	pw->pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw->pw_md.md_address =
 	    (void*)(intptr_t)l->l_md.md_watchpoint[pw->pw_index].address;
 	pw->pw_md.md_condition = l->l_md.md_watchpoint[pw->pw_index].condition;
@@ -210,6 +211,9 @@ process_write_watchpoint(struct lwp *l, 
 	if (pw->pw_index > X86_HW_WATCHPOINTS)
 		return (EINVAL);
 
+	if (pw->pw_type != PTRACE_PW_TYPE_DBREGS)
+		return (EINVAL);
+
 	if (pw->pw_md.md_address == 0) {
 		l->l_md.md_watchpoint[pw->pw_index].address = 0;
 		update_mdl_x86_hw_watchpoints(l);

Index: src/sys/arch/amd64/include/ptrace.h
diff -u src/sys/arch/amd64/include/ptrace.h:1.8 src/sys/arch/amd64/include/ptrace.h:1.9
--- src/sys/arch/amd64/include/ptrace.h:1.8	Thu Dec 15 12:04:17 2016
+++ src/sys/arch/amd64/include/ptrace.h	Mon Jan 16 21:35:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.8 2016/12/15 12:04:17 kamil Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.9 2017/01/16 21:35:59 kamil Exp $	*/
 
 /*
  * Copyright (c) 1993 Christopher G. Demetriou
@@ -68,6 +68,22 @@
 #define __HAVE_PTRACE_WATCHPOINTS
 
 /*
+ * The current list of supported hardware watchpoints
+ */
+#define PTRACE_PW_TYPE_DBREGS	1
+
+struct mdpw {
+	union {
+		/* Debug Registers DR0-3, DR6, DR7 */
+		struct {
+			void	*_md_address;
+			int	 _md_condition;
+			int	 _md_length;
+		} _dbregs;
+	} _type;
+};
+
+/*
  * This MD structure translates into x86_hw_watchpoint
  *
  * pw_address - 0 represents disabled hardware watchpoint
@@ -87,11 +103,11 @@
  * Helper symbols for conditions and length are available in <x86/dbregs.h>
  *
  */
-struct mdpw {
-	void	*md_address;
-	int	 md_condition;
-	int	 md_length;
-};
+
+#define	md_address	_type._dbregs._md_address
+#define	md_condition	_type._dbregs._md_condition
+#define	md_length	_type._dbregs._md_length
+
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd32.h"

Index: src/sys/arch/i386/i386/process_machdep.c
diff -u src/sys/arch/i386/i386/process_machdep.c:1.87 src/sys/arch/i386/i386/process_machdep.c:1.88
--- src/sys/arch/i386/i386/process_machdep.c:1.87	Thu Dec 15 12:04:18 2016
+++ src/sys/arch/i386/i386/process_machdep.c	Mon Jan 16 21:35:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: process_machdep.c,v 1.87 2016/12/15 12:04:18 kamil Exp $	*/
+/*	$NetBSD: process_machdep.c,v 1.88 2017/01/16 21:35:59 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.87 2016/12/15 12:04:18 kamil Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.88 2017/01/16 21:35:59 kamil Exp $");
 
 #include "opt_vm86.h"
 #include "opt_ptrace.h"
@@ -362,6 +362,7 @@ int
 process_read_watchpoint(struct lwp *l, struct ptrace_watchpoint *pw)
 {
 
+	pw->pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw->pw_md.md_address =
 	    (void*)(intptr_t)l->l_md.md_watchpoint[pw->pw_index].address;
 	pw->pw_md.md_condition = l->l_md.md_watchpoint[pw->pw_index].condition;
@@ -390,6 +391,9 @@ process_write_watchpoint(struct lwp *l, 
 	if (pw->pw_index > X86_HW_WATCHPOINTS)
 		return (EINVAL);
 
+	if (pw->pw_type != PTRACE_PW_TYPE_DBREGS)
+		return (EINVAL);
+
 	if (pw->pw_md.md_address == 0) {
 		l->l_md.md_watchpoint[pw->pw_index].address = 0;
 		update_mdl_x86_hw_watchpoints(l);

Index: src/sys/arch/i386/include/ptrace.h
diff -u src/sys/arch/i386/include/ptrace.h:1.16 src/sys/arch/i386/include/ptrace.h:1.17
--- src/sys/arch/i386/include/ptrace.h:1.16	Thu Dec 15 12:04:18 2016
+++ src/sys/arch/i386/include/ptrace.h	Mon Jan 16 21:35:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.16 2016/12/15 12:04:18 kamil Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.17 2017/01/16 21:35:59 kamil Exp $	*/
 
 /*
  * Copyright (c) 2001 Wasabi Systems, Inc.
@@ -115,6 +115,22 @@
 #define __HAVE_PTRACE_WATCHPOINTS
 
 /*
+ * The current list of supported hardware watchpoints
+ */
+#define	PTRACE_PW_TYPE_DBREGS	1
+
+struct mdpw {
+	union {
+		/* Debug Registers DR0-3, DR6, DR7 */
+		struct {
+			void	*_md_address;
+			int	_md_condition; 
+			int	_md_length;
+		} _dbregs;
+	} _type;
+};
+
+/*
  * This MD structure translates into x86_hw_watchpoint
  *
  * pw_address - 0 represents disabled hardware watchpoint
@@ -134,11 +150,11 @@
  * Helper symbols for conditions and length are available in <x86/dbregs.h>
  *
  */
-struct mdpw {
-	void	*md_address;
-	int	 md_condition;
-	int	 md_length;
-};
+
+#define	md_address	_type._dbregs._md_address
+#define	md_condition	_type._dbregs._md_condition
+#define	md_length	_type._dbregs._md_length
+
 
 #ifdef _KERNEL
 

Index: src/sys/sys/ptrace.h
diff -u src/sys/sys/ptrace.h:1.54 src/sys/sys/ptrace.h:1.55
--- src/sys/sys/ptrace.h:1.54	Sat Jan 14 06:36:52 2017
+++ src/sys/sys/ptrace.h	Mon Jan 16 21:35:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: ptrace.h,v 1.54 2017/01/14 06:36:52 kamil Exp $	*/
+/*	$NetBSD: ptrace.h,v 1.55 2017/01/16 21:35:59 kamil Exp $	*/
 
 /*-
  * Copyright (c) 1984, 1993
@@ -142,6 +142,7 @@ struct ptrace_lwpinfo {
 typedef struct ptrace_watchpoint {
 	int		pw_index;	/* HW Watchpoint ID (count from 0) */
 	lwpid_t		pw_lwpid;	/* LWP described */
+	int		pw_type;	/* HW Watchpoint type w/ MD content */
 #ifdef __HAVE_PTRACE_WATCHPOINTS
 	struct mdpw	pw_md;		/* MD fields */
 #endif

Index: src/tests/kernel/arch/amd64/t_ptrace_wait.c
diff -u src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.9 src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.10
--- src/tests/kernel/arch/amd64/t_ptrace_wait.c:1.9	Fri Jan 13 21:30:41 2017
+++ src/tests/kernel/arch/amd64/t_ptrace_wait.c	Mon Jan 16 21:35:59 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.9 2017/01/13 21:30:41 christos Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.10 2017/01/16 21:35:59 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.9 2017/01/13 21:30:41 christos Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.10 2017/01/16 21:35:59 kamil Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -247,6 +247,7 @@ ATF_TC_BODY(watchpoint_read, tc)
 		printf("struct ptrace {\n");
 		printf("\t.pw_index=%d\n", pw.pw_index);
 		printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+		printf("\t.pw_type=%#x\n", pw.pw_type);
 		printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 		printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 		printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -320,6 +321,7 @@ ATF_TC_BODY(watchpoint_write_unmodified,
 		printf("struct ptrace {\n");
 		printf("\t.pw_index=%d\n", pw.pw_index);
 		printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+		printf("\t.pw_type=%#x\n", pw.pw_type);
 		printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 		printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 		printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -390,6 +392,7 @@ ATF_TC_BODY(watchpoint_trap_code0, tc)
 
 	pw.pw_index = i;
 	pw.pw_lwpid = 0;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = (void *)check_happy;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_EXECUTION;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -397,6 +400,7 @@ ATF_TC_BODY(watchpoint_trap_code0, tc)
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -478,6 +482,7 @@ ATF_TC_BODY(watchpoint_trap_code1, tc)
 
 	pw.pw_index = i;
 	pw.pw_lwpid = 0;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = (void *)check_happy;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_EXECUTION;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -485,6 +490,7 @@ ATF_TC_BODY(watchpoint_trap_code1, tc)
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%d\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -566,6 +572,7 @@ ATF_TC_BODY(watchpoint_trap_code2, tc)
 
 	pw.pw_index = i;
 	pw.pw_lwpid = 0;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = (void *)check_happy;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_EXECUTION;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -573,6 +580,7 @@ ATF_TC_BODY(watchpoint_trap_code2, tc)
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -654,6 +662,7 @@ ATF_TC_BODY(watchpoint_trap_code3, tc)
 
 	pw.pw_index = i;
 	pw.pw_lwpid = 0;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = (void *)check_happy;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_EXECUTION;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -661,6 +670,7 @@ ATF_TC_BODY(watchpoint_trap_code3, tc)
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -741,6 +751,7 @@ ATF_TC_BODY(watchpoint_trap_data_write0,
 	printf("Preparing code watchpoint trap %d\n", i);
 
 	pw.pw_index = 0;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = &watchme;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_WRITE;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -748,6 +759,7 @@ ATF_TC_BODY(watchpoint_trap_data_write0,
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -824,6 +836,7 @@ ATF_TC_BODY(watchpoint_trap_data_write1,
 	printf("Preparing code watchpoint trap %d\n", i);
 
 	pw.pw_index = i;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = &watchme;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_WRITE;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -831,6 +844,7 @@ ATF_TC_BODY(watchpoint_trap_data_write1,
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -907,6 +921,7 @@ ATF_TC_BODY(watchpoint_trap_data_write2,
 	printf("Preparing code watchpoint trap %d\n", i);
 
 	pw.pw_index = i;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = &watchme;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_WRITE;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -914,6 +929,7 @@ ATF_TC_BODY(watchpoint_trap_data_write2,
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -991,6 +1007,7 @@ ATF_TC_BODY(watchpoint_trap_data_write3,
 	printf("Preparing code watchpoint trap %d\n", i);
 
 	pw.pw_index = i;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = &watchme;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_WRITE;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -998,6 +1015,7 @@ ATF_TC_BODY(watchpoint_trap_data_write3,
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -1074,6 +1092,7 @@ ATF_TC_BODY(watchpoint_trap_data_rw0, tc
 	printf("Preparing code watchpoint trap %d\n", i);
 
 	pw.pw_index = i;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = &watchme;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_READWRITE;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -1081,6 +1100,7 @@ ATF_TC_BODY(watchpoint_trap_data_rw0, tc
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -1157,6 +1177,7 @@ ATF_TC_BODY(watchpoint_trap_data_rw1, tc
 	printf("Preparing code watchpoint trap %d\n", i);
 
 	pw.pw_index = i;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = &watchme;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_READWRITE;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -1164,6 +1185,7 @@ ATF_TC_BODY(watchpoint_trap_data_rw1, tc
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -1240,6 +1262,7 @@ ATF_TC_BODY(watchpoint_trap_data_rw2, tc
 	printf("Preparing code watchpoint trap %d\n", i);
 
 	pw.pw_index = i;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = &watchme;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_READWRITE;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -1247,6 +1270,7 @@ ATF_TC_BODY(watchpoint_trap_data_rw2, tc
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);
@@ -1323,6 +1347,7 @@ ATF_TC_BODY(watchpoint_trap_data_rw3, tc
 	printf("Preparing code watchpoint trap %d\n", i);
 
 	pw.pw_index = i;
+	pw.pw_type = PTRACE_PW_TYPE_DBREGS;
 	pw.pw_md.md_address = &watchme;
 	pw.pw_md.md_condition = X86_HW_WATCHPOINT_DR7_CONDITION_DATA_READWRITE;
 	pw.pw_md.md_length = X86_HW_WATCHPOINT_DR7_LENGTH_BYTE;
@@ -1330,6 +1355,7 @@ ATF_TC_BODY(watchpoint_trap_data_rw3, tc
 	printf("struct ptrace {\n");
 	printf("\t.pw_index=%d\n", pw.pw_index);
 	printf("\t.pw_lwpid=%d\n", pw.pw_lwpid);
+	printf("\t.pw_type=%#x\n", pw.pw_type);
 	printf("\t.pw_md.md_address=%p\n", pw.pw_md.md_address);
 	printf("\t.pw_md.md_condition=%#x\n", pw.pw_md.md_condition);
 	printf("\t.pw_md.md_length=%#x\n", pw.pw_md.md_length);

Reply via email to