Fix the problem that single-step tracing of a trap instruction

drops the system into kernel debugger.
This commit is contained in:
itohy 1999-10-26 00:20:34 +00:00
parent 3b435a7396
commit cef3e31058
20 changed files with 131 additions and 65 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.12 1999/05/06 14:16:07 kleink Exp $
# $NetBSD: genassym.cf,v 1.13 1999/10/26 00:20:34 itohy Exp $
#-
# Copyright (c) 1997 The NetBSD Foundation, Inc.
@ -130,6 +130,7 @@ define PSL_IPL7 PSL_IPL7
define PSL_LOWIPL PSL_LOWIPL
define PSL_HIGHIPL PSL_HIGHIPL
define PSL_USER PSL_USER
define PSL_TS PSL_T | PSL_S
define SPL1 PSL_S | PSL_IPL1
define SPL2 PSL_S | PSL_IPL2
define SPL3 PSL_S | PSL_IPL3

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.63 1999/09/17 19:59:40 thorpej Exp $ */
/* $NetBSD: locore.s,v 1.64 1999/10/26 00:20:34 itohy Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -435,9 +435,17 @@ _trace:
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@-
moveq #T_TRACE,d0
| Check PSW and see what happen.
| T=0 S=0 (should not happen)
| T=1 S=0 trace trap from user mode
| T=0 S=1 trace trap on a trap instruction
| T=1 S=1 trace trap from system mode (kernel breakpoint)
movw sp@(FR_HW),d1 | get PSW
andw #PSL_S,d1 | from system mode?
jne kbrkpt | yes, kernel breakpoint
notw d1 | XXX no support for T0 on 680[234]0
andw #PSL_TS,d1 | from system mode (T=1, S=1)?
jeq kbrkpt | yes, kernel breakpoint
jra fault | no, user-mode fault
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.44 1999/07/08 18:05:26 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.45 1999/10/26 00:20:35 itohy Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -375,14 +375,6 @@ trap(type, code, v, frame)
sticks = p->p_sticks;
p->p_md.md_regs = frame.f_regs;
}
#ifdef DDB
if (type == T_TRACE || type == T_BREAKPOINT) {
if (kdb_trap(type, (db_regs_t *)&frame))
return;
}
#endif
switch (type) {
#ifdef DEBUG
dopanic:
@ -516,14 +508,15 @@ trap(type, code, v, frame)
* NetBSD and HP-UX traps get mapped by locore.s into T_TRACE.
* SUN 3.x traps get passed through as T_TRAP15 and are not really
* supported yet.
*
* XXX: We should never get kernel-mode T_TRAP15
* XXX: because locore.s now gives them special treatment.
*/
case T_TRACE:
case T_TRAP15:
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
break;
return;
case T_TRACE|T_USER:
case T_TRAP15|T_USER:
#ifdef COMPAT_SUNOS
/*
* SunOS uses Trap #2 for a "CPU cache flush".
@ -535,6 +528,9 @@ trap(type, code, v, frame)
return;
}
#endif
/* FALLTHROUGH */
case T_TRACE: /* tracing a trap instruction */
case T_TRAP15|T_USER:
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
break;

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.17 1999/07/31 20:50:48 thorpej Exp $
# $NetBSD: genassym.cf,v 1.18 1999/10/26 00:20:38 itohy Exp $
#
# Copyright (c) 1982, 1990, 1993
@ -168,6 +168,7 @@ define PSL_IPL7 PSL_IPL7
define PSL_LOWIPL PSL_LOWIPL
define PSL_HIGHIPL PSL_HIGHIPL
define PSL_USER PSL_USER
define PSL_TS PSL_T | PSL_S
define SPL1 PSL_S | PSL_IPL1
define SPL2 PSL_S | PSL_IPL2
define SPL3 PSL_S | PSL_IPL3

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.102 1999/10/24 19:12:44 thorpej Exp $ */
/* $NetBSD: locore.s,v 1.103 1999/10/26 00:20:38 itohy Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
@ -865,9 +865,17 @@ ENTRY_NOPROFILE(trace)
clrl %sp@- | stack adjust count
moveml #0xFFFF,%sp@-
moveq #T_TRACE,%d0
| Check PSW and see what happen.
| T=0 S=0 (should not happen)
| T=1 S=0 trace trap from user mode
| T=0 S=1 trace trap on a trap instruction
| T=1 S=1 trace trap from system mode (kernel breakpoint)
movw %sp@(FR_HW),%d1 | get PSW
andw #PSL_S,%d1 | from system mode?
jne Lkbrkpt | yes, kernel breakpoint
notw %d1 | XXX no support for T0 on 680[234]0
andw #PSL_TS,%d1 | from system mode (T=1, S=1)?
jeq Lkbrkpt | yes, kernel breakpoint
jra _ASM_LABEL(fault) | no, user-mode fault
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.72 1999/07/08 18:05:27 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.73 1999/10/26 00:20:38 itohy Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -485,10 +485,9 @@ trap(type, code, v, frame)
* SUN 3.x traps get passed through as T_TRAP15 and are not really
* supported yet.
*
* XXX: We should never get kernel-mode T_TRACE or T_TRAP15
* XXX: We should never get kernel-mode T_TRAP15
* XXX: because locore.s now gives them special treatment.
*/
case T_TRACE: /* kernel trace trap */
case T_TRAP15: /* kernel breakpoint */
#ifdef DEBUG
printf("unexpected kernel trace trap, type = %d\n", type);
@ -498,7 +497,6 @@ trap(type, code, v, frame)
return;
case T_TRACE|T_USER: /* user trace trap */
case T_TRAP15|T_USER: /* SUN user trace trap */
#ifdef COMPAT_SUNOS
/*
* SunOS uses Trap #2 for a "CPU cache flush".
@ -510,6 +508,9 @@ trap(type, code, v, frame)
return;
}
#endif
/* FALLTHROUGH */
case T_TRACE: /* tracing a trap instruction */
case T_TRAP15|T_USER: /* SUN user trace trap */
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
break;

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.14 1999/05/06 14:16:08 kleink Exp $
# $NetBSD: genassym.cf,v 1.15 1999/10/26 00:20:38 itohy Exp $
#
# Copyright (c) 1982, 1990, 1993
@ -151,6 +151,7 @@ define PSL_IPL7 PSL_IPL7
define PSL_LOWIPL PSL_LOWIPL
define PSL_HIGHIPL PSL_HIGHIPL
define PSL_USER PSL_USER
define PSL_TS PSL_T | PSL_S
define SPL1 PSL_S | PSL_IPL1
define SPL2 PSL_S | PSL_IPL2
define SPL3 PSL_S | PSL_IPL3

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.55 1999/09/18 09:35:44 scw Exp $ */
/* $NetBSD: locore.s,v 1.56 1999/10/26 00:20:39 itohy Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -908,9 +908,17 @@ ENTRY_NOPROFILE(trace)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@-
moveq #T_TRACE,d0
| Check PSW and see what happen.
| T=0 S=0 (should not happen)
| T=1 S=0 trace trap from user mode
| T=0 S=1 trace trap on a trap instruction
| T=1 S=1 trace trap from system mode (kernel breakpoint)
movw sp@(FR_HW),d1 | get PSW
andw #PSL_S,d1 | from system mode?
jne Lkbrkpt | yes, kernel breakpoint
notw d1 | XXX no support for T0 on 680[234]0
andw #PSL_TS,d1 | from system mode (T=1, S=1)?
jeq Lkbrkpt | yes, kernel breakpoint
jra _ASM_LABEL(fault) | no, user-mode fault
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.32 1999/08/03 10:52:06 dbj Exp $ */
/* $NetBSD: trap.c,v 1.33 1999/10/26 00:20:39 itohy Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -490,10 +490,9 @@ trap(type, code, v, frame)
* SUN 3.x traps get passed through as T_TRAP15 and are not really
* supported yet.
*
* XXX: We should never get kernel-mode T_TRACE or T_TRAP15
* XXX: We should never get kernel-mode T_TRAP15
* XXX: because locore.s now gives them special treatment.
*/
case T_TRACE: /* kernel trace trap */
case T_TRAP15: /* kernel breakpoint */
#ifdef DEBUG
printf("unexpected kernel trace trap, type = %d\n", type);
@ -503,7 +502,6 @@ trap(type, code, v, frame)
return;
case T_TRACE|T_USER: /* user trace trap */
case T_TRAP15|T_USER: /* SUN user trace trap */
#ifdef COMPAT_SUNOS
/*
* SunOS uses Trap #2 for a "CPU cache flush".
@ -515,6 +513,9 @@ trap(type, code, v, frame)
return;
}
#endif
/* FALLTHROUGH */
case T_TRACE: /* tracing a trap instruction */
case T_TRAP15|T_USER: /* SUN user trace trap */
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
break;

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.8 1999/05/06 14:16:08 kleink Exp $
# $NetBSD: genassym.cf,v 1.9 1999/10/26 00:20:39 itohy Exp $
#
# Copyright (c) 1982, 1990, 1993
@ -147,6 +147,7 @@ define PSL_IPL7 PSL_IPL7
define PSL_LOWIPL PSL_LOWIPL
define PSL_HIGHIPL PSL_HIGHIPL
define PSL_USER PSL_USER
define PSL_TS PSL_T | PSL_S
define SPL1 PSL_S | PSL_IPL1
define SPL2 PSL_S | PSL_IPL2
define SPL3 PSL_S | PSL_IPL3

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.19 1999/09/17 20:04:44 thorpej Exp $ */
/* $NetBSD: locore.s,v 1.20 1999/10/26 00:20:39 itohy Exp $ */
/*
* Copyright (c) 1998 Darrin B. Jewell
@ -825,9 +825,17 @@ ENTRY_NOPROFILE(trace)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@-
moveq #T_TRACE,d0
| Check PSW and see what happen.
| T=0 S=0 (should not happen)
| T=1 S=0 trace trap from user mode
| T=0 S=1 trace trap on a trap instruction
| T=1 S=1 trace trap from system mode (kernel breakpoint)
movw sp@(FR_HW),d1 | get PSW
andw #PSL_S,d1 | from system mode?
jne Lkbrkpt | yes, kernel breakpoint
notw d1 | XXX no support for T0 on 680[234]0
andw #PSL_TS,d1 | from system mode (T=1, S=1)?
jeq Lkbrkpt | yes, kernel breakpoint
jra _ASM_LABEL(fault) | no, user-mode fault
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.16 1999/08/04 07:18:21 dbj Exp $ */
/* $NetBSD: trap.c,v 1.17 1999/10/26 00:20:39 itohy Exp $ */
/*
* This file was taken from mvme68k/mvme68k/trap.c
@ -497,10 +497,9 @@ trap(type, code, v, frame)
* SUN 3.x traps get passed through as T_TRAP15 and are not really
* supported yet.
*
* XXX: We should never get kernel-mode T_TRACE or T_TRAP15
* XXX: We should never get kernel-mode T_TRAP15
* XXX: because locore.s now gives them special treatment.
*/
case T_TRACE: /* kernel trace trap */
case T_TRAP15: /* kernel breakpoint */
#ifdef DEBUG
printf("unexpected kernel trace trap, type = %d\n", type);
@ -510,7 +509,6 @@ trap(type, code, v, frame)
return;
case T_TRACE|T_USER: /* user trace trap */
case T_TRAP15|T_USER: /* SUN user trace trap */
#ifdef COMPAT_SUNOS
/*
* SunOS uses Trap #2 for a "CPU cache flush".
@ -522,6 +520,9 @@ trap(type, code, v, frame)
return;
}
#endif
/* FALLTHROUGH */
case T_TRACE: /* tracing a trap instruction */
case T_TRAP15|T_USER: /* SUN user trace trap */
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
break;

