From 15bea7153a55f149c3c3c97ff78ab0f5740bfbd2 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 19 Jun 2019 18:50:02 +0200 Subject: [PATCH] Kernel: Symbolicate the crash address too, not just the call stack. Also print it in shiny red to make it extra easy to spot. :^) Fixes #244. --- Kernel/Arch/i386/CPU.cpp | 12 +++++++----- Kernel/Process.cpp | 4 +++- Kernel/Process.h | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp index a1a7ec5177c..d1f5beb717d 100644 --- a/Kernel/Arch/i386/CPU.cpp +++ b/Kernel/Arch/i386/CPU.cpp @@ -171,14 +171,14 @@ void exception_6_handler(RegisterDump& regs) current->pid()); dump(regs); - dump_backtrace(); if (current->process().is_ring0()) { kprintf("Oh shit, we've crashed in ring 0 :(\n"); + dump_backtrace(); hang(); } - current->process().crash(SIGILL); + current->process().crash(SIGILL, regs.eip); } // 7: FPU not available exception @@ -224,10 +224,11 @@ void exception_0_handler(RegisterDump& regs) if (current->process().is_ring0()) { kprintf("Oh shit, we've crashed in ring 0 :(\n"); + dump_backtrace(); hang(); } - current->process().crash(SIGFPE); + current->process().crash(SIGFPE, regs.eip); } // 13: General Protection Fault @@ -240,10 +241,11 @@ void exception_13_handler(RegisterDumpWithExceptionCode& regs) if (current->process().is_ring0()) { kprintf("Oh shit, we've crashed in ring 0 :(\n"); + dump_backtrace(); hang(); } - current->process().crash(); + current->process().crash(SIGSEGV, regs.eip); } // 14: Page Fault @@ -285,7 +287,7 @@ void exception_14_handler(RegisterDumpWithExceptionCode& regs) regs.exception_code & 2 ? "write" : "read", faultAddress); dump(regs); - current->process().crash(); + current->process().crash(SIGSEGV, regs.eip); } else if (response == PageFaultResponse::Continue) { #ifdef PAGE_FAULT_DEBUG dbgprintf("Continuing after resolved page fault\n"); diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index f388e42251e..7af8e974263 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -740,11 +740,13 @@ void Process::sys$sigreturn() ASSERT_NOT_REACHED(); } -void Process::crash(int signal) +void Process::crash(int signal, dword eip) { ASSERT_INTERRUPTS_DISABLED(); ASSERT(!is_dead()); + if (m_elf_loader && ksyms_ready) + dbgprintf("\033[31;1m%p %s\033[0m\n", eip, m_elf_loader->symbolicate(eip).characters()); dump_backtrace(); m_termination_signal = signal; diff --git a/Kernel/Process.h b/Kernel/Process.h index 90b685d5828..46f5b895a11 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -204,7 +204,7 @@ public: static void initialize(); - [[noreturn]] void crash(int signal = SIGSEGV); + [[noreturn]] void crash(int signal, dword eip); [[nodiscard]] static int reap(Process&); const TTY* tty() const { return m_tty; }