Make stack traces on exceptions possible.

This commit is contained in:
Ben Gras 2006-06-29 13:35:27 +00:00
parent bfca7d68ba
commit f1222a09a6
3 changed files with 39 additions and 0 deletions

View file

@ -20,6 +20,7 @@
* are disabled.
*/
#define DEBUG_ENABLE_IPC_WARNINGS 0
#define DEBUG_STACKTRACE 1
/* It's interesting to measure the time spent withing locked regions, because
* this is the time that the system is deaf to interrupts.

View file

@ -65,6 +65,10 @@ unsigned vec_nr;
saved_proc->p_reg.cs, saved_proc->p_reg.pc,
saved_proc->p_reg.ss, saved_proc->p_reg.sp);
kprintf("edi = 0x%x\n", saved_proc->p_reg.di);
#if DEBUG_STACKTRACE
stacktrace(saved_proc);
#endif
}
#endif
@ -85,3 +89,34 @@ unsigned vec_nr;
panic("exception in a kernel task", NO_NUM);
}
#if DEBUG_STACKTRACE
/*===========================================================================*
* stacktrace *
*===========================================================================*/
PUBLIC void stacktrace(proc)
struct proc *proc;
{
reg_t bp, v_bp, v_pc, v_hbp;
v_bp = proc->p_reg.fp;
kprintf("stacktrace: ");
while(v_bp) {
phys_bytes p;
if(!(p = umap_local(proc, D, v_bp, sizeof(v_bp)))) {
kprintf("(bad bp %lx)", v_bp);
break;
}
phys_copy(p+sizeof(v_pc), vir2phys(&v_pc), sizeof(v_pc));
phys_copy(p, vir2phys(&v_hbp), sizeof(v_hbp));
kprintf("0x%lx ", (unsigned long) v_pc);
if(v_hbp != 0 && v_hbp <= v_bp) {
kprintf("(bad hbp %lx)", v_hbp);
break;
}
v_bp = v_hbp;
}
kprintf("\n");
}
#endif

View file

@ -74,6 +74,9 @@ _PROTOTYPE( int newmap, (struct proc *rp, struct mem_map *map_ptr) );
/* exception.c */
_PROTOTYPE( void exception, (unsigned vec_nr) );
#if DEBUG_STACK_TRACE
_PROTOTYPE( void stacktrace, (struct proc *) );
#endif
/* i8259.c */
_PROTOTYPE( void intr_init, (int mine) );