Kernel: Symbolicate kernel EIP on process crash

Process::crash() was assuming that EIP was always inside the ELF binary
of the program, but it could also be in the kernel.
This commit is contained in:
Andreas Kling 2020-01-18 14:38:39 +01:00
parent 9c9fe62a4b
commit 4e6fe3c14b
Notes: sideshowbarker 2024-07-19 09:58:58 +09:00

View File

@ -30,6 +30,7 @@
#include <AK/StringBuilder.h>
#include <AK/Time.h>
#include <AK/Types.h>
#include <AK/Demangle.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/Arch/i386/PIT.h>
#include <Kernel/Console.h>
@ -1420,8 +1421,14 @@ void Process::crash(int signal, u32 eip)
ASSERT(!is_dead());
ASSERT(&current->process() == this);
if (m_elf_loader && ksyms_ready)
if (eip >= 0xc0000000 && ksyms_ready) {
auto* ksym = ksymbolicate(eip);
dbgprintf("\033[31;1m%p %s +%d\033[0m\n", eip, ksym ? demangle(ksym->name).characters() : "(k?)", ksym ? eip - ksym->address : 0);
} else if (m_elf_loader) {
dbgprintf("\033[31;1m%p %s\033[0m\n", eip, m_elf_loader->symbolicate(eip).characters());
} else {
dbgprintf("\033[31;1m%p (?)\033[0m\n", eip);
}
dump_backtrace();
m_termination_signal = signal;