summaryrefslogtreecommitdiff
path: root/src/kernel/task
diff options
context:
space:
mode:
authorAlex AUVOLAT <alexis211@gmail.com>2013-06-09 14:35:40 +0200
committerAlex AUVOLAT <alexis211@gmail.com>2013-06-09 14:35:40 +0200
commit9c74cb8c5bb5661d7f71f43b88816e70cc9fc022 (patch)
tree77a893ff826dcb14e9b8768c23e4970033e934ea /src/kernel/task
parent4d65fcb9a8b6c7c6fd5a3390c46a96d11b6a80d4 (diff)
downloadTCE-9c74cb8c5bb5661d7f71f43b88816e70cc9fc022.tar.gz
TCE-9c74cb8c5bb5661d7f71f43b88816e70cc9fc022.zip
Many bug corrections.
Diffstat (limited to 'src/kernel/task')
-rw-r--r--src/kernel/task/idt.cpp2
-rw-r--r--src/kernel/task/task.cpp32
2 files changed, 25 insertions, 9 deletions
diff --git a/src/kernel/task/idt.cpp b/src/kernel/task/idt.cpp
index e56a51b..94a31b7 100644
--- a/src/kernel/task/idt.cpp
+++ b/src/kernel/task/idt.cpp
@@ -78,7 +78,7 @@ static struct irq_waiter {
/* Called in idt_.asm when an exception fires (interrupt 0 to 31).
Tries to handle the exception, panics if fails. */
extern "C" void idt_isrHandler(registers regs) {
- if ((regs.int_no == 14 && paging_fault(&regs) != 0) || regs.int_no != 14) {
+ if (regs.int_no != 14 || paging_fault(&regs)) {
if (tasking_handleException(&regs) == 0) {
*ke_vt << "\nREALLY BAD THIS TIME\t\tUnhandled exception\t#";
*ke_vt << regs.int_no;
diff --git a/src/kernel/task/task.cpp b/src/kernel/task/task.cpp
index 91f802d..2af0441 100644
--- a/src/kernel/task/task.cpp
+++ b/src/kernel/task/task.cpp
@@ -104,24 +104,40 @@ 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
- NL; WHERE; ke_vt->writeStr("Exception: `");
+
+ vt->writeStr("\n");
+ vt->writeStr("[ke:"); vt->writeStr(__FILE__); vt->writeStr(":");
+ vt->writeDec(__LINE__); vt->writeStr("] ");
+ vt->writeStr("Exception: ");
+
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"};
- *ke_vt << exception_messages[regs->int_no];
- *ke_vt << "'\teip:" << regs->eip;
+ *vt << exception_messages[regs->int_no];;
+ *vt << "\n\tPID: " << (int)current_thread->process->pid;
+ *vt << "\n\teip: " << regs->eip;
+
if (regs->eip >= K_HIGHHALF_ADDR) {
- *ke_vt << "\nException in kernel. Stack trace:\n";
- stack_trace(regs->ebp);
+ *vt << "\n\tException in kernel.";
+ stack_trace(regs->ebp); // useless
+ }
+ *vt << "\n\tTrace:";
+ 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];
+ stack = (uint32_t*)stack[0];
}
- *ke_vt << "\n (PID " << current_thread->process->pid << ") ";
+
if (regs->int_no == 14) {
- *ke_vt << ">>> Process exiting.\n";
+ *vt << "\n\tKilling process.\n";
thread_exit_stackJmp(EX_PAGEFAULT);
} else {
- *ke_vt << ">>> Thread exiting.\n";
+ *vt << "\n\tKilling thread.\n";
thread_exit_stackJmp(EX_EXCEPTION);
}
PANIC("This should never have happened. Please report this.");