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!
This commit is contained in:
parent
947610a7b0
commit
12cbcbd04f
|
@ -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__)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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
|
||||
|
||||
/*
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 @@ ATF_TC_BODY(signal3, tc)
|
|||
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 @@ ATF_TC_BODY(signal4, tc)
|
|||
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
|
||||
|
||||
|
|
Loading…
Reference in New Issue