Now that pfind(9) takes tid we need a way to show TID in ddb(4) ps
output. Otherwise it's hard to use "ps /p"
Diff below does that and fix some documentation about "show all procs".
pfind(9) manual still needs a fix, and we can all decide afterward if
we should rename "/p" into "/t".
Here's the difference:
Before:
PID PPID PGRP UID S FLAGS WAIT COMMAND
*50672 66667 50672 0 7 0x3 sysctl
66667 1 66667 0 3 0x10008b pause ksh
90555 1 90555 0 3 0x100098 poll cron
After:
PID TID PPID PGRP UID S FLAGS WAIT COMMAND
*52636 496486 51956 52636 0 7 0x3 sysctl
51956 407679 1 51956 0 3 0x10008b pause ksh
42726 321266 1 42726 0 3 0x100098 poll cron
ok?
Index: sys/kern/kern_proc.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_proc.c,v
retrieving revision 1.72
diff -u -p -r1.72 kern_proc.c
--- sys/kern/kern_proc.c 21 Jan 2017 05:42:03 -0000 1.72
+++ sys/kern/kern_proc.c 23 Jan 2017 23:47:49 -0000
@@ -471,8 +471,8 @@ db_show_all_procs(db_expr_t addr, int ha
"COMMAND", "STRUCT PROC *", "UAREA *", "VMSPACE/VM_MAP");
break;
case 'n':
- db_printf(" PID %5s %5s %5s S %10s %-12s %-16s\n",
- "PPID", "PGRP", "UID", "FLAGS", "WAIT", "COMMAND");
+ db_printf(" PID %6s %5s %5s %5s S %10s %-12s %-16s\n",
+ "TID", "PPID", "PGRP", "UID", "FLAGS", "WAIT", "COMMAND");
break;
case 'w':
db_printf(" TID %-16s %-8s %18s %s\n",
@@ -497,8 +497,14 @@ db_show_all_procs(db_expr_t addr, int ha
ci_schedstate.spc_idleproc == p)
continue;
}
- db_printf("%c%5d ", p == curproc ? '*' : ' ',
- *mode == 'n' ? pr->ps_pid : p->p_tid);
+
+ if (*mode == 'n') {
+ db_printf("%c%5d ", (p == curproc ?
+ '*' : ' '), pr->ps_pid);
+ } else {
+ db_printf("%c%6d ", (p == curproc ?
+ '*' : ' '), p->p_tid);
+ }
switch (*mode) {
@@ -508,9 +514,9 @@ db_show_all_procs(db_expr_t addr, int ha
break;
case 'n':
- db_printf("%5d %5d %5d %d %#10x "
- "%-12.12s %-16s\n",
- ppr ? ppr->ps_pid : -1,
+ db_printf("%6d %5d %5d %5d %d "
+ "%#10x %-12.12s %-16s\n",
+ p->p_tid, ppr ? ppr->ps_pid : -1,
pr->ps_pgrp ? pr->ps_pgrp->pg_id :
-1,
pr->ps_ucred->cr_ruid, p->p_stat,
p->p_flag | pr->ps_flags,
Index: share/man/man4/ddb.4
===================================================================
RCS file: /cvs/src/share/man/man4/ddb.4,v
retrieving revision 1.82
diff -u -p -r1.82 ddb.4
--- share/man/man4/ddb.4 1 Sep 2016 12:24:56 -0000 1.82
+++ share/man/man4/ddb.4 23 Jan 2017 23:38:09 -0000
@@ -542,7 +542,7 @@ The
.Cm /p
modifier interprets the
.Ar frameaddr
-argument as the PID of a process and shows the stack trace of
+argument as the TID of a process and shows the stack trace of
that process.
The
.Cm /p
@@ -832,7 +832,7 @@ Display information on all processes.
(Default) Show process information in a
.Xr ps 1 Ns \&-like
format.
-Information printed includes thread ID, parent
+Information printed includes process ID, thread ID, parent
process ID, process group, UID, process status, process flags, process
command name, and process wait channel message.
.It Cm /a
@@ -928,7 +928,7 @@ A synonym for the
.Ic show all callout
command.
.\" --------------------
-.It Ic ps Op Cm /anw
+.It Ic ps Op Cm /anow
A synonym for
.Ic show all procs .
.\" --------------------