diff options
author | Ian Moffett <ian@osmora.org> | 2024-02-20 00:31:44 -0500 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2024-02-20 00:31:44 -0500 |
commit | 6f2e70067b9fd62818117eb2969169d549179ee0 (patch) | |
tree | 5c39e6e19906e70f63928b334a1e97f98cf2321e /sys/arch/amd64/amd64 | |
parent | b9ac16de634e04b92d5a050381a363ed1d4aeb52 (diff) |
kernel/amd64: trap: Dump regs upon exception
Signed-off-by: Ian Moffett <ian@osmora.org>
Diffstat (limited to 'sys/arch/amd64/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/trap.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 85d1058..703b6cf 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -63,6 +63,28 @@ trap_print(struct trapframe *tf) kprintf(" in %s mode **\n", mode); } +static void +regdump(struct trapframe *tf) +{ + uintptr_t cr3, cr2; + + __ASMV("mov %%cr2, %0\n" + "mov %%cr3, %1\n" + : "=r" (cr2), "=r" (cr3) + : + : "memory" + ); + + kprintf("RAX=%p RCX=%p RDX=%p\n" + "RBX=%p RSI=%p RDI=%p\n" + "RFL=%p CR2=%p CR3=%p\n" + "RBP=%p RSP=%p RIP=%p\n", + tf->rax, tf->rcx, tf->rdx, + tf->rbx, tf->rsi, tf->rdi, + tf->rflags, cr2, cr3, + tf->rbp, tf->rsp, tf->rip); +} + /* * Handles traps. */ @@ -80,5 +102,6 @@ trap_handler(struct trapframe *tf) panic("Caught NMI; bailing out\n"); } - panic("Caught pre-sched exception @0x%x\n", tf->rip); + regdump(tf); + panic("Caught pre-sched exception\n"); } |