On 24/01/17(Tue) 10:08, Philip Guenther wrote:
> On Tue, 24 Jan 2017, Martin Pieuchot wrote:
> > 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"
> 
> You mean "tr /p", right?

I do :)

> Hmm, ps/n (the default) is the only of the ps subcommands to not show the 
> TID...so that it can show more columns of COMMAND.  You've added 8 columns 
> without shrinking any of the existing ones, which will cause an unreadable 
> mess when it wraps around.  Maybe drop PGRP from /n and we add a new one 
> that's more like (userspace) ps -j ?

Here's the updated output.

   PID     TID   PPID    UID  S       FLAGS  WAIT          COMMAND
*97567  517976  11478      0  7         0x3                sysctl
 11478  302289      1      0  3    0x10008b  pause         ksh
 68659  470461      1      0  3    0x100098  poll          cron


I like the idea of "ps /j", I could also merge the information in the
current "ps /w" since EMUL is always 'native' now.  What do you think?

ok for the diff below?

Index: sys/kern/kern_proc.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_proc.c,v
retrieving revision 1.73
diff -u -p -r1.73 kern_proc.c
--- sys/kern/kern_proc.c        24 Jan 2017 00:58:55 -0000      1.73
+++ sys/kern/kern_proc.c        24 Jan 2017 01:36:05 -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  S  %10s  %-12s  %-16s\n",
+                   "TID", "PPID", "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,10 +514,9 @@ db_show_all_procs(db_expr_t addr, int ha
                                        break;
 
                                case 'n':
-                                       db_printf("%5d  %5d  %5d  %d  %#10x  "
+                                       db_printf("%6d  %5d  %5d  %d  %#10x  "
                                            "%-12.12s  %-16s\n",
-                                           ppr ? ppr->ps_pid : -1,
-                                           pr->ps_pgrp ? pr->ps_pgrp->pg_id : 
-1,
+                                           p->p_tid, ppr ? ppr->ps_pid : -1,
                                            pr->ps_ucred->cr_ruid, p->p_stat,
                                            p->p_flag | pr->ps_flags,
                                            (p->p_wchan && p->p_wmesg) ?
Index: share/man/man4/ddb.4
===================================================================
RCS file: /cvs/src/share/man/man4/ddb.4,v
retrieving revision 1.83
diff -u -p -r1.83 ddb.4
--- share/man/man4/ddb.4        24 Jan 2017 01:01:33 -0000      1.83
+++ share/man/man4/ddb.4        24 Jan 2017 01:45:48 -0000
@@ -833,8 +833,8 @@ Display information on all processes.
 .Xr ps 1 Ns \&-like
 format.
 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.
+process ID, UID, process status, process flags, process
+wait channel message and process command name.
 .It Cm /a
 Shows the kernel virtual addresses of each process'
 proc structure, u-area, and vmspace structure.

Reply via email to