提交 89a7d4f1 创建 作者: Silas Boyd-Wickizer's avatar Silas Boyd-Wickizer

Fix procdump code and tweak output

上级 4eb2d3df
...@@ -503,38 +503,37 @@ kill(int pid) ...@@ -503,38 +503,37 @@ kill(int pid)
void *procdump(void *vk, void *v, void *arg) void *procdump(void *vk, void *v, void *arg)
{ {
struct proc *p = (struct proc *) v;
static char *states[] = { static char *states[] = {
[UNUSED] = "unused", [UNUSED] = "unused",
[EMBRYO] = "embryo", [EMBRYO] = "embryo",
[SLEEPING] = "sleep ", [SLEEPING] = "sleep ",
[RUNNABLE] = "runble", [RUNNABLE] = "runble",
[RUNNING] = "run ", [RUNNING] = "run ",
[ZOMBIE] = "zombie" [ZOMBIE] = "zombie"
}; };
char *state; struct proc *p = (struct proc *) v;
const char *name = "(no name)";
const char *state;
if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) if(p->state >= 0 && p->state < NELEM(states) && states[p->state])
state = states[p->state]; state = states[p->state];
else else
state = "???"; state = "???";
cprintf("%d %s %s %d %lu", p->pid, state, p->name, p->cpuid, p->tsc);
// XXX(sbw) if (p->name && p->name[0] != 0)
#if 0 name = p->name;
uint pc[10];
cprintf("\n%-3d %-10s %8s %2u %lu\n", p->pid, name, state, p->cpuid, p->tsc);
uptr pc[10];
if(p->state == SLEEPING){ if(p->state == SLEEPING){
getcallerpcs((uint*)p->context->ebp+2, pc); getcallerpcs((void*)p->context->rbp, pc);
for(int i=0; i<10 && pc[i] != 0; i++) for(int i=0; i<10 && pc[i] != 0; i++)
cprintf(" %p", pc[i]); cprintf(" %p\n", pc[i]);
} }
#endif
cprintf("\n");
return 0; return 0;
} }
//PAGEBREAK: 36
// Print a process listing to console. For debugging. // Print a process listing to console. For debugging.
// Runs when user types ^P on console. // Runs when user types ^P on console.
// No lock to avoid wedging a stuck machine further. // No lock to avoid wedging a stuck machine further.
......
...@@ -115,7 +115,7 @@ getcallerpcs(void *v, uptr pcs[]) ...@@ -115,7 +115,7 @@ getcallerpcs(void *v, uptr pcs[])
uptr *rbp; uptr *rbp;
int i; int i;
rbp = (uptr*)v - 2; rbp = (uptr*)v;
for(i = 0; i < 10; i++){ for(i = 0; i < 10; i++){
if(rbp == 0 || rbp < (uptr*)KBASE || rbp == (uptr*)(~0UL)) if(rbp == 0 || rbp < (uptr*)KBASE || rbp == (uptr*)(~0UL))
break; break;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论