Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/sh3 Implement PT_STEP.
details: https://anonhg.NetBSD.org/src/rev/9293b29e6966
branches: trunk
changeset: 761472:9293b29e6966
user: uwe <uwe%NetBSD.org@localhost>
date: Fri Jan 28 21:06:07 2011 +0000
description:
Implement PT_STEP.
diffstat:
sys/arch/sh3/include/ptrace.h | 6 ++++--
sys/arch/sh3/include/userret.h | 29 ++++++++++++++++++++++++++++-
sys/arch/sh3/sh3/db_interface.c | 30 ++++++++----------------------
sys/arch/sh3/sh3/exception.c | 5 +++--
sys/arch/sh3/sh3/exception_vector.S | 18 ++++++++++--------
sys/arch/sh3/sh3/process_machdep.c | 10 ++++++----
sys/arch/sh3/sh3/sh3_machdep.c | 34 ++++++++++++++++++++++++++++++++--
7 files changed, 91 insertions(+), 41 deletions(-)
diffs (truncated from 324 to 300 lines):
diff -r 28f209fa2190 -r 9293b29e6966 sys/arch/sh3/include/ptrace.h
--- a/sys/arch/sh3/include/ptrace.h Fri Jan 28 20:36:19 2011 +0000
+++ b/sys/arch/sh3/include/ptrace.h Fri Jan 28 21:06:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ptrace.h,v 1.8 2008/10/27 23:50:12 uwe Exp $ */
+/* $NetBSD: ptrace.h,v 1.9 2011/01/28 21:06:07 uwe Exp $ */
/*
* Copyright (c) 1993 Christopher G. Demetriou
@@ -37,6 +37,8 @@
* sh3-dependent ptrace definitions
*/
+#define PT_STEP (PT_FIRSTMACH + 0)
+
/* old struct reg (now struct __reg40) that was missing r_gbr */
#define PT___GETREGS40 (PT_FIRSTMACH + 1)
#define PT___SETREGS40 (PT_FIRSTMACH + 2)
@@ -45,7 +47,7 @@
#define PT_SETREGS (PT_FIRSTMACH + 4)
#define PT_MACHDEP_STRINGS \
- "(unused)", \
+ "PT_STEP", \
"PT___GETREGS40", \
"PT___SETREGS40", \
"PT_GETREGS", \
diff -r 28f209fa2190 -r 9293b29e6966 sys/arch/sh3/include/userret.h
--- a/sys/arch/sh3/include/userret.h Fri Jan 28 20:36:19 2011 +0000
+++ b/sys/arch/sh3/include/userret.h Fri Jan 28 21:06:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: userret.h,v 1.10 2007/11/05 20:37:48 ad Exp $ */
+/* $NetBSD: userret.h,v 1.11 2011/01/28 21:06:07 uwe Exp $ */
/*
* Copyright (c) 1992, 1993
@@ -81,12 +81,39 @@
#include <sys/userret.h>
+#include <sh3/ubcreg.h>
+#include "opt_ptrace.h"
+
+
static __inline void
userret(struct lwp *l)
{
/* Invoke MI userret code */
mi_userret(l);
+
+#ifdef PTRACE
+ /* Check if lwp is being PT_STEP'ed */
+ if (l->l_md.md_flags & MDP_SSTEP) {
+ struct trapframe *tf = l->l_md.md_regs;
+
+ /*
+ * Channel A is set up for single stepping in sh_cpu_init().
+ * Before RTE we write tf_ubc to BBRA and tf_spc to BARA.
+ */
+#ifdef SH3
+ if (CPU_IS_SH3) {
+ tf->tf_ubc = UBC_CYCLE_INSN | UBC_CYCLE_READ
+ | SH3_UBC_CYCLE_CPU;
+ }
+#endif
+#ifdef SH4
+ if (CPU_IS_SH4) {
+ tf->tf_ubc = UBC_CYCLE_INSN | UBC_CYCLE_READ;
+ }
+#endif
+ }
+#endif /* PTRACE */
}
#endif /* !_SH3_USERRET_H_ */
diff -r 28f209fa2190 -r 9293b29e6966 sys/arch/sh3/sh3/db_interface.c
--- a/sys/arch/sh3/sh3/db_interface.c Fri Jan 28 20:36:19 2011 +0000
+++ b/sys/arch/sh3/sh3/db_interface.c Fri Jan 28 21:06:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: db_interface.c,v 1.60 2011/01/26 18:43:30 uwe Exp $ */
+/* $NetBSD: db_interface.c,v 1.61 2011/01/28 21:06:07 uwe Exp $ */
/*-
* Copyright (C) 2002 UCHIYAMA Yasushi. All rights reserved.
@@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.60 2011/01/26 18:43:30 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.61 2011/01/28 21:06:07 uwe Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -227,35 +227,21 @@
db_set_single_step(db_regs_t *regs)
{
- _reg_write_2(SH_(BBRA), 0); /* disable break */
-
+ /*
+ * Channel A is set up for single stepping in sh_cpu_init().
+ * Before RTE we write tf_ubc to BBRA and tf_spc to BARA.
+ */
#ifdef SH3
if (CPU_IS_SH3) {
- /* A: compare all address bits */
- _reg_write_4(SH3_BAMRA, 0x00000000);
-
- /* A: break after execution, ignore ASID */
- _reg_write_4(SH3_BRCR, (UBC_CTL_A_AFTER_INSN
- | SH3_UBC_CTL_A_MASK_ASID));
-
- /* will be written to BBRA before RTE */
regs->tf_ubc = UBC_CYCLE_INSN | UBC_CYCLE_READ
| SH3_UBC_CYCLE_CPU;
}
-#endif /* SH3 */
-
+#endif
#ifdef SH4
if (CPU_IS_SH4) {
- /* A: compare all address bits, ignore ASID */
- _reg_write_1(SH4_BAMRA, SH4_UBC_MASK_NONE | SH4_UBC_MASK_ASID);
-
- /* A: break after execution */
- _reg_write_2(SH4_BRCR, UBC_CTL_A_AFTER_INSN);
-
- /* will be written to BBRA before RTE */
regs->tf_ubc = UBC_CYCLE_INSN | UBC_CYCLE_READ;
}
-#endif /* SH4 */
+#endif
}
void
diff -r 28f209fa2190 -r 9293b29e6966 sys/arch/sh3/sh3/exception.c
--- a/sys/arch/sh3/sh3/exception.c Fri Jan 28 20:36:19 2011 +0000
+++ b/sys/arch/sh3/sh3/exception.c Fri Jan 28 21:06:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exception.c,v 1.60 2011/01/27 01:01:55 uwe Exp $ */
+/* $NetBSD: exception.c,v 1.61 2011/01/28 21:06:08 uwe Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved.
@@ -79,7 +79,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.60 2011/01/27 01:01:55 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exception.c,v 1.61 2011/01/28 21:06:08 uwe Exp $");
#include "opt_ddb.h"
#include "opt_kgdb.h"
@@ -185,6 +185,7 @@
break;
case EXPEVT_BREAK | EXP_USER:
+ l->l_md.md_flags &= ~MDP_SSTEP;
KSI_INIT_TRAP(&ksi);
ksi.ksi_signo = SIGTRAP;
ksi.ksi_code = TRAP_TRACE;
diff -r 28f209fa2190 -r 9293b29e6966 sys/arch/sh3/sh3/exception_vector.S
--- a/sys/arch/sh3/sh3/exception_vector.S Fri Jan 28 20:36:19 2011 +0000
+++ b/sys/arch/sh3/sh3/exception_vector.S Fri Jan 28 21:06:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exception_vector.S,v 1.46 2010/12/20 00:25:43 matt Exp $ */
+/* $NetBSD: exception_vector.S,v 1.47 2011/01/28 21:06:08 uwe Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -28,6 +28,8 @@
#include "opt_cputype.h"
#include "opt_ddb.h"
+#include "opt_ptrace.h"
+
#include "assym.h"
#include <sh3/param.h>
@@ -46,7 +48,7 @@
#define _ALIGN_TEXT .align 5
#include <sh3/asm.h>
-__KERNEL_RCSID(0, "$NetBSD: exception_vector.S,v 1.46 2010/12/20 00:25:43 matt Exp $")
+__KERNEL_RCSID(0, "$NetBSD: exception_vector.S,v 1.47 2011/01/28 21:06:08 uwe Exp $")
/*
@@ -97,12 +99,12 @@
/* general_exception(curlwp, tf, TEA); */
1: mov r4, r8
-#ifdef DDB
+#if defined(PTRACE) || defined(DDB)
mov #0, r2
MOV (BBRA, r1)
- mov.w r2, @r1 /* disable UBC */
mov.l r2, @(TF_UBC, r14) /* clear tf->tf_ubc */
-#endif /* DDB */
+ mov.w r2, @r1 /* disable UBC channel A */
+#endif
__EXCEPTION_UNBLOCK(r0, r1)
mov.l .Lg_general_exception, r0
jsr @r0
@@ -114,9 +116,9 @@
jsr @r0
mov r14, r5
-#ifdef DDB
+#if defined(PTRACE) || defined(DDB)
mov.l @(TF_UBC, r14), r2
- tst r2, r2 ! ddb single-step == 0?
+ tst r2, r2 ! single-step == 0?
bt .Lg_return_from_exception
!! We are returning from DDB to do single step. Channel A in
@@ -127,7 +129,7 @@
mov.l @(TF_SPC, r14), r4
mov.l r4, @r5 ! BARA = tf->tf_spc
mov.w r2, @r3 ! BBRA = tf->tf_ubc
-#endif /* DDB */
+#endif /* PTRACE || DDB */
.Lg_return_from_exception:
__EXCEPTION_RETURN
diff -r 28f209fa2190 -r 9293b29e6966 sys/arch/sh3/sh3/process_machdep.c
--- a/sys/arch/sh3/sh3/process_machdep.c Fri Jan 28 20:36:19 2011 +0000
+++ b/sys/arch/sh3/sh3/process_machdep.c Fri Jan 28 21:06:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: process_machdep.c,v 1.18 2009/11/21 17:40:28 rmind Exp $ */
+/* $NetBSD: process_machdep.c,v 1.19 2011/01/28 21:06:08 uwe Exp $ */
/*
* Copyright (c) 1993 The Regents of the University of California.
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.18 2009/11/21 17:40:28 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.19 2011/01/28 21:06:08 uwe Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -343,9 +343,11 @@
{
if (sstep)
- return (EINVAL);
+ l->l_md.md_flags |= MDP_SSTEP;
+ else
+ l->l_md.md_flags &= ~MDP_SSTEP;
- return (0);
+ return 0;
}
int
diff -r 28f209fa2190 -r 9293b29e6966 sys/arch/sh3/sh3/sh3_machdep.c
--- a/sys/arch/sh3/sh3/sh3_machdep.c Fri Jan 28 20:36:19 2011 +0000
+++ b/sys/arch/sh3/sh3/sh3_machdep.c Fri Jan 28 21:06:07 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: sh3_machdep.c,v 1.89 2011/01/26 23:29:16 uwe Exp $ */
+/* $NetBSD: sh3_machdep.c,v 1.90 2011/01/28 21:06:08 uwe Exp $ */
/*-
* Copyright (c) 1996, 1997, 1998, 2002 The NetBSD Foundation, Inc.
@@ -65,11 +65,13 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sh3_machdep.c,v 1.89 2011/01/26 23:29:16 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sh3_machdep.c,v 1.90 2011/01/28 21:06:08 uwe Exp $");
+#include "opt_ddb.h"
#include "opt_kgdb.h"
#include "opt_memsize.h"
#include "opt_kstack_debug.h"
+#include "opt_ptrace.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -104,6 +106,7 @@
#include <sh3/mmu.h>
#include <sh3/pcb.h>
#include <sh3/intr.h>
+#include <sh3/ubcreg.h>
/* Our exported CPU info; we can have only one. */
struct cpu_info cpu_info_store;
@@ -190,6 +193,33 @@
/* Set page size (4KB) */
uvm_setpagesize();
+
+ /* setup UBC channel A for single-stepping */
+#if defined(PTRACE) || defined(DDB)
+ _reg_write_2(SH_(BBRA), 0); /* disable channel A */
+ _reg_write_2(SH_(BBRB), 0); /* disable channel B */
+
Home |
Main Index |
Thread Index |
Old Index