1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:57:44 +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);

View file

@ -36,6 +36,7 @@
#include <Kernel/Forward.h>
#include <Kernel/KResult.h>
#include <Kernel/Scheduler.h>
#include <Kernel/ThreadTracer.h>
#include <Kernel/UnixTypes.h>
#include <LibC/fd_set.h>

View file

@ -25,6 +25,7 @@
*/
#include <AK/Memory.h>
#include <AK/kmalloc.h>
#include <Kernel/ThreadTracer.h>
namespace Kernel {

View file

@ -26,11 +26,8 @@
#pragma once
#include <AK/CircularDeque.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/Optional.h>
#include <AK/RefCounted.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/UnixTypes.h>
#include <LibC/sys/arch/i386/regs.h>

View file

@ -143,8 +143,10 @@ cp ../Applications/DisplayProperties/DisplayProperties mnt/bin/DisplayProperties
cp ../Applications/Welcome/Welcome mnt/bin/Welcome
cp ../Applications/Help/Help mnt/bin/Help
cp ../Applications/Browser/Browser mnt/bin/Browser
cp ../Applications/Debugger/Debugger mnt/bin/sdb
cp ../Games/Solitaire/Solitaire mnt/bin/Solitaire
cp ../Demos/HelloWorld/HelloWorld mnt/bin/HelloWorld
cp ../Demos/Debugee/Debugee mnt/bin/Debugee
cp ../Demos/WidgetGallery/WidgetGallery mnt/bin/WidgetGallery
cp ../Demos/Fire/Fire mnt/bin/Fire
cp ../Demos/DynamicLink/LinkDemo/LinkDemo mnt/bin/LinkDemo