Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Add new macro PTRACE_BREAKPOINT_ASM in <sys/ptrace.h> MD part
details: https://anonhg.NetBSD.org/src/rev/fbbbb8c86272
branches: trunk
changeset: 352854:fbbbb8c86272
user: kamil <kamil%NetBSD.org@localhost>
date: Wed Apr 12 18:17:59 2017 +0000
description:
Add new macro PTRACE_BREAKPOINT_ASM in <sys/ptrace.h> MD part
This macro ships with a MD-specific assembly instruction triggering
a software breakpoint.
Missing instruction for powerpc targets.
This code is used in ATF tests (lib/libc/sys/t_ptrace_wait).
Original patch by Nick Hudson, thanks!
diffstat:
sys/arch/aarch64/include/ptrace.h | 3 ++-
sys/arch/alpha/include/ptrace.h | 3 ++-
sys/arch/amd64/include/ptrace.h | 3 ++-
sys/arch/arm/include/ptrace.h | 6 ++++--
sys/arch/hppa/include/ptrace.h | 3 ++-
sys/arch/m68k/include/ptrace.h | 3 ++-
sys/arch/mips/include/ptrace.h | 3 ++-
sys/arch/sh3/include/ptrace.h | 4 +++-
sys/arch/sparc/include/ptrace.h | 3 ++-
sys/arch/vax/include/ptrace.h | 3 ++-
tests/lib/libc/sys/t_ptrace_wait.c | 14 ++++++--------
11 files changed, 29 insertions(+), 19 deletions(-)
diffs (208 lines):
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/aarch64/include/ptrace.h
--- a/sys/arch/aarch64/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/aarch64/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.4 2015/09/25 16:05:17 christos Exp $ */
+/* $NetBSD: ptrace.h,v 1.5 2017/04/12 18:17:59 kamil Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -57,6 +57,7 @@
#define PTRACE_REG_INTRV(r) (r)->r_reg[0]
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xd4, 0x20, 0x01, 0xa0 })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile(".word 0xa00120d4" ::: "memory")
#define PTRACE_BREAKPOINT_SIZE 4
#elif defined(__arm__)
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/alpha/include/ptrace.h
--- a/sys/arch/alpha/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/alpha/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.8 2015/09/25 16:05:17 christos Exp $ */
+/* $NetBSD: ptrace.h,v 1.9 2017/04/12 18:17:59 kamil Exp $ */
/*
* Copyright (c) 1994 Christopher G. Demetriou
@@ -53,4 +53,5 @@
#define PTRACE_REG_INTRV(r) (r)->r_regs[R_V0]
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x80, 0x00, 0x00, 0x00 })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile("bpt" ::: "memory")
#define PTRACE_BREAKPOINT_SIZE 4
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/amd64/include/ptrace.h
--- a/sys/arch/amd64/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/amd64/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.11 2017/04/08 00:25:49 kamil Exp $ */
+/* $NetBSD: ptrace.h,v 1.12 2017/04/12 18:17:59 kamil Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
@@ -64,6 +64,7 @@
#define PTRACE_REG_INTRV(r) (r)->regs[_REG_RAX]
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xcc })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile ("int3" : : : "memory")
#define PTRACE_BREAKPOINT_SIZE 1
#define PTRACE_BREAKPOINT_ADJ 1
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/arm/include/ptrace.h
--- a/sys/arch/arm/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/arm/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.10 2017/04/08 00:25:49 kamil Exp $ */
+/* $NetBSD: ptrace.h,v 1.11 2017/04/12 18:17:59 kamil Exp $ */
/*
* Copyright (c) 1995 Frank Lancaster
@@ -64,5 +64,7 @@
#define PTRACE_REG_SP(_r) (_r)->r_sp
#define PTRACE_REG_INTRV(_r) (_r)->r[0]
-#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xe7, 0xff, 0xff, 0xff })
+#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xe7, 0xff, 0xff, 0xfe })
+#define PTRACE_BREAKPOINT_INSN 0xe7fffffe
+#define PTRACE_BREAKPOINT_ASM __asm __volatile (".word " ___STRING(PTRACE_BREAKPOINT_INSN) )
#define PTRACE_BREAKPOINT_SIZE 4
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/hppa/include/ptrace.h
--- a/sys/arch/hppa/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/hppa/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.7 2017/04/08 00:25:49 kamil Exp $ */
+/* $NetBSD: ptrace.h,v 1.8 2017/04/12 18:17:59 kamil Exp $ */
/* $OpenBSD: ptrace.h,v 1.2 1998/12/01 03:05:44 mickey Exp $ */
@@ -58,4 +58,5 @@
#define PTRACE_REG_INTRV(r) (r)->r_regs[28]
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x00, 0x01, 0x00, 0x04 })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile("break %0, %1" :: "i" (HPPA_BREAK_KERNEL), "i" (HPPA_BREAK_SS) : "memory")
#define PTRACE_BREAKPOINT_SIZE 4
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/m68k/include/ptrace.h
--- a/sys/arch/m68k/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/m68k/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.11 2017/04/08 00:25:49 kamil Exp $ */
+/* $NetBSD: ptrace.h,v 1.12 2017/04/12 18:18:00 kamil Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
@@ -59,6 +59,7 @@
#define PTRACE_REG_INTRV(r) (r)->r_regs[0]
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x4e, 0x4f })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile("trap #15" ::: "memory")
#define PTRACE_BREAKPOINT_SIZE 2
#endif /* !_M68K_PTRACE_H_ */
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/mips/include/ptrace.h
--- a/sys/arch/mips/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/mips/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.15 2017/04/08 00:25:49 kamil Exp $ */
+/* $NetBSD: ptrace.h,v 1.16 2017/04/12 18:18:00 kamil Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -67,6 +67,7 @@
#define PTRACE_REG_INTRV(r) (r)->r_regs[2]
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x00, 0x00, 0x00, 0x0d })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile("break")
#define PTRACE_BREAKPOINT_SIZE 4
/*
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/sh3/include/ptrace.h
--- a/sys/arch/sh3/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/sh3/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.13 2017/04/08 00:25:49 kamil Exp $ */
+/* $NetBSD: ptrace.h,v 1.14 2017/04/12 18:18:00 kamil Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
@@ -71,7 +71,9 @@
#define PTRACE_REG_SP(r) r->r_r15
#define PTRACE_REG_INTV(r) r->r_r0
+#define PTRACE_BREAKPOINT_TRAP 0xc3
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0xc3, 0xc3 })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile("trapa %0" :: "i"(PTRACE_BREAKPOINT_TRAP))
#define PTRACE_BREAKPOINT_SIZE 2
#ifdef _KERNEL
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/sparc/include/ptrace.h
--- a/sys/arch/sparc/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/sparc/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.10 2016/11/25 14:10:31 christos Exp $ */
+/* $NetBSD: ptrace.h,v 1.11 2017/04/12 18:18:00 kamil Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -64,4 +64,5 @@
#define PTRACE_REG_INTRV(r) ((register_t)(r)->r_out[0])
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x91, 0xd0, 0x20, 0x01 })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile("ta 1")
#define PTRACE_BREAKPOINT_SIZE 4
diff -r ac2568bcba55 -r fbbbb8c86272 sys/arch/vax/include/ptrace.h
--- a/sys/arch/vax/include/ptrace.h Wed Apr 12 17:29:49 2017 +0000
+++ b/sys/arch/vax/include/ptrace.h Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.8 2017/04/11 07:45:36 skrll Exp $ */
+/* $NetBSD: ptrace.h,v 1.9 2017/04/12 18:18:00 kamil Exp $ */
/*
* Copyright (c) 1994 Ludd, University of Lule}, Sweden.
@@ -54,4 +54,5 @@
#define PTRACE_REG_INTRV(r) (r)->r0
#define PTRACE_BREAKPOINT ((const uint8_t[]) { 0x03 })
+#define PTRACE_BREAKPOINT_ASM __asm __volatile("bpt")
#define PTRACE_BREAKPOINT_SIZE 1
diff -r ac2568bcba55 -r fbbbb8c86272 tests/lib/libc/sys/t_ptrace_wait.c
--- a/tests/lib/libc/sys/t_ptrace_wait.c Wed Apr 12 17:29:49 2017 +0000
+++ b/tests/lib/libc/sys/t_ptrace_wait.c Wed Apr 12 18:17:59 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_ptrace_wait.c,v 1.3 2017/04/10 16:45:57 kamil Exp $ */
+/* $NetBSD: t_ptrace_wait.c,v 1.4 2017/04/12 18:18:00 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.3 2017/04/10 16:45:57 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.4 2017/04/12 18:18:00 kamil Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -5771,10 +5771,11 @@
FORKEE_ASSERT(raise(sigval) == 0);
printf("Before raising software breakpoint from child\n");
-#if defined(__x86_64__)
- __asm__ __volatile__ ("int3\n;");
+
+#ifdef PTRACE_BREAKPOINT_ASM
+ PTRACE_BREAKPOINT_ASM;
#else
- /* port me */
+ /* port me */
#endif
printf("Before exiting of the child process\n");
@@ -5831,9 +5832,6 @@
int happy;
#if defined(__arm__)
- /* PT_STEP not supported on arm 32-bit */
- atf_tc_expect_fail("PR kern/51918 PR kern/52119");
-#else
atf_tc_expect_fail("PR kern/52119");
#endif
Home |
Main Index |
Thread Index |
Old Index