MCPcopy Create free account
hub / github.com/F-Stack/f-stack / db_ps_proc

Function db_ps_proc

freebsd/ddb/db_ps.c:138–259  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136}
137
138static void
139db_ps_proc(struct proc *p)
140{
141 volatile struct proc *pp;
142 volatile struct thread *td;
143 struct ucred *cred;
144 struct pgrp *pgrp;
145 char state[9];
146 int rflag, sflag, dflag, lflag, wflag;
147
148 pp = p->p_pptr;
149 if (pp == NULL)
150 pp = p;
151
152 cred = p->p_ucred;
153 pgrp = p->p_pgrp;
154 db_printf("%5d %5d %5d %5d ", p->p_pid, pp->p_pid,
155 pgrp != NULL ? pgrp->pg_id : 0,
156 cred != NULL ? cred->cr_ruid : 0);
157
158 /* Determine our primary process state. */
159 switch (p->p_state) {
160 case PRS_NORMAL:
161 if (P_SHOULDSTOP(p))
162 state[0] = 'T';
163 else {
164 /*
165 * One of D, L, R, S, W. For a
166 * multithreaded process we will use
167 * the state of the thread with the
168 * highest precedence. The
169 * precendence order from high to low
170 * is R, L, D, S, W. If no thread is
171 * in a sane state we use '?' for our
172 * primary state.
173 */
174 rflag = sflag = dflag = lflag = wflag = 0;
175 FOREACH_THREAD_IN_PROC(p, td) {
176 if (td->td_state == TDS_RUNNING ||
177 td->td_state == TDS_RUNQ ||
178 td->td_state == TDS_CAN_RUN)
179 rflag++;
180 if (TD_ON_LOCK(td))
181 lflag++;
182 if (TD_IS_SLEEPING(td)) {
183 if (!(td->td_flags & TDF_SINTR))
184 dflag++;
185 else
186 sflag++;
187 }
188 if (TD_AWAITING_INTR(td))
189 wflag++;
190 }
191 if (rflag)
192 state[0] = 'R';
193 else if (lflag)
194 state[0] = 'L';
195 else if (dflag)

Callers 1

db_psFunction · 0.85

Calls 5

db_printfFunction · 0.85
jailedFunction · 0.85
dumpthreadFunction · 0.85
dump_argsFunction · 0.70
strlcatFunction · 0.50

Tested by

no test coverage detected