diff --git a/sys/amd64/debug.c b/sys/amd64/debug.c index 47f347a..6f3aec6 100644 --- a/sys/amd64/debug.c +++ b/sys/amd64/debug.c @@ -48,12 +48,12 @@ Debug_ResumeCPUs() } void -Debug_HaltIPI() +Debug_HaltIPI(TrapFrame *tf) { MP_SetState(CPUSTATE_HALTED); __sync_fetch_and_add(&debugHalted, 1); - enable_interrupts(); + frames[CPU()] = tf; while (debugCmd == 0) { pause(); @@ -89,6 +89,15 @@ Debug_Registers(int argc, const char *argv[]) { TrapFrame *tf = frames[CPU()]; + if (argc == 2) { + int cpuNo = Debug_StrToInt(argv[1]); + if (cpuNo >= MAX_CPUS) { + kprintf("Invalid CPU number\n"); + return; + } + tf = frames[cpuNo]; + } + kprintf("Interrupt %d Error Code: %016llx\n", tf->vector, tf->errcode); kprintf("cr0: %016llx cr2: %016llx\n", @@ -122,8 +131,20 @@ Debug_Backtrace(int argc, const char *argv[]) { TrapFrame *tf = frames[CPU()]; uint64_t *ptr; - uint64_t rip = tf->rip; - uint64_t rbp = tf->rbp; + uint64_t rip; + uint64_t rbp; + + if (argc == 2) { + int cpuNo = Debug_StrToInt(argv[1]); + if (cpuNo >= MAX_CPUS) { + kprintf("Invalid CPU number\n"); + return; + } + tf = frames[cpuNo]; + } + + rip = tf->rip; + rbp = tf->rbp; kprintf("%-16s %-16s\n", "IP Pointer", "Base Pointer"); while (3) { diff --git a/sys/amd64/trap.c b/sys/amd64/trap.c index e40bcc3..a273649 100644 --- a/sys/amd64/trap.c +++ b/sys/amd64/trap.c @@ -186,7 +186,8 @@ trap_entry(TrapFrame *tf) if (tf->vector <= T_CPU_LAST) { Critical_Enter(); - kprintf("Kernel Fault!\n"); + kprintf("Kernel Fault: Vector %d\n", tf->vector); + Trap_Dump(tf); Debug_Breakpoint(tf); while (1) hlt();