summaryrefslogtreecommitdiff
path: root/src/kernel/task/task.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/kernel/task/task.cpp')
-rw-r--r--src/kernel/task/task.cpp26
1 files changed, 11 insertions, 15 deletions
diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp
index 2af0441..2ad5447 100644
--- a/src/kernel/task/task.cpp
+++ b/src/kernel/task/task.cpp
@@ -104,40 +104,36 @@ void schedule() {
/* Called when an exception happens. Provides a stack trace if it was in kernel land.
Ends the thread for most exceptions, ends the whole process for page faults. */
uint32_t tasking_handleException(registers *regs) {
- node *n = current_thread->process->fd.at(0);
- vt *vt = (n && n->as_vt() ? n->as_vt() : ke_vt);
-
if (current_thread == 0) return 0; //No tasking yet
- vt->writeStr("\n");
- vt->writeStr("[ke:"); vt->writeStr(__FILE__); vt->writeStr(":");
- vt->writeDec(__LINE__); vt->writeStr("] ");
- vt->writeStr("Exception: ");
+ dbg_printf("[ke:%s:%d] Exception: ", __FILE__, __LINE__);
char *exception_messages[] = {"Division By Zero","Debug","Non Maskable Interrupt","Breakpoint",
"Into Detected Overflow","Out of Bounds","Invalid Opcode","No Coprocessor", "Double Fault",
"Coprocessor Segment Overrun","Bad TSS","Segment Not Present","Stack Fault","General Protection Fault",
"Page Fault","Unknown Interrupt","Coprocessor Fault","Alignment Check","Machine Check"};
- *vt << exception_messages[regs->int_no];;
- *vt << "\n\tPID: " << (int)current_thread->process->pid;
- *vt << "\n\teip: " << regs->eip;
+
+ dbg_printf("%s\n", exception_messages[regs->int_no]);
+ dbg_printf("\tPID: %d\n", current_thread->process->pid);
+ dbg_printf("\teip: %p\n", regs->eip);
+
if (regs->eip >= K_HIGHHALF_ADDR) {
- *vt << "\n\tException in kernel.";
+ dbg_printf("\tException in kernel\n");
stack_trace(regs->ebp); // useless
}
- *vt << "\n\tTrace:";
+ dbg_printf("\tTrace:\n");
uint32_t *stack = (uint32_t*)regs->ebp, i;
for (i = 0; i < 7 && (size_t)stack < (regs->ebp + 0x4000) && (size_t) stack >= regs->ebp; i++) {
- *vt << "\n\t " << (size_t)stack << " next: " << stack[0] << " ret: " << stack[1];
+ dbg_printf("\t%p\tnext: %p\tret: %p\n", stack, stack[0], stack[1]);
stack = (uint32_t*)stack[0];
}
if (regs->int_no == 14) {
- *vt << "\n\tKilling process.\n";
+ dbg_printf("\tKilling process.\n");
thread_exit_stackJmp(EX_PAGEFAULT);
} else {
- *vt << "\n\tKilling thread.\n";
+ dbg_printf("\tKilling thread.\n");
thread_exit_stackJmp(EX_EXCEPTION);
}
PANIC("This should never have happened. Please report this.");