]> Zhao Yanbai Git Server - minix.git/commitdiff
debugging - printing processes on serial
authorTomas Hruby <tom@minix3.org>
Mon, 3 May 2010 17:37:18 +0000 (17:37 +0000)
committerTomas Hruby <tom@minix3.org>
Mon, 3 May 2010 17:37:18 +0000 (17:37 +0000)
- 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
kernel/debug.c
kernel/proto.h

index 934bea2a97ef43710f91fec6483dbb139370d8c3..33340f4711f98723c75d0ca0a37d0af9cfc0c748 100644 (file)
@@ -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);
        }
 }
 
index ba9a33deab06df7f17093fcfce05d1a058af438b..beaa6daf5b5de6c3ab7bec48a19efe885e00969c 100644 (file)
@@ -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);
+}
+
index 2cd5befc67bea199b81e70b547a9313c3cebdb78..560f10662ba5ce592a3d2c1104b16152da5974ea 100644 (file)
@@ -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,