Re: Help for ddb(4)'s "tr /p"

2017-01-23 Thread Philip Guenther
On Tue, 24 Jan 2017, Martin Pieuchot wrote:
> Diff below does that and fix alignment issues with /a /o and /w.  The
> problem was that TID needs 6 columns not 5.
> 
> With this ps /a no longer wraps on i386.
> 
> ddb{0}> ps /a
> TID  COMMAND STRUCT PROC * UAREA *  VMSPACE/VM_MAP
> * 70709  sysctl 0xd94e9418  0xf551c000  0xd94e7144
>  154620  ksh0xd94e9c28  0xf5544000  0xd94e7324
>  278101  cron   0xd94e9820  0xf557c000  0xd94e7004
> 
> ok?

Looks good.  ok guenther@



Re: Help for ddb(4)'s "tr /p"

2017-01-23 Thread Martin Pieuchot
On 24/01/17(Tue) 11:35, Philip Guenther wrote:
> On Tue, 24 Jan 2017, Martin Pieuchot wrote:
> > On 24/01/17(Tue) 10:08, Philip Guenther wrote:
> ...
> > > 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   PPIDUID  S   FLAGS  WAIT  COMMAND
> > *97567  517976  11478  0  7 0x3sysctl
> >  11478  302289  1  0  30x10008b  pause ksh
> >  68659  470461  1  0  30x100098  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?
> 
> Just s/EMUL/PGID/ and wait for someone to need something more?

Diff below does that and fix alignment issues with /a /o and /w.  The
problem was that TID needs 6 columns not 5.

With this ps /a no longer wraps on i386.

ddb{0}> ps /a
TID  COMMAND STRUCT PROC * UAREA *  VMSPACE/VM_MAP
* 70709  sysctl 0xd94e9418  0xf551c000  0xd94e7144
 154620  ksh0xd94e9c28  0xf5544000  0xd94e7324
 278101  cron   0xd94e9820  0xf557c000  0xd94e7004

ok?

