Kernel: Print more detailed output on ISR

This commit is contained in:
Bananymous 2023-09-25 20:33:07 +03:00
parent 55d30a7cc3
commit b4e4f7a6cc
1 changed files with 27 additions and 0 deletions

View File

@ -148,6 +148,31 @@ namespace IDT
pid_t tid = Kernel::Scheduler::current_tid(); pid_t tid = Kernel::Scheduler::current_tid();
pid_t pid = tid ? Kernel::Process::current().pid() : 0; pid_t pid = tid ? Kernel::Process::current().pid() : 0;
if (tid)
{
auto start = Kernel::Thread::current().stack_base();
auto end = start + Kernel::Thread::current().stack_size();
if (interrupt_stack.rsp < start)
derrorln("Stack overflow");
if (interrupt_stack.rsp >= end)
derrorln("Stack underflow");
}
if (Kernel::PageTable::current().get_page_flags(interrupt_stack.rip & PAGE_ADDR_MASK) & Kernel::PageTable::Flags::Present)
{
uint8_t* machine_code = (uint8_t*)interrupt_stack.rip;
dwarnln("While executing: {2H}{2H}{2H}{2H}{2H}{2H}{2H}{2H}",
machine_code[0],
machine_code[1],
machine_code[2],
machine_code[3],
machine_code[4],
machine_code[5],
machine_code[6],
machine_code[7]
);
}
dwarnln( dwarnln(
"{} (error code: 0x{16H}), pid {}, tid {}\r\n" "{} (error code: 0x{16H}), pid {}, tid {}\r\n"
"Register dump\r\n" "Register dump\r\n"
@ -161,6 +186,8 @@ namespace IDT
regs->rip, regs->rflags, regs->rip, regs->rflags,
regs->cr0, regs->cr2, regs->cr3, regs->cr4 regs->cr0, regs->cr2, regs->cr3, regs->cr4
); );
if (isr == ISR::PageFault)
Kernel::PageTable::current().debug_dump();
Debug::dump_stack_trace(); Debug::dump_stack_trace();
if (tid) if (tid)