Allow dumping stack frames and backtraces of any processor.

This commit is contained in:
Ali Mashtizadeh 2015-11-23 14:38:07 -08:00
parent a274a78a5b
commit 16b21e1406
2 changed files with 27 additions and 5 deletions

View File

@ -48,12 +48,12 @@ Debug_ResumeCPUs()
} }
void void
Debug_HaltIPI() Debug_HaltIPI(TrapFrame *tf)
{ {
MP_SetState(CPUSTATE_HALTED); MP_SetState(CPUSTATE_HALTED);
__sync_fetch_and_add(&debugHalted, 1); __sync_fetch_and_add(&debugHalted, 1);
enable_interrupts(); frames[CPU()] = tf;
while (debugCmd == 0) { while (debugCmd == 0) {
pause(); pause();
@ -89,6 +89,15 @@ Debug_Registers(int argc, const char *argv[])
{ {
TrapFrame *tf = frames[CPU()]; 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", kprintf("Interrupt %d Error Code: %016llx\n",
tf->vector, tf->errcode); tf->vector, tf->errcode);
kprintf("cr0: %016llx cr2: %016llx\n", kprintf("cr0: %016llx cr2: %016llx\n",
@ -122,8 +131,20 @@ Debug_Backtrace(int argc, const char *argv[])
{ {
TrapFrame *tf = frames[CPU()]; TrapFrame *tf = frames[CPU()];
uint64_t *ptr; uint64_t *ptr;
uint64_t rip = tf->rip; uint64_t rip;
uint64_t rbp = tf->rbp; 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"); kprintf("%-16s %-16s\n", "IP Pointer", "Base Pointer");
while (3) { while (3) {

View File

@ -186,7 +186,8 @@ trap_entry(TrapFrame *tf)
if (tf->vector <= T_CPU_LAST) if (tf->vector <= T_CPU_LAST)
{ {
Critical_Enter(); Critical_Enter();
kprintf("Kernel Fault!\n"); kprintf("Kernel Fault: Vector %d\n", tf->vector);
Trap_Dump(tf);
Debug_Breakpoint(tf); Debug_Breakpoint(tf);
while (1) while (1)
hlt(); hlt();