Update for the KDB framework:

o  Make debugging support conditional upon KDB instead of DDB.
o  Remove implementation of Debugger().
o  Don't make setjump() and longjump() conditional upon DDB.
o  s/ddb_on_nmi/kdb_on_nmi/g
o  Call kdb_reenter() when kdb_active is non-zero. Call kdb_trap()
   otherwise.
This commit is contained in:
Marcel Moolenaar 2004-07-10 22:39:17 +00:00
parent 5704f2350a
commit 4b0cc40d57
3 changed files with 33 additions and 45 deletions

View File

@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <sys/sysproto.h>
#include <sys/signalvar.h>
#include <sys/imgact.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/linker.h>
@ -139,6 +140,10 @@ static void get_fpcontext(struct thread *td, mcontext_t *mcp);
static int set_fpcontext(struct thread *td, const mcontext_t *mcp);
SYSINIT(cpu, SI_SUB_CPU, SI_ORDER_FIRST, cpu_startup, NULL)
#ifdef DDB
extern vm_offset_t ksym_start, ksym_end;
#endif
int _udatasel, _ucodesel, _ucode32sel;
int cold = 1;
@ -159,10 +164,6 @@ struct pcpu __pcpu[MAXCPU];
struct mtx icu_lock;
#ifdef DDB
void *ksym_start, *ksym_end;
#endif
static void
cpu_startup(dummy)
void *dummy;
@ -1113,8 +1114,8 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
boothowto = MD_FETCH(kmdp, MODINFOMD_HOWTO, int);
kern_envp = MD_FETCH(kmdp, MODINFOMD_ENVP, char *) + KERNBASE;
#ifdef DDB
ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, void *);
ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, void *);
ksym_start = MD_FETCH(kmdp, MODINFOMD_SSYM, uintptr_t);
ksym_end = MD_FETCH(kmdp, MODINFOMD_ESYM, uintptr_t);
#endif
/* Init basic tunables, hz etc */
@ -1195,10 +1196,11 @@ hammer_time(u_int64_t modulep, u_int64_t physfree)
atpic_startup();
#endif
#ifdef DDB
kdb_init();
#ifdef KDB
if (boothowto & RB_KDB)
Debugger("Boot flags requested debugger");
kdb_enter("Boot flags requested debugger");
#endif
identify_cpu(); /* Final stage of CPU initialization */
@ -1775,20 +1777,12 @@ user_dbreg_trap(void)
return 0;
}
#ifndef DDB
void
Debugger(const char *msg)
{
printf("Debugger(\"%s\") called.\n", msg);
}
#endif /* no DDB */
#ifdef DDB
#ifdef KDB
/*
* Provide inb() and outb() as functions. They are normally only
* available as macros calling inlined functions, thus cannot be
* called inside DDB.
* called from the debugger.
*
* The actual code is stolen from <machine/cpufunc.h>, and de-inlined.
*/
@ -1827,4 +1821,4 @@ outb(u_int port, u_char data)
__asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port));
}
#endif /* DDB */
#endif /* KDB */

View File

@ -621,7 +621,6 @@ ENTRY(lgdt)
MEXITCOUNT
lretq
#ifdef DDB
/*****************************************************************************/
/* setjump, longjump */
/*****************************************************************************/
@ -652,7 +651,6 @@ ENTRY(longjmp)
xorl %eax,%eax /* return(1); */
incl %eax
ret
#endif
/*
* Support for BB-profiling (gcc -a). The kernbb program will extract

View File

@ -46,7 +46,6 @@ __FBSDID("$FreeBSD$");
#include "opt_clock.h"
#include "opt_cpu.h"
#include "opt_ddb.h"
#include "opt_isa.h"
#include "opt_ktrace.h"
@ -56,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <sys/proc.h>
#include <sys/pioctl.h>
#include <sys/ptrace.h>
#include <sys/kdb.h>
#include <sys/kernel.h>
#include <sys/ktr.h>
#include <sys/lock.h>
@ -88,8 +88,6 @@ __FBSDID("$FreeBSD$");
#endif
#include <machine/tss.h>
#include <ddb/ddb.h>
extern void trap(struct trapframe frame);
extern void syscall(struct trapframe frame);
@ -130,10 +128,10 @@ static char *trap_msg[] = {
"machine check trap", /* 28 T_MCHK */
};
#ifdef DDB
static int ddb_on_nmi = 1;
SYSCTL_INT(_machdep, OID_AUTO, ddb_on_nmi, CTLFLAG_RW,
&ddb_on_nmi, 0, "Go to DDB on NMI");
#ifdef KDB
static int kdb_on_nmi = 1;
SYSCTL_INT(_machdep, OID_AUTO, kdb_on_nmi, CTLFLAG_RW,
&kdb_on_nmi, 0, "Go to KDB on NMI");
#endif
static int panic_on_nmi = 1;
SYSCTL_INT(_machdep, OID_AUTO, panic_on_nmi, CTLFLAG_RW,
@ -167,11 +165,9 @@ trap(frame)
atomic_add_int(&cnt.v_trap, 1);
type = frame.tf_trapno;
#ifdef DDB
if (db_active) {
vm_offset_t eva;
eva = (type == T_PAGEFLT ? frame.tf_addr : 0);
trap_fatal(&frame, eva);
#ifdef KDB
if (kdb_active) {
kdb_reenter();
goto out;
}
#endif
@ -283,16 +279,16 @@ trap(frame)
/* machine/parity/power fail/"kitchen sink" faults */
/* XXX Giant */
if (isa_nmi(code) == 0) {
#ifdef DDB
#ifdef KDB
/*
* NMI can be hooked up to a pushbutton
* for debugging.
*/
if (ddb_on_nmi) {
if (kdb_on_nmi) {
printf ("NMI ... going to debugger\n");
kdb_trap (type, 0, &frame);
}
#endif /* DDB */
#endif /* KDB */
goto userout;
} else if (panic_on_nmi)
panic("NMI indicates hardware failure");
@ -419,12 +415,12 @@ trap(frame)
*/
case T_BPTFLT:
/*
* If DDB is enabled, let it handle the debugger trap.
* If KDB is enabled, let it handle the debugger trap.
* Otherwise, debugger traps "can't happen".
*/
#ifdef DDB
#ifdef KDB
/* XXX Giant */
if (kdb_trap (type, 0, &frame))
if (kdb_trap(type, 0, &frame))
goto out;
#endif
break;
@ -434,16 +430,16 @@ trap(frame)
/* XXX Giant */
/* machine/parity/power fail/"kitchen sink" faults */
if (isa_nmi(code) == 0) {
#ifdef DDB
#ifdef KDB
/*
* NMI can be hooked up to a pushbutton
* for debugging.
*/
if (ddb_on_nmi) {
if (kdb_on_nmi) {
printf ("NMI ... going to debugger\n");
kdb_trap (type, 0, &frame);
kdb_trap(type, 0, &frame);
}
#endif /* DDB */
#endif /* KDB */
goto out;
} else if (panic_on_nmi == 0)
goto out;
@ -629,8 +625,8 @@ trap_fatal(frame, eva)
printf("Idle\n");
}
#ifdef DDB
if ((debugger_on_panic || db_active) && kdb_trap(type, 0, frame))
#ifdef KDB
if (kdb_trap(type, 0, frame))
return;
#endif
printf("trap number = %d\n", type);