diff options
author | Itamar <itamar8910@gmail.com> | 2020-04-03 14:50:17 +0300 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-04-13 00:53:22 +0200 |
commit | 77f671b462be1c3f5469a348337326235da6d5a0 (patch) | |
tree | 4ed44b9ca23ef8dd6a5284e84b7405f8d454783a /Kernel/Arch | |
parent | c112f533578cda48396308ee34314917d97a5614 (diff) | |
download | serenity-77f671b462be1c3f5469a348337326235da6d5a0.zip |
CPU: Handle breakpoint trap
Also, start working on the debugger app.
Diffstat (limited to 'Kernel/Arch')
-rw-r--r-- | Kernel/Arch/i386/CPU.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/Kernel/Arch/i386/CPU.cpp b/Kernel/Arch/i386/CPU.cpp index fca0685c91..460cb47243 100644 --- a/Kernel/Arch/i386/CPU.cpp +++ b/Kernel/Arch/i386/CPU.cpp @@ -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); |