View File

@ -1,4 +1,4 @@
/* $NetBSD: genassym.c,v 1.49 1999/07/01 20:46:42 thorpej Exp $ */
/* $NetBSD: genassym.c,v 1.50 1999/10/26 00:20:40 itohy Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
@ -129,6 +129,7 @@ struct nv assyms[] = {
def1(PSL_HIGHIPL),
def1(PSL_USER),
def1(PSL_S),
def("PSL_TS", PSL_T | PSL_S),
def1(FC_CONTROL),
def1(FC_SUPERD),
def1(FC_USERD),

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.69 1999/08/01 21:41:00 thorpej Exp $ */
/* $NetBSD: locore.s,v 1.70 1999/10/26 00:20:40 itohy Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
@ -369,8 +369,17 @@ GLOBAL(trace)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@-
moveq #T_TRACE,d0
btst #5,sp@(FR_HW) | was supervisor mode?
jne _ASM_LABEL(kbrkpt) | yes, kernel brkpt
| Check PSW and see what happen.
| T=0 S=0 (should not happen)
| T=1 S=0 trace trap from user mode
| T=0 S=1 trace trap on a trap instruction
| T=1 S=1 trace trap from system mode (kernel breakpoint)
movw sp@(FR_HW),d1 | get PSW
notw d1 | XXX no support for T0 on 680[234]0
andw #PSL_TS,d1 | from system mode (T=1, S=1)?
jeq _ASM_LABEL(kbrkpt) | yes, kernel brkpt
jra _ASM_LABEL(fault) | no, user-mode fault
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.85 1999/03/24 05:51:15 mrg Exp $ */
/* $NetBSD: trap.c,v 1.86 1999/10/26 00:20:40 itohy Exp $ */
/*
* Copyright (c) 1994 Gordon W. Ross
@ -405,16 +405,14 @@ trap(type, code, v, tf)
* SUN 3.x traps get passed through as T_TRAP15 and are not really
* supported yet.
*
* XXX: We should never get kernel-mode T_TRACE or T_TRAP15
* XXX: We should never get kernel-mode T_TRAP15
* XXX: because locore.s now gives them special treatment.
*/
case T_TRACE: /* kernel trace trap */
case T_TRAP15: /* kernel breakpoint */
tf.tf_sr &= ~PSL_T;
goto done;
case T_TRACE|T_USER: /* user trace trap */
case T_TRAP15|T_USER: /* SUN user trace trap */
#ifdef COMPAT_SUNOS
/*
* SunOS uses Trap #2 for a "CPU cache flush"
@ -428,6 +426,9 @@ trap(type, code, v, tf)
goto done;
}
#endif
/* FALLTHROUGH */
case T_TRACE: /* tracing a trap instruction */
case T_TRAP15|T_USER: /* SUN user trace trap */
tf.tf_sr &= ~PSL_T;
sig = SIGTRAP;
break;
@ -586,7 +587,7 @@ finish:
douret:
userret(p, &tf, sticks);
done:
done:;
/* XXX: Detect trap recursion? */
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: genassym.c,v 1.21 1999/07/01 20:46:42 thorpej Exp $ */
/* $NetBSD: genassym.c,v 1.22 1999/10/26 00:20:40 itohy Exp $ */
/*
* Copyright (c) 1994, 1995 Gordon W. Ross
@ -128,6 +128,7 @@ struct nv assyms[] = {
def1(PSL_HIGHIPL),
def1(PSL_USER),
def1(PSL_S),
def("PSL_TS", PSL_T | PSL_S),
def1(FC_CONTROL),
def1(FC_SUPERD),
def1(FC_USERD),

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.36 1999/08/01 21:43:04 thorpej Exp $ */
/* $NetBSD: locore.s,v 1.37 1999/10/26 00:20:40 itohy Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -388,8 +388,17 @@ GLOBAL(trace)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@-
moveq #T_TRACE,d0
btst #5,sp@(FR_HW) | was supervisor mode?
jne _ASM_LABEL(kbrkpt) | yes, kernel brkpt
| Check PSW and see what happen.
| T=0 S=0 (should not happen)
| T=1 S=0 trace trap from user mode
| T=0 S=1 trace trap on a trap instruction
| T=1 S=1 trace trap from system mode (kernel breakpoint)
movw sp@(FR_HW),d1 | get PSW
notw d1 | XXX no support for T0 on 680[234]0
andw #PSL_TS,d1 | from system mode (T=1, S=1)?
jeq _ASM_LABEL(kbrkpt) | yes, kernel brkpt
jra _ASM_LABEL(fault) | no, user-mode fault
/*

View File

@ -1,4 +1,4 @@
# $NetBSD: genassym.cf,v 1.10 1999/05/06 14:16:09 kleink Exp $
# $NetBSD: genassym.cf,v 1.11 1999/10/26 00:20:40 itohy Exp $
#
# Copyright (c) 1982, 1990, 1993
@ -147,6 +147,7 @@ define PSL_IPL7 PSL_IPL7
define PSL_LOWIPL PSL_LOWIPL
define PSL_HIGHIPL PSL_HIGHIPL
define PSL_USER PSL_USER
define PSL_TS PSL_T | PSL_S
define SPL1 PSL_S | PSL_IPL1
define SPL2 PSL_S | PSL_IPL2
define SPL3 PSL_S | PSL_IPL3

View File

@ -1,4 +1,4 @@
/* $NetBSD: locore.s,v 1.50 1999/09/23 15:24:34 minoura Exp $ */
/* $NetBSD: locore.s,v 1.51 1999/10/26 00:20:40 itohy Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -154,14 +154,14 @@ Lberr2:
movw d0,sp@ | save (ONLY LOW 16 BITS!)
jra Lismerr
#endif
_addrerr:
ENTRY_NOPROFILE(addrerr)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@- | save user registers
movl usp,a0 | save the user SP
movl a0,sp@(FR_SP) | in the savearea
lea sp@(FR_HW),a1 | grab base of HW berr frame
#if defined(M68040) || defined(M68060)
cmpl #MMU_68040,_mmutype | 68040?
cmpl #MMU_68040,_C_LABEL(mmutype) | 68040?
jne Lbenot040 | no, skip
movl a1@(8),sp@- | yes, push fault address
clrl sp@- | no SSW for address fault
@ -388,9 +388,17 @@ ENTRY_NOPROFILE(trace)
clrl sp@- | stack adjust count
moveml #0xFFFF,sp@-
moveq #T_TRACE,d0
| Check PSW and see what happen.
| T=0 S=0 (should not happen)
| T=1 S=0 trace trap from user mode
| T=0 S=1 trace trap on a trap instruction
| T=1 S=1 trace trap from system mode (kernel breakpoint)
movw sp@(FR_HW),d1 | get PSW
andw #PSL_S,d1 | from system mode?
jne Lkbrkpt | yes, kernel breakpoint
notw d1 | XXX no support for T0 on 680[234]0
andw #PSL_TS,d1 | from system mode (T=1, S=1)?
jeq Lkbrkpt | yes, kernel breakpoint
jra _ASM_LABEL(fault) | no, user-mode fault
/*
@ -1461,7 +1469,7 @@ Lmotommu7:
* and TBI*.
*/
ENTRY(DCIA)
__DCIA:
_C_LABEL(_DCIA):
#if defined(M68040) || defined(M68060)
cmpl #MMU_68040,_C_LABEL(mmutype) | 68040
jne Lmotommu8 | no, skip

