提交 4e81358f 创建 作者: Nickolai Zeldovich's avatar Nickolai Zeldovich

^T to print out stack traces

上级 227f0486
......@@ -239,6 +239,10 @@ consoleintr(int (*getc)(void))
for (u32 i = 0; i < NCPU; i++)
cpus[i].timer_printpc = 1;
break;
case C('T'): // Print user-space PCs and stack traces.
for (u32 i = 0; i < NCPU; i++)
cpus[i].timer_printpc = 2;
break;
case C('U'): // Kill line.
while(input.e != input.w &&
input.buf[(input.e-1) % INPUT_BUF] != '\n'){
......
......@@ -76,6 +76,12 @@ trap(struct trapframe *tf)
mycpu()->id,
myproc() ? myproc()->name : "(none)",
tf->rip, tf->rsp, tf->cs);
if (mycpu()->timer_printpc == 2 && tf->rbp > KBASE) {
uptr pc[10];
getcallerpcs((void *) tf->rbp, pc, NELEM(pc));
for (int i = 0; i < 10 && pc[i]; i++)
cprintf("cpu%d: %lx\n", mycpu()->id, pc[i]);
}
mycpu()->timer_printpc = 0;
}
if (mycpu()->id == 0)
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论