From 57a88ce70812d81fcec22be817ce157bc895e2cd Mon Sep 17 00:00:00 2001 From: Tomas Hruby Date: Mon, 3 May 2010 17:37:18 +0000 Subject: [PATCH] debugging - printing processes on serial - this patch moves the former printslot() from arch_system.c to debug.c and reimplements it slightly. The output is not changed, however, the process information is printed in a separate function print_proc() in debug.c as such a function is also handy in other situations and should be publicly available when debugging. --- kernel/arch/i386/arch_system.c | 52 +----------------------- kernel/debug.c | 73 ++++++++++++++++++++++++++++++++++ kernel/proto.h | 4 ++ 3 files changed, 78 insertions(+), 51 deletions(-) diff --git a/kernel/arch/i386/arch_system.c b/kernel/arch/i386/arch_system.c index 934bea2a9..33340f471 100644 --- a/kernel/arch/i386/arch_system.c +++ b/kernel/arch/i386/arch_system.c @@ -324,56 +324,6 @@ PRIVATE void ser_debug(const int c) serial_debug_active = 0; } -PRIVATE void printslot(struct proc *pp, const int level) -{ - struct proc *depproc = NULL; - endpoint_t dep; -#define COL { int i; for(i = 0; i < level; i++) printf("> "); } - - if(level >= NR_PROCS) { - printf("loop??\n"); - return; - } - - COL - - printf("%d: %s %d prio %d time %d/%d cycles 0x%x%08x cr3 0x%lx rts %s misc %s sched %s", - proc_nr(pp), pp->p_name, pp->p_endpoint, - pp->p_priority, pp->p_user_time, - pp->p_sys_time, pp->p_cycles.hi, pp->p_cycles.lo, pp->p_seg.p_cr3, - rtsflagstr(pp->p_rts_flags), miscflagstr(pp->p_misc_flags), - schedulerstr(pp->p_scheduler)); - - if((dep = P_BLOCKEDON(pp)) != NONE) { - printf(" blocked on: "); - if(dep == ANY) { - printf(" ANY\n"); - } else { - int procno; - if(!isokendpt(dep, &procno)) { - printf(" ??? %d\n", dep); - } else { - depproc = proc_addr(procno); - if(isemptyp(depproc)) { - printf(" empty slot %d???\n", procno); - depproc = NULL; - } else { - printf(" %s\n", depproc->p_name); - } - } - } - } else { - printf("\n"); - } - - COL - proc_stacktrace(pp); - - - if(depproc) - printslot(depproc, level+1); -} - PUBLIC void ser_dump_proc() { @@ -383,7 +333,7 @@ PUBLIC void ser_dump_proc() { if (isemptyp(pp)) continue; - printslot(pp, 0); + print_proc_recursive(pp); } } diff --git a/kernel/debug.c b/kernel/debug.c index ba9a33dea..beaa6daf5 100644 --- a/kernel/debug.c +++ b/kernel/debug.c @@ -161,3 +161,76 @@ schedulerstr(struct proc *scheduler) return "KERNEL"; } +PUBLIC void print_proc(struct proc *pp) +{ + struct proc *depproc = NULL; + endpoint_t dep; + + printf("%d: %s %d prio %d time %d/%d cycles 0x%x%08x cr3 0x%lx rts %s misc %s sched %s", + proc_nr(pp), pp->p_name, pp->p_endpoint, + pp->p_priority, pp->p_user_time, + pp->p_sys_time, pp->p_cycles.hi, pp->p_cycles.lo, pp->p_seg.p_cr3, + rtsflagstr(pp->p_rts_flags), miscflagstr(pp->p_misc_flags), + schedulerstr(pp->p_scheduler)); + + dep = P_BLOCKEDON(pp); + if(dep != NONE) { + printf(" blocked on: "); + if(dep == ANY) { + printf(" ANY\n"); + } else { + int procno; + if(!isokendpt(dep, &procno)) { + printf(" ??? %d\n", dep); + } else { + depproc = proc_addr(procno); + if(isemptyp(depproc)) { + printf(" empty slot %d???\n", procno); + depproc = NULL; + } else { + printf(" %s\n", depproc->p_name); + } + } + } + } else { + printf("\n"); + } +} + +PRIVATE void print_proc_depends(struct proc *pp, const int level) +{ + struct proc *depproc = NULL; + endpoint_t dep; +#define COL { int i; for(i = 0; i < level; i++) printf("> "); } + + if(level >= NR_PROCS) { + printf("loop??\n"); + return; + } + + COL + + print_proc(pp); + + COL + proc_stacktrace(pp); + + + dep = P_BLOCKEDON(pp); + if(dep != NONE) { + int procno; + if(isokendpt(dep, &procno)) { + depproc = proc_addr(procno); + if(isemptyp(depproc)) + depproc = NULL; + } + if (depproc) + print_proc_depends(depproc, level+1); + } +} + +PUBLIC void print_proc_recursive(struct proc *pp) +{ + print_proc_depends(pp, 0); +} + diff --git a/kernel/proto.h b/kernel/proto.h index 2cd5befc6..560f10662 100644 --- a/kernel/proto.h +++ b/kernel/proto.h @@ -92,6 +92,10 @@ _PROTOTYPE( int runqueues_ok, (void) ); _PROTOTYPE( char *rtsflagstr, (int flags) ); _PROTOTYPE( char *miscflagstr, (int flags) ); _PROTOTYPE( char *schedulerstr, (struct proc *scheduler) ); +/* prints process information */ +_PROTOTYPE( void print_proc, (struct proc *pp)); +/* prints the given process and recursively all processes it depends on */ +_PROTOTYPE( void print_proc_recursive, (struct proc *pp)); /* system/do_safemap.c */ _PROTOTYPE( int map_invoke_vm, (struct proc * caller, int req_type,