From 91ba81110acd3163f7de3580b677eece0c57f5e7 Mon Sep 17 00:00:00 2001 From: Robert Morris Date: Thu, 6 Jun 2019 13:54:03 -0400 Subject: gdb backtraces: -ggdb, -fno-omit-frame-pointer, BSIZE=1024 --- proc.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'proc.c') diff --git a/proc.c b/proc.c index d23cb95..4ae34c8 100644 --- a/proc.c +++ b/proc.c @@ -560,3 +560,32 @@ either_copyin(void *dst, int user_src, uint64 src, uint64 len) } } +// Print a process listing to console. For debugging. +// Runs when user types ^P on console. +// No lock to avoid wedging a stuck machine further. +void +procdump(void) +{ + static char *states[] = { + [UNUSED] "unused", + [EMBRYO] "embryo", + [SLEEPING] "sleep ", + [RUNNABLE] "runble", + [RUNNING] "run ", + [ZOMBIE] "zombie" + }; + struct proc *p; + char *state; + + for(p = ptable.proc; p < &ptable.proc[NPROC]; p++){ + if(p->state == UNUSED) + continue; + if(p->state >= 0 && p->state < NELEM(states) && states[p->state]) + state = states[p->state]; + else + state = "???"; + printf("%d %s %s", p->pid, state, p->name); + printf("\n"); + } +} + -- cgit v1.2.3