Starting Kernel Debugger

This commit is contained in:
Ali Mashtizadeh 2014-07-13 13:07:19 -07:00
parent 34aad175e9
commit dd0e90c84d
4 changed files with 57 additions and 0 deletions

29
sys/amd64/debug.c Normal file
View 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[])
{
}

View File

@ -101,5 +101,7 @@ void Machine_Init()
PCI_Init();
IDE_Init();
breakpoint();
}

View File

@ -87,11 +87,19 @@ Trap_Dump(TrapFrame *tf)
void
trap_entry(TrapFrame *tf)
{
// Kernel Debugger
if (tf->vector == T_BP && tf->cs == SEL_KCS)
{
Debug_Breakpoint(tf);
return;
}
// Halt on kernel errors
if (tf->vector <= T_CPU_LAST && tf->cs == SEL_KCS)
{
kprintf("Kernel Fault!\n");
Trap_Dump(tf);
Debug_Breakpoint(tf);
while (1)
hlt();
}

View File

@ -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
}