summaryrefslogtreecommitdiff
path: root/proc.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-06-06 13:54:03 -0400
committerRobert Morris <[email protected]>2019-06-06 13:54:03 -0400
commit91ba81110acd3163f7de3580b677eece0c57f5e7 (patch)
tree670536a7f365e75282048b5447a107338b677642 /proc.c
parent8607051b5fc79fffa319b913b19e99bc5b90e063 (diff)
downloadxv6-labs-91ba81110acd3163f7de3580b677eece0c57f5e7.tar.gz
xv6-labs-91ba81110acd3163f7de3580b677eece0c57f5e7.tar.bz2
xv6-labs-91ba81110acd3163f7de3580b677eece0c57f5e7.zip
gdb backtraces: -ggdb, -fno-omit-frame-pointer, BSIZE=1024
Diffstat (limited to 'proc.c')
-rw-r--r--proc.c29
1 files changed, 29 insertions, 0 deletions
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");
+ }
+}
+