Starting Kernel Debugger
This commit is contained in:
parent
34aad175e9
commit
dd0e90c84d
29
sys/amd64/debug.c
Normal file
29
sys/amd64/debug.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <kassert.h>
|
||||||
|
#include <kconfig.h>
|
||||||
|
//#include <kdebug.h>
|
||||||
|
#include <mp.h>
|
||||||
|
|
||||||
|
#include "trap.h"
|
||||||
|
|
||||||
|
TrapFrame *frames[MAX_CPUS];
|
||||||
|
|
||||||
|
void
|
||||||
|
Debug_Breakpoint(TrapFrame *tf)
|
||||||
|
{
|
||||||
|
frames[CPU()] = tf;
|
||||||
|
|
||||||
|
// Stop all processors
|
||||||
|
|
||||||
|
Debug_Prompt();
|
||||||
|
|
||||||
|
// Resume all processors
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Debug_Registers(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
@ -101,5 +101,7 @@ void Machine_Init()
|
|||||||
|
|
||||||
PCI_Init();
|
PCI_Init();
|
||||||
IDE_Init();
|
IDE_Init();
|
||||||
|
|
||||||
|
breakpoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,11 +87,19 @@ Trap_Dump(TrapFrame *tf)
|
|||||||
void
|
void
|
||||||
trap_entry(TrapFrame *tf)
|
trap_entry(TrapFrame *tf)
|
||||||
{
|
{
|
||||||
|
// Kernel Debugger
|
||||||
|
if (tf->vector == T_BP && tf->cs == SEL_KCS)
|
||||||
|
{
|
||||||
|
Debug_Breakpoint(tf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Halt on kernel errors
|
// Halt on kernel errors
|
||||||
if (tf->vector <= T_CPU_LAST && tf->cs == SEL_KCS)
|
if (tf->vector <= T_CPU_LAST && tf->cs == SEL_KCS)
|
||||||
{
|
{
|
||||||
kprintf("Kernel Fault!\n");
|
kprintf("Kernel Fault!\n");
|
||||||
Trap_Dump(tf);
|
Trap_Dump(tf);
|
||||||
|
Debug_Breakpoint(tf);
|
||||||
while (1)
|
while (1)
|
||||||
hlt();
|
hlt();
|
||||||
}
|
}
|
||||||
|
@ -70,3 +70,21 @@ Debug_PrintHex(const char *data, size_t length, off_t off, size_t limit)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Debug_Dump(int argc, const char *argv[])
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Debug_Prompt()
|
||||||
|
{
|
||||||
|
kprintf("Entered Debugger!\n");
|
||||||
|
|
||||||
|
kprintf("> ");
|
||||||
|
// read input
|
||||||
|
|
||||||
|
// parse input
|
||||||
|
|
||||||
|
// execute command
|
||||||
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user