1994-08-27 16:28:45 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1993 The Regents of the University of California.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 4. Neither the name of the University nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
2003-06-10 22:09:23 +00:00
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
1994-08-27 16:28:45 +00:00
|
|
|
#include <sys/param.h>
|
2006-04-27 22:09:18 +00:00
|
|
|
#include <sys/cons.h>
|
2006-04-25 20:34:04 +00:00
|
|
|
#include <sys/jail.h>
|
|
|
|
#include <sys/kdb.h>
|
|
|
|
#include <sys/linker_set.h>
|
1994-08-27 16:28:45 +00:00
|
|
|
#include <sys/proc.h>
|
2006-04-25 20:34:04 +00:00
|
|
|
#include <sys/sysent.h>
|
2006-04-27 22:09:18 +00:00
|
|
|
#include <sys/systm.h>
|
2002-12-28 01:23:07 +00:00
|
|
|
#include <vm/vm.h>
|
|
|
|
#include <vm/vm_param.h>
|
|
|
|
#include <vm/pmap.h>
|
1994-08-27 16:28:45 +00:00
|
|
|
|
1995-12-10 19:08:32 +00:00
|
|
|
#include <ddb/ddb.h>
|
2003-06-06 17:19:27 +00:00
|
|
|
|
2006-04-25 20:34:04 +00:00
|
|
|
static void dumpthread(volatile struct proc *p, volatile struct thread *td,
|
|
|
|
int all);
|
2008-03-25 20:36:32 +00:00
|
|
|
/*
|
|
|
|
* At least one non-optional show-command must be implemented using
|
|
|
|
* DB_SHOW_ALL_COMMAND() so that db_show_all_cmd_set gets created.
|
|
|
|
* Here is one.
|
|
|
|
*/
|
|
|
|
DB_SHOW_ALL_COMMAND(procs, db_procs_cmd)
|
|
|
|
{
|
|
|
|
db_ps(addr, have_addr, count, modif);
|
|
|
|
}
|
1995-12-10 19:08:32 +00:00
|
|
|
|
2006-04-25 20:34:04 +00:00
|
|
|
/*
|
|
|
|
* Layout:
|
|
|
|
* - column counts
|
|
|
|
* - header
|
|
|
|
* - single-threaded process
|
|
|
|
* - multi-threaded process
|
|
|
|
* - thread in a MT process
|
|
|
|
*
|
|
|
|
* 1 2 3 4 5 6 7
|
|
|
|
* 1234567890123456789012345678901234567890123456789012345678901234567890
|
2006-08-01 22:30:55 +00:00
|
|
|
* pid ppid pgrp uid state wmesg wchan cmd
|
|
|
|
* <pid> <ppi> <pgi> <uid> <stat> < wmesg > < wchan > <name>
|
|
|
|
* <pid> <ppi> <pgi> <uid> <stat> (threaded) <command>
|
|
|
|
* <tid > <stat> < wmesg > < wchan > <name>
|
2006-04-25 20:34:04 +00:00
|
|
|
*
|
|
|
|
* For machines with 64-bit pointers, we expand the wchan field 8 more
|
|
|
|
* characters.
|
|
|
|
*/
|
1994-08-27 16:28:45 +00:00
|
|
|
void
|
2006-04-25 20:34:04 +00:00
|
|
|
db_ps(db_expr_t addr, boolean_t hasaddr, db_expr_t count, char *modif)
|
1995-08-27 02:40:39 +00:00
|
|
|
{
|
1995-08-20 05:25:11 +00:00
|
|
|
volatile struct proc *p, *pp;
|
2001-10-20 03:22:23 +00:00
|
|
|
volatile struct thread *td;
|
2006-04-25 20:34:04 +00:00
|
|
|
struct ucred *cred;
|
|
|
|
struct pgrp *pgrp;
|
|
|
|
char state[9];
|
2006-07-12 21:22:44 +00:00
|
|
|
int np, rflag, sflag, dflag, lflag, wflag;
|
1995-08-20 05:25:11 +00:00
|
|
|
|
1994-08-27 16:28:45 +00:00
|
|
|
np = nprocs;
|
1995-08-20 05:25:11 +00:00
|
|
|
|
2000-12-30 22:06:19 +00:00
|
|
|
if (!LIST_EMPTY(&allproc))
|
|
|
|
p = LIST_FIRST(&allproc);
|
1995-08-20 05:25:11 +00:00
|
|
|
else
|
|
|
|
p = &proc0;
|
1994-08-27 16:28:45 +00:00
|
|
|
|
2006-05-11 21:59:55 +00:00
|
|
|
#ifdef __LP64__
|
2006-08-01 22:30:55 +00:00
|
|
|
db_printf(" pid ppid pgrp uid state wmesg wchan cmd\n");
|
2006-04-25 20:34:04 +00:00
|
|
|
#else
|
2006-08-01 22:30:55 +00:00
|
|
|
db_printf(" pid ppid pgrp uid state wmesg wchan cmd\n");
|
2006-04-25 20:34:04 +00:00
|
|
|
#endif
|
2006-07-12 21:22:44 +00:00
|
|
|
while (--np >= 0 && !db_pager_quit) {
|
1996-06-15 07:08:02 +00:00
|
|
|
if (p == NULL) {
|
2006-04-25 20:34:04 +00:00
|
|
|
db_printf("oops, ran out of processes early!\n");
|
1996-06-15 07:08:02 +00:00
|
|
|
break;
|
|
|
|
}
|
1994-08-27 16:28:45 +00:00
|
|
|
pp = p->p_pptr;
|
1995-08-20 05:25:11 +00:00
|
|
|
if (pp == NULL)
|
1994-08-27 16:28:45 +00:00
|
|
|
pp = p;
|
1995-08-20 05:25:11 +00:00
|
|
|
|
2006-04-25 20:34:04 +00:00
|
|
|
cred = p->p_ucred;
|
|
|
|
pgrp = p->p_pgrp;
|
2006-08-01 15:29:46 +00:00
|
|
|
db_printf("%5d %5d %5d %5d ", p->p_pid, pp->p_pid,
|
|
|
|
pgrp != NULL ? pgrp->pg_id : 0,
|
|
|
|
cred != NULL ? cred->cr_ruid : 0);
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
|
2006-04-25 20:34:04 +00:00
|
|
|
/* Determine our primary process state. */
|
2006-04-27 22:02:27 +00:00
|
|
|
switch (p->p_state) {
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
case PRS_NORMAL:
|
|
|
|
if (P_SHOULDSTOP(p))
|
2006-04-25 20:34:04 +00:00
|
|
|
state[0] = 'T';
|
|
|
|
else {
|
|
|
|
/*
|
|
|
|
* One of D, L, R, S, W. For a
|
|
|
|
* multithreaded process we will use
|
|
|
|
* the state of the thread with the
|
|
|
|
* highest precedence. The
|
|
|
|
* precendence order from high to low
|
|
|
|
* is R, L, D, S, W. If no thread is
|
|
|
|
* in a sane state we use '?' for our
|
|
|
|
* primary state.
|
|
|
|
*/
|
|
|
|
rflag = sflag = dflag = lflag = wflag = 0;
|
|
|
|
FOREACH_THREAD_IN_PROC(p, td) {
|
|
|
|
if (td->td_state == TDS_RUNNING ||
|
|
|
|
td->td_state == TDS_RUNQ ||
|
|
|
|
td->td_state == TDS_CAN_RUN)
|
|
|
|
rflag++;
|
|
|
|
if (TD_ON_LOCK(td))
|
|
|
|
lflag++;
|
|
|
|
if (TD_IS_SLEEPING(td)) {
|
|
|
|
if (!td->td_flags & TDF_SINTR)
|
|
|
|
dflag++;
|
|
|
|
else
|
|
|
|
sflag++;
|
|
|
|
}
|
|
|
|
if (TD_AWAITING_INTR(td))
|
|
|
|
wflag++;
|
|
|
|
}
|
|
|
|
if (rflag)
|
|
|
|
state[0] = 'R';
|
|
|
|
else if (lflag)
|
|
|
|
state[0] = 'L';
|
|
|
|
else if (dflag)
|
|
|
|
state[0] = 'D';
|
|
|
|
else if (sflag)
|
|
|
|
state[0] = 'S';
|
|
|
|
else if (wflag)
|
|
|
|
state[0] = 'W';
|
|
|
|
else
|
|
|
|
state[0] = '?';
|
|
|
|
}
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
break;
|
|
|
|
case PRS_NEW:
|
2006-04-25 20:34:04 +00:00
|
|
|
state[0] = 'N';
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
break;
|
|
|
|
case PRS_ZOMBIE:
|
2006-04-25 20:34:04 +00:00
|
|
|
state[0] = 'Z';
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
break;
|
|
|
|
default:
|
2006-04-25 20:34:04 +00:00
|
|
|
state[0] = 'U';
|
Part 1 of KSE-III
The ability to schedule multiple threads per process
(one one cpu) by making ALL system calls optionally asynchronous.
to come: ia64 and power-pc patches, patches for gdb, test program (in tools)
Reviewed by: Almost everyone who counts
(at various times, peter, jhb, matt, alfred, mini, bernd,
and a cast of thousands)
NOTE: this is still Beta code, and contains lots of debugging stuff.
expect slight instability in signals..
2002-06-29 17:26:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-04-25 20:34:04 +00:00
|
|
|
state[1] = '\0';
|
|
|
|
|
|
|
|
/* Additional process state flags. */
|
2007-09-17 05:31:39 +00:00
|
|
|
if (!p->p_flag & P_INMEM)
|
2006-04-25 20:34:04 +00:00
|
|
|
strlcat(state, "W", sizeof(state));
|
|
|
|
if (p->p_flag & P_TRACED)
|
|
|
|
strlcat(state, "X", sizeof(state));
|
|
|
|
if (p->p_flag & P_WEXIT && p->p_state != PRS_ZOMBIE)
|
|
|
|
strlcat(state, "E", sizeof(state));
|
|
|
|
if (p->p_flag & P_PPWAIT)
|
|
|
|
strlcat(state, "V", sizeof(state));
|
|
|
|
if (p->p_flag & P_SYSTEM || p->p_lock > 0)
|
|
|
|
strlcat(state, "L", sizeof(state));
|
|
|
|
if (p->p_session != NULL && SESS_LEADER(p))
|
|
|
|
strlcat(state, "s", sizeof(state));
|
|
|
|
/* Cheated here and didn't compare pgid's. */
|
|
|
|
if (p->p_flag & P_CONTROLT)
|
|
|
|
strlcat(state, "+", sizeof(state));
|
|
|
|
if (cred != NULL && jailed(cred))
|
|
|
|
strlcat(state, "J", sizeof(state));
|
|
|
|
db_printf(" %-6.6s ", state);
|
2004-09-05 02:09:54 +00:00
|
|
|
if (p->p_flag & P_HADTHREADS)
|
2006-05-11 21:59:55 +00:00
|
|
|
#ifdef __LP64__
|
2006-04-25 20:34:04 +00:00
|
|
|
db_printf(" (threaded) %s\n",
|
|
|
|
p->p_comm);
|
|
|
|
#else
|
|
|
|
db_printf(" (threaded) %s\n", p->p_comm);
|
|
|
|
#endif
|
2002-09-11 08:13:56 +00:00
|
|
|
FOREACH_THREAD_IN_PROC(p, td) {
|
2006-04-25 20:34:04 +00:00
|
|
|
dumpthread(p, td, p->p_flag & P_HADTHREADS);
|
2006-07-12 21:22:44 +00:00
|
|
|
if (db_pager_quit)
|
2003-07-31 17:29:42 +00:00
|
|
|
break;
|
1994-08-27 16:28:45 +00:00
|
|
|
}
|
2002-04-11 21:01:34 +00:00
|
|
|
|
2000-12-30 22:06:19 +00:00
|
|
|
p = LIST_NEXT(p, p_list);
|
1995-08-20 05:25:11 +00:00
|
|
|
if (p == NULL && np > 0)
|
2000-12-30 22:06:19 +00:00
|
|
|
p = LIST_FIRST(&zombproc);
|
1994-08-27 16:28:45 +00:00
|
|
|
}
|
|
|
|
}
|
2003-06-06 17:19:27 +00:00
|
|
|
|
2002-12-28 01:23:07 +00:00
|
|
|
static void
|
2006-04-25 20:34:04 +00:00
|
|
|
dumpthread(volatile struct proc *p, volatile struct thread *td, int all)
|
2002-12-28 01:23:07 +00:00
|
|
|
{
|
2006-04-25 20:34:04 +00:00
|
|
|
char state[9], wprefix;
|
|
|
|
const char *wmesg;
|
|
|
|
void *wchan;
|
|
|
|
|
|
|
|
if (all) {
|
2006-08-01 15:29:46 +00:00
|
|
|
db_printf("%6d ", td->td_tid);
|
2006-04-25 20:34:04 +00:00
|
|
|
switch (td->td_state) {
|
|
|
|
case TDS_RUNNING:
|
|
|
|
snprintf(state, sizeof(state), "Run");
|
|
|
|
break;
|
|
|
|
case TDS_RUNQ:
|
|
|
|
snprintf(state, sizeof(state), "RunQ");
|
|
|
|
break;
|
|
|
|
case TDS_CAN_RUN:
|
|
|
|
snprintf(state, sizeof(state), "CanRun");
|
|
|
|
break;
|
|
|
|
case TDS_INACTIVE:
|
|
|
|
snprintf(state, sizeof(state), "Inactv");
|
|
|
|
break;
|
|
|
|
case TDS_INHIBITED:
|
|
|
|
state[0] = '\0';
|
|
|
|
if (TD_ON_LOCK(td))
|
|
|
|
strlcat(state, "L", sizeof(state));
|
|
|
|
if (TD_IS_SLEEPING(td)) {
|
|
|
|
if (td->td_flags & TDF_SINTR)
|
|
|
|
strlcat(state, "S", sizeof(state));
|
|
|
|
else
|
|
|
|
strlcat(state, "D", sizeof(state));
|
|
|
|
}
|
|
|
|
if (TD_IS_SWAPPED(td))
|
|
|
|
strlcat(state, "W", sizeof(state));
|
|
|
|
if (TD_AWAITING_INTR(td))
|
|
|
|
strlcat(state, "I", sizeof(state));
|
|
|
|
if (TD_IS_SUSPENDED(td))
|
|
|
|
strlcat(state, "s", sizeof(state));
|
|
|
|
if (state[0] != '\0')
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
snprintf(state, sizeof(state), "???");
|
|
|
|
}
|
|
|
|
db_printf(" %-6.6s ", state);
|
|
|
|
}
|
|
|
|
wprefix = ' ';
|
|
|
|
if (TD_ON_LOCK(td)) {
|
|
|
|
wprefix = '*';
|
|
|
|
wmesg = td->td_lockname;
|
|
|
|
wchan = td->td_blocked;
|
|
|
|
} else if (TD_ON_SLEEPQ(td)) {
|
|
|
|
wmesg = td->td_wmesg;
|
|
|
|
wchan = td->td_wchan;
|
|
|
|
} else if (TD_IS_RUNNING(td)) {
|
|
|
|
snprintf(state, sizeof(state), "CPU %d", td->td_oncpu);
|
|
|
|
wmesg = state;
|
|
|
|
wchan = NULL;
|
|
|
|
} else {
|
|
|
|
wmesg = "";
|
|
|
|
wchan = NULL;
|
|
|
|
}
|
|
|
|
db_printf("%c%-8.8s ", wprefix, wmesg);
|
|
|
|
if (wchan == NULL)
|
2006-05-11 21:59:55 +00:00
|
|
|
#ifdef __LP64__
|
2006-04-25 20:34:04 +00:00
|
|
|
db_printf("%18s ", "");
|
|
|
|
#else
|
|
|
|
db_printf("%10s ", "");
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
db_printf("%p ", wchan);
|
|
|
|
if (p->p_flag & P_SYSTEM)
|
|
|
|
db_printf("[");
|
|
|
|
if (td->td_name[0] != '\0')
|
|
|
|
db_printf("%s", td->td_name);
|
|
|
|
else
|
|
|
|
db_printf("%s", td->td_proc->p_comm);
|
|
|
|
if (p->p_flag & P_SYSTEM)
|
|
|
|
db_printf("]");
|
|
|
|
db_printf("\n");
|
|
|
|
}
|
2003-07-30 20:59:36 +00:00
|
|
|
|
2006-04-25 20:34:04 +00:00
|
|
|
DB_SHOW_COMMAND(thread, db_show_thread)
|
|
|
|
{
|
|
|
|
struct thread *td;
|
2008-06-18 20:42:01 +00:00
|
|
|
struct lock_object *lock;
|
2006-04-25 20:34:04 +00:00
|
|
|
boolean_t comma;
|
|
|
|
|
|
|
|
/* Determine which thread to examine. */
|
|
|
|
if (have_addr)
|
|
|
|
td = db_lookup_thread(addr, FALSE);
|
|
|
|
else
|
|
|
|
td = kdb_thread;
|
2008-06-18 20:42:01 +00:00
|
|
|
lock = (struct lock_object *)td->td_lock;
|
2006-04-25 20:34:04 +00:00
|
|
|
|
|
|
|
db_printf("Thread %d at %p:\n", td->td_tid, td);
|
2006-10-26 21:42:22 +00:00
|
|
|
db_printf(" proc (pid %d): %p\n", td->td_proc->p_pid, td->td_proc);
|
2006-04-25 20:34:04 +00:00
|
|
|
if (td->td_name[0] != '\0')
|
|
|
|
db_printf(" name: %s\n", td->td_name);
|
2007-10-16 17:52:59 +00:00
|
|
|
db_printf(" stack: %p-%p\n", (void *)td->td_kstack,
|
|
|
|
(void *)(td->td_kstack + td->td_kstack_pages * PAGE_SIZE - 1));
|
2006-04-25 20:34:04 +00:00
|
|
|
db_printf(" flags: %#x ", td->td_flags);
|
|
|
|
db_printf(" pflags: %#x\n", td->td_pflags);
|
|
|
|
db_printf(" state: ");
|
2002-12-28 01:23:07 +00:00
|
|
|
switch (td->td_state) {
|
2006-04-25 20:34:04 +00:00
|
|
|
case TDS_INACTIVE:
|
|
|
|
db_printf("INACTIVE\n");
|
|
|
|
break;
|
|
|
|
case TDS_CAN_RUN:
|
|
|
|
db_printf("CAN RUN\n");
|
|
|
|
break;
|
|
|
|
case TDS_RUNQ:
|
|
|
|
db_printf("RUNQ\n");
|
|
|
|
break;
|
|
|
|
case TDS_RUNNING:
|
|
|
|
db_printf("RUNNING (CPU %d)\n", td->td_oncpu);
|
|
|
|
break;
|
2002-12-28 01:23:07 +00:00
|
|
|
case TDS_INHIBITED:
|
2006-04-25 20:34:04 +00:00
|
|
|
db_printf("INHIBITED: {");
|
|
|
|
comma = FALSE;
|
2002-12-28 01:23:07 +00:00
|
|
|
if (TD_IS_SLEEPING(td)) {
|
2006-04-25 20:34:04 +00:00
|
|
|
db_printf("SLEEPING");
|
|
|
|
comma = TRUE;
|
2002-12-28 01:23:07 +00:00
|
|
|
}
|
|
|
|
if (TD_IS_SUSPENDED(td)) {
|
2006-04-25 20:34:04 +00:00
|
|
|
if (comma)
|
|
|
|
db_printf(", ");
|
|
|
|
db_printf("SUSPENDED");
|
|
|
|
comma = TRUE;
|
|
|
|
}
|
|
|
|
if (TD_IS_SWAPPED(td)) {
|
|
|
|
if (comma)
|
|
|
|
db_printf(", ");
|
|
|
|
db_printf("SWAPPED");
|
|
|
|
comma = TRUE;
|
|
|
|
}
|
|
|
|
if (TD_ON_LOCK(td)) {
|
|
|
|
if (comma)
|
|
|
|
db_printf(", ");
|
|
|
|
db_printf("LOCK");
|
|
|
|
comma = TRUE;
|
2002-12-28 01:23:07 +00:00
|
|
|
}
|
|
|
|
if (TD_AWAITING_INTR(td)) {
|
2006-04-25 20:34:04 +00:00
|
|
|
if (comma)
|
|
|
|
db_printf(", ");
|
|
|
|
db_printf("IWAIT");
|
2002-12-28 01:23:07 +00:00
|
|
|
}
|
2006-04-25 20:34:04 +00:00
|
|
|
db_printf("}\n");
|
2002-12-28 01:23:07 +00:00
|
|
|
break;
|
2006-04-25 20:34:04 +00:00
|
|
|
default:
|
|
|
|
db_printf("??? (%#x)\n", td->td_state);
|
2002-12-28 01:23:07 +00:00
|
|
|
break;
|
2006-04-25 20:34:04 +00:00
|
|
|
}
|
|
|
|
if (TD_ON_LOCK(td))
|
|
|
|
db_printf(" lock: %s turnstile: %p\n", td->td_lockname,
|
|
|
|
td->td_blocked);
|
|
|
|
if (TD_ON_SLEEPQ(td))
|
|
|
|
db_printf(" wmesg: %s wchan: %p\n", td->td_wmesg,
|
|
|
|
td->td_wchan);
|
|
|
|
db_printf(" priority: %d\n", td->td_priority);
|
2008-06-18 20:42:01 +00:00
|
|
|
db_printf(" container lock: %s (%p)\n", lock->lo_name, lock);
|
2006-04-25 20:34:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DB_SHOW_COMMAND(proc, db_show_proc)
|
|
|
|
{
|
|
|
|
struct thread *td;
|
|
|
|
struct proc *p;
|
2006-07-12 21:22:44 +00:00
|
|
|
int i;
|
2006-04-25 20:34:04 +00:00
|
|
|
|
|
|
|
/* Determine which process to examine. */
|
|
|
|
if (have_addr)
|
|
|
|
p = db_lookup_proc(addr);
|
|
|
|
else
|
|
|
|
p = kdb_thread->td_proc;
|
|
|
|
|
|
|
|
db_printf("Process %d (%s) at %p:\n", p->p_pid, p->p_comm, p);
|
|
|
|
db_printf(" state: ");
|
|
|
|
switch (p->p_state) {
|
|
|
|
case PRS_NEW:
|
|
|
|
db_printf("NEW\n");
|
2002-12-28 01:23:07 +00:00
|
|
|
break;
|
2006-04-25 20:34:04 +00:00
|
|
|
case PRS_NORMAL:
|
|
|
|
db_printf("NORMAL\n");
|
2002-12-28 01:23:07 +00:00
|
|
|
break;
|
2006-04-25 20:34:04 +00:00
|
|
|
case PRS_ZOMBIE:
|
|
|
|
db_printf("ZOMBIE\n");
|
2003-06-06 17:20:47 +00:00
|
|
|
break;
|
2002-12-28 01:23:07 +00:00
|
|
|
default:
|
2006-04-25 20:34:04 +00:00
|
|
|
db_printf("??? (%#x)\n", p->p_state);
|
2002-12-28 01:23:07 +00:00
|
|
|
}
|
2006-04-25 20:34:04 +00:00
|
|
|
if (p->p_ucred != NULL) {
|
|
|
|
db_printf(" uid: %d gids: ", p->p_ucred->cr_uid);
|
|
|
|
for (i = 0; i < p->p_ucred->cr_ngroups; i++) {
|
|
|
|
db_printf("%d", p->p_ucred->cr_groups[i]);
|
|
|
|
if (i < (p->p_ucred->cr_ngroups - 1))
|
|
|
|
db_printf(", ");
|
|
|
|
}
|
2002-12-28 01:23:07 +00:00
|
|
|
db_printf("\n");
|
2006-04-25 20:34:04 +00:00
|
|
|
}
|
|
|
|
if (p->p_pptr != NULL)
|
|
|
|
db_printf(" parent: pid %d at %p\n", p->p_pptr->p_pid,
|
|
|
|
p->p_pptr);
|
|
|
|
if (p->p_leader != NULL && p->p_leader != p)
|
|
|
|
db_printf(" leader: pid %d at %p\n", p->p_leader->p_pid,
|
|
|
|
p->p_leader);
|
|
|
|
if (p->p_sysent != NULL)
|
|
|
|
db_printf(" ABI: %s\n", p->p_sysent->sv_name);
|
|
|
|
if (p->p_args != NULL)
|
|
|
|
db_printf(" arguments: %.*s\n", (int)p->p_args->ar_length,
|
|
|
|
p->p_args->ar_args);
|
|
|
|
db_printf(" threads: %d\n", p->p_numthreads);
|
|
|
|
FOREACH_THREAD_IN_PROC(p, td) {
|
|
|
|
dumpthread(p, td, 1);
|
2006-07-12 21:22:44 +00:00
|
|
|
if (db_pager_quit)
|
2006-04-25 20:34:04 +00:00
|
|
|
break;
|
|
|
|
}
|
2002-12-28 01:23:07 +00:00
|
|
|
}
|