void print_trapframe(struct hw_trapframe *hw_tf) { char buf[1024]; int len = format_trapframe(hw_tf, buf, sizeof(buf)); cputbuf(buf,len); }
static void unhandled_trap(struct hw_trapframe *state, const char* name) { static spinlock_t screwup_lock = SPINLOCK_INITIALIZER; spin_lock(&screwup_lock); if(in_kernel(state)) { print_trapframe(state); panic("Unhandled trap in kernel!\nTrap type: %s", name); } else { char tf_buf[1024]; format_trapframe(state, tf_buf, sizeof(tf_buf)); warn("Unhandled trap in user!\nTrap type: %s\n%s", name, tf_buf); backtrace(); spin_unlock(&screwup_lock); assert(current); enable_irq(); proc_destroy(current); } }