View File

@ -1,4 +1,4 @@
/* $NetBSD: trap.c,v 1.33 1999/07/08 18:11:03 thorpej Exp $ */
/* $NetBSD: trap.c,v 1.34 1999/10/26 00:20:41 itohy Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@ -510,10 +510,9 @@ trap(type, code, v, frame)
* SUN 3.x traps get passed through as T_TRAP15 and are not really
* supported yet.
*
* XXX: We should never get kernel-mode T_TRACE or T_TRAP15
* XXX: We should never get kernel-mode T_TRAP15
* XXX: because locore.s now gives them special treatment.
*/
case T_TRACE: /* kernel trace trap */
case T_TRAP15: /* kernel breakpoint */
#ifdef DEBUG
printf("unexpected kernel trace trap, type = %d\n", type);
@ -523,7 +522,6 @@ trap(type, code, v, frame)
return;
case T_TRACE|T_USER: /* user trace trap */
case T_TRAP15|T_USER: /* SUN user trace trap */
#ifdef COMPAT_SUNOS
/*
* SunOS uses Trap #2 for a "CPU cache flush".
@ -535,6 +533,9 @@ trap(type, code, v, frame)
return;
}
#endif
/* FALLTHROUGH */
case T_TRACE: /* tracing a trap instruction */
case T_TRAP15|T_USER: /* SUN user trace trap */
frame.f_sr &= ~PSL_T;
i = SIGTRAP;
break;