lab1 monitor mon_backtrace

This commit is contained in:
D_B
2022-03-22 18:07:55 +08:00
committed by GitHub
parent aaa5cd9aa5
commit be5fded5d4

View File

@@ -59,6 +59,24 @@ int
mon_backtrace(int argc, char **argv, struct Trapframe *tf)
{
// Your code here.
int
mon_backtrace(int argc, char **argv, struct Trapframe *tf)
{
uint32_t *ebp;
ebp = (uint32_t *)read_ebp();
cprintf("Stack backtrace:\n");
while(ebp!=0){
cprintf(" ebp %08x",ebp);
cprintf(" eip %08x args",*(ebp+1));
cprintf(" args");
cprintf(" %08x", *(ebp+2));
cprintf(" %08x", *(ebp+3));
cprintf(" %08x", *(ebp+4));
cprintf(" %08x", *(ebp+5));
cprintf(" %08x\n", *(ebp+6));
}
return 0;
}