diff options
author | marcel <marcel@FreeBSD.org> | 2004-07-10 23:04:42 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2004-07-10 23:04:42 +0000 |
commit | da93585cf49a1b1dc6045f5b1e43ab9a1453a89f (patch) | |
tree | c77ca76c34feeac7c2bc332ca23d6d830830a78b /sys/pc98 | |
parent | bf7aa00f9c2cc74a136ba8493fdc0f1e148f1e87 (diff) | |
download | FreeBSD-src-da93585cf49a1b1dc6045f5b1e43ab9a1453a89f.zip FreeBSD-src-da93585cf49a1b1dc6045f5b1e43ab9a1453a89f.tar.gz |
MFi386: Update for the KDB framework:
o Implement makectx().
o Call kdb_enter() instead of Debugger().
o Remove implementation of Debugger().
Diffstat (limited to 'sys/pc98')
-rw-r--r-- | sys/pc98/i386/machdep.c | 46 | ||||
-rw-r--r-- | sys/pc98/pc98/machdep.c | 46 |
2 files changed, 68 insertions, 24 deletions
diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c index 1278261..67e5f71 100644 --- a/sys/pc98/i386/machdep.c +++ b/sys/pc98/i386/machdep.c @@ -56,6 +56,7 @@ #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> @@ -166,6 +167,10 @@ int need_pre_dma_flush; /* If 1, use wbinvd befor DMA transfer. */ int need_post_dma_flush; /* If 1, use invd after DMA transfer. */ #endif +#ifdef DDB +extern vm_offset_t ksym_start, ksym_end; +#endif + int _udatasel, _ucodesel; u_int basemem; @@ -2146,9 +2151,15 @@ init386(first) #endif #ifdef DDB + ksym_start = bootinfo.bi_symtab; + ksym_end = bootinfo.bi_esymtab; +#endif + kdb_init(); + +#ifdef KDB if (boothowto & RB_KDB) - Debugger("Boot flags requested debugger"); + kdb_enter("Boot flags requested debugger"); #endif finishidentcpu(); /* Final stage of CPU initialization */ @@ -2263,6 +2274,25 @@ f00f_hack(void *unused) } #endif /* defined(I586_CPU) && !NO_F00F_HACK */ +/* + * Construct a PCB from a trapframe. This is called from kdb_trap() where + * we want to start a backtrace from the function that caused us to enter + * the debugger. We have the context in the trapframe, but base the trace + * on the PCB. The PCB doesn't have to be perfect, as long as it contains + * enough for a backtrace. + */ +void +makectx(struct trapframe *tf, struct pcb *pcb) +{ + + pcb->pcb_edi = tf->tf_edi; + pcb->pcb_esi = tf->tf_esi; + pcb->pcb_ebp = tf->tf_ebp; + pcb->pcb_ebx = tf->tf_ebx; + pcb->pcb_eip = tf->tf_eip; + pcb->pcb_esp = (ISPL(tf->tf_cs)) ? tf->tf_esp : (int)(tf + 1) - 8; +} + int ptrace_set_pc(struct thread *td, u_long addr) { @@ -2782,20 +2812,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. */ @@ -2834,4 +2856,4 @@ outb(u_int port, u_char data) __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port)); } -#endif /* DDB */ +#endif /* KDB */ diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index 1278261..67e5f71 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -56,6 +56,7 @@ #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> @@ -166,6 +167,10 @@ int need_pre_dma_flush; /* If 1, use wbinvd befor DMA transfer. */ int need_post_dma_flush; /* If 1, use invd after DMA transfer. */ #endif +#ifdef DDB +extern vm_offset_t ksym_start, ksym_end; +#endif + int _udatasel, _ucodesel; u_int basemem; @@ -2146,9 +2151,15 @@ init386(first) #endif #ifdef DDB + ksym_start = bootinfo.bi_symtab; + ksym_end = bootinfo.bi_esymtab; +#endif + kdb_init(); + +#ifdef KDB if (boothowto & RB_KDB) - Debugger("Boot flags requested debugger"); + kdb_enter("Boot flags requested debugger"); #endif finishidentcpu(); /* Final stage of CPU initialization */ @@ -2263,6 +2274,25 @@ f00f_hack(void *unused) } #endif /* defined(I586_CPU) && !NO_F00F_HACK */ +/* + * Construct a PCB from a trapframe. This is called from kdb_trap() where + * we want to start a backtrace from the function that caused us to enter + * the debugger. We have the context in the trapframe, but base the trace + * on the PCB. The PCB doesn't have to be perfect, as long as it contains + * enough for a backtrace. + */ +void +makectx(struct trapframe *tf, struct pcb *pcb) +{ + + pcb->pcb_edi = tf->tf_edi; + pcb->pcb_esi = tf->tf_esi; + pcb->pcb_ebp = tf->tf_ebp; + pcb->pcb_ebx = tf->tf_ebx; + pcb->pcb_eip = tf->tf_eip; + pcb->pcb_esp = (ISPL(tf->tf_cs)) ? tf->tf_esp : (int)(tf + 1) - 8; +} + int ptrace_set_pc(struct thread *td, u_long addr) { @@ -2782,20 +2812,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. */ @@ -2834,4 +2856,4 @@ outb(u_int port, u_char data) __asm __volatile("outb %0,%%dx" : : "a" (al), "d" (port)); } -#endif /* DDB */ +#endif /* KDB */ |