Index: sys/kern/kern_proc.c
===
RCS file: /cvs/src/sys/kern/kern_proc.c,v
retrieving revision 1.74
diff -u -p -r1.74 kern_proc.c
--- sys/kern/kern_proc.c24 Jan 2017 04:50:48 -  1.74
+++ sys/kern/kern_proc.c24 Jan 2017 05:03:38 -
@@ -467,7 +467,7 @@ db_show_all_procs(db_expr_t addr, int ha
switch (*mode) {
 
case 'a':
-   db_printf("   TID  %-10s  %18s  %18s  %18s\n",
+   db_printf("TID  %-9s  %18s  %18s  %18s\n",
"COMMAND", "STRUCT PROC *", "UAREA *", "VMSPACE/VM_MAP");
break;
case 'n':
@@ -475,12 +475,12 @@ db_show_all_procs(db_expr_t addr, int ha
"TID", "PPID", "UID", "FLAGS", "WAIT", "COMMAND");
break;
case 'w':
-   db_printf("   TID  %-16s  %-8s  %18s  %s\n",
-   "COMMAND", "EMUL", "WAIT-CHANNEL", "WAIT-MSG");
+   db_printf("TID  %-15s  %-5s  %18s  %s\n",
+   "COMMAND", "PGRP", "WAIT-CHANNEL", "WAIT-MSG");
break;
case 'o':
skipzomb = 1;
-   db_printf("   TID  %5s  %5s  %10s %10s  %3s  %-31s\n",
+   db_printf("TID  %5s  %5s  %10s %10s  %3s  %-30s\n",
"PID", "UID", "PRFLAGS", "PFLAGS", "CPU", "COMMAND");
break;
}
@@ -509,7 +509,7 @@ db_show_all_procs(db_expr_t addr, int ha
switch (*mode) {
 
case 'a':
-   db_printf("%-10.10s  %18p  %18p  
%18p\n",
+   db_printf("%-9.9s  %18p  %18p  %18p\n",
pr->ps_comm, p, p->p_addr, 
p->p_vmspace);
break;
 
@@ -524,9 +524,11 @@ db_show_all_procs(db_expr_t addr, int ha
break;
 
case 'w':
-   db_printf("%-16s  %-8s  %18p  %s\n", 
pr->ps_comm,
-   pr->ps_emul->e_name, p->p_wchan,
-   (p->p_wchan && p->p_wmesg) ? 
+   db_printf("%-15s  %-5d  %18p  %s\n",
+   pr->ps_comm, (pr->ps_pgrp ?
+   pr->ps_pgrp->pg_id : -1),
+   p->p_wchan,
+   (p->p_wchan && p->p_wmesg) ?
p->p_wmesg : "");
break;
 
Index: share/man/man4/ddb.4
===
RCS file: /cvs/src/share/man/man4/ddb.4,v
retrieving revision 1.84
diff -u -p -r1.84 ddb.4
--- share/man/man4/ddb.424 Jan 2017 04:50:48 -  1.84
+++ share/man/man4/ddb.424 Jan 2017 05:03:38 -
@@ -849,7 +849,7 @@ Shows non-idle threads that were on CPU 
 Information printed includes thread ID, process ID, UID, process flags,
 thread flags, current CPU, and command name.
 .It Cm /w
-Shows each thread's ID, command, system call emulation,
+Shows each thread's ID, command, process group,
 wait channel address, and wait channel message.
 .El
 .\" 



Re: Help for ddb(4)'s "tr /p"

2017-01-23 Thread Philip Guenther
On Tue, 24 Jan 2017, Martin Pieuchot wrote:
> On 24/01/17(Tue) 10:08, Philip Guenther wrote:
...
> > 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   PPIDUID  S   FLAGS  WAIT  COMMAND
> *97567  517976  11478  0  7 0x3sysctl
>  11478  302289  1  0  30x10008b  pause ksh
>  68659  470461  1  0  30x100098  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?

Just s/EMUL/PGID/ and wait for someone to need something more?


> ok for the diff below?

Almost

> 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 -  1.73
> +++ sys/kern/kern_proc.c  24 Jan 2017 01:36:05 -
> @@ -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");

TID is %6s instead of %5s, so should change %-16s to %-15s for COMMAND, 
both here and...

>   case 'n':
> - db_printf("%5d  %5d  %5d  %d  %#10x  "
> + db_printf("%6d  %5d  %5d  %d  %#10x  "
>   "%-12.12s  %-16s\n",

here.



Re: Help for ddb(4)'s "tr /p"

2017-01-23 Thread Martin Pieuchot
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   PPIDUID  S   FLAGS  WAIT  COMMAND
*97567  517976  11478  0  7 0x3sysctl
 11478  302289  1  0  30x10008b  pause ksh
 68659  470461  1  0  30x100098  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.c24 Jan 2017 00:58:55 -  1.73
+++ sys/kern/kern_proc.c24 Jan 2017 01:36:05 -
@@ -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.424 Jan 2017 01:01:33 -  1.83
+++ share/man/man4/ddb.424 Jan 2017 01:45:48 -
@@ -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.



Re: Help for ddb(4)'s "tr /p"

2017-01-23 Thread Philip Guenther
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?


> Here's the difference:
> 
> Before:
>PID   PPID   PGRPUID  S   FLAGS  WAIT  COMMAND
> *50672  7  50672  0  7 0x3sysctl
>  7  1  7  0  30x10008b  pause ksh
>  90555  1  90555  0  30x100098  poll  cron
> 
> After:
>PID TID   PPID   PGRPUID  S   FLAGS  WAIT  COMMAND
> *52636  496486  51956  52636  0  7 0x3sysctl
>  51956  407679  1  51956  0  30x10008b  pause ksh
>  42726  321266  1  42726  0  30x100098  poll  cron
> 
> ok?

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 ?


The outer two chunks here are clearly correct, regardless of how we
bikeshed ps:

> --- share/man/man4/ddb.4  1 Sep 2016 12:24:56 -   1.82
> +++ share/man/man4/ddb.4  23 Jan 2017 23:38:09 -
> @@ -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
...
> @@ -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 .
>  .\" 
> 
>