1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:37:45 +00:00

CPU: Handle breakpoint trap

Also, start working on the debugger app.
This commit is contained in:
Itamar 2020-04-03 14:50:17 +03:00 committed by Andreas Kling
parent c112f53357
commit 77f671b462
10 changed files with 184 additions and 23 deletions

View file

@ -297,6 +297,21 @@ void page_fault_handler(RegisterState regs)
}
}
EH_ENTRY_NO_CODE(3, breakpoint);
void breakpoint_handler(RegisterState regs)
{
clac();
if (!Process::current || Process::current->is_ring0()) {
klog() << "Breakpoint Trap in Ring0";
hang();
return;
}
if (Thread::current->tracer()) {
Thread::current->tracer()->set_regs(regs);
}
Thread::current->send_urgent_signal_to_self(SIGTRAP);
}
#define EH(i, msg) \
static void _exception##i() \
{ \
@ -316,7 +331,6 @@ void page_fault_handler(RegisterState regs)
EH(1, "Debug exception")
EH(2, "Unknown error")
EH(3, "Breakpoint")
EH(4, "Overflow")
EH(5, "Bounds check")
EH(8, "Double fault")
@ -486,7 +500,7 @@ void idt_init()
register_interrupt_handler(0x00, divide_error_asm_entry);
register_interrupt_handler(0x01, _exception1);
register_interrupt_handler(0x02, _exception2);
register_interrupt_handler(0x03, _exception3);
register_user_callable_interrupt_handler(0x03, breakpoint_asm_entry);
register_interrupt_handler(0x04, _exception4);
register_interrupt_handler(0x05, _exception5);
register_interrupt_handler(0x06, illegal_instruction_asm_entry);