[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/ddb/db_ps.c

Version: -  FREEBSD  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  cheribsd  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1  -  FREEBSD-LIBC  -  FREEBSD8-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 1993 The Regents of the University of California.
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  * 4. Neither the name of the University nor the names of its contributors
   14  *    may be used to endorse or promote products derived from this software
   15  *    without specific prior written permission.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  */
   29 
   30 #include <sys/cdefs.h>
   31 __FBSDID("$FreeBSD: src/sys/ddb/db_ps.c,v 1.52.2.3 2005/02/05 01:02:27 das Exp $");
   32 
   33 #include <sys/param.h>
   34 #include <sys/systm.h>
   35 #include <sys/lock.h>
   36 #include <sys/mutex.h>
   37 #include <sys/proc.h>
   38 #include <sys/cons.h>
   39 #include <vm/vm.h>
   40 #include <vm/vm_param.h>
   41 #include <vm/pmap.h>
   42 
   43 #include <ddb/ddb.h>
   44 
   45 static void     dumpthread(volatile struct proc *p, volatile struct thread *td);
   46 
   47 void
   48 db_ps(dummy1, dummy2, dummy3, dummy4)
   49         db_expr_t       dummy1;
   50         boolean_t       dummy2;
   51         db_expr_t       dummy3;
   52         char *          dummy4;
   53 {
   54         volatile struct proc *p, *pp;
   55         volatile struct thread *td;
   56         char *state;
   57         int np, quit;
   58 
   59         np = nprocs;
   60         quit = 0;
   61 
   62         /* sx_slock(&allproc_lock); */
   63         if (!LIST_EMPTY(&allproc))
   64                 p = LIST_FIRST(&allproc);
   65         else
   66                 p = &proc0;
   67 
   68         db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
   69         db_printf("  pid   proc     uid  ppid  pgrp  flag   stat  wmesg    wchan  cmd\n");
   70         while (--np >= 0 && !quit) {
   71                 if (p == NULL) {
   72                         printf("oops, ran out of processes early!\n");
   73                         break;
   74                 }
   75                 /* PROC_LOCK(p); */
   76                 pp = p->p_pptr;
   77                 if (pp == NULL)
   78                         pp = p;
   79 
   80 
   81                 switch(p->p_state) {
   82                 case PRS_NORMAL:
   83                         if (P_SHOULDSTOP(p))
   84                                 state = "stop";
   85                         else
   86                                 state = "";
   87                         break;
   88                 case PRS_NEW:
   89                         state = "new ";
   90                         break;
   91                 case PRS_ZOMBIE:
   92                         state = "zomb";
   93                         break;
   94                 default:
   95                         state = "Unkn";
   96                         break;
   97                 }
   98                 db_printf("%5d %8p %4d %5d %5d %07x %s",
   99                     p->p_pid, (volatile void *)p,
  100                     p->p_ucred != NULL ? p->p_ucred->cr_ruid : 0, pp->p_pid,
  101                     p->p_pgrp != NULL ? p->p_pgrp->pg_id : 0, p->p_flag,
  102                     state);
  103                 if (p->p_flag & P_HADTHREADS)
  104                         db_printf("(threaded)  %s\n", p->p_comm);
  105                 FOREACH_THREAD_IN_PROC(p, td) {
  106                         dumpthread(p, td);
  107                         if (quit)
  108                                 break;
  109                 }
  110                 /* PROC_UNLOCK(p); */
  111 
  112                 p = LIST_NEXT(p, p_list);
  113                 if (p == NULL && np > 0)
  114                         p = LIST_FIRST(&zombproc);
  115         }
  116         /* sx_sunlock(&allproc_lock); */
  117 }
  118 
  119 static void
  120 dumpthread(volatile struct proc *p, volatile struct thread *td)
  121 {
  122 
  123         if (p->p_flag & P_HADTHREADS)
  124                 db_printf( "   thread %p ksegrp %p ", td, td->td_ksegrp);
  125         if (TD_ON_SLEEPQ(td))
  126                 db_printf("[SLPQ %s %p]", td->td_wmesg, (void *)td->td_wchan);
  127         switch (td->td_state) {
  128         case TDS_INHIBITED:
  129                 if (TD_ON_LOCK(td)) {
  130                         db_printf("[LOCK %6s %8p]",
  131                             td->td_lockname,
  132                             (void *)td->td_blocked);
  133                 }
  134                 if (TD_IS_SLEEPING(td)) {
  135                         db_printf("[SLP]");
  136                 }  
  137                 if (TD_IS_SWAPPED(td)) {
  138                         db_printf("[SWAP]");
  139                 }
  140                 if (TD_IS_SUSPENDED(td)) {
  141                         db_printf("[SUSP]");
  142                 }
  143                 if (TD_AWAITING_INTR(td)) {
  144                         db_printf("[IWAIT]");
  145                 }
  146                 break;
  147         case TDS_CAN_RUN:
  148                 db_printf("[Can run]");
  149                 break;
  150         case TDS_RUNQ:
  151                 db_printf("[RUNQ]");
  152                 break;
  153         case TDS_RUNNING:
  154                 db_printf("[CPU %d]", td->td_oncpu);
  155                 break;
  156         case TDS_INACTIVE:
  157                 db_printf("[INACTIVE]");
  158                 break;
  159         default:
  160                 db_printf("[UNK: %#x]", td->td_state);
  161         }
  162         if (p->p_flag & P_HADTHREADS) {
  163 #ifdef KEF_DIDRUN
  164                 if (td->td_kse)
  165                         db_printf("[kse %p]", td->td_kse);
  166 #endif
  167                 db_printf("\n");
  168         } else
  169                 db_printf(" %s\n", p->p_comm);
  170 }

Cache object: c31286d707723e2df1bde39d6a2989b0


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.