Page MenuHomeFreeBSD

Print arguments in ddb ps command
ClosedPublic

Authored by thu_panzura.com on Aug 6 2018, 8:29 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 8 2024, 7:40 AM
Unknown Object (File)
Mar 8 2024, 7:40 AM
Unknown Object (File)
Mar 8 2024, 7:40 AM
Unknown Object (File)
Mar 8 2024, 7:40 AM
Unknown Object (File)
Feb 17 2024, 11:36 AM
Unknown Object (File)
Dec 20 2023, 2:18 AM
Unknown Object (File)
Nov 28 2023, 3:13 AM
Unknown Object (File)
Nov 24 2023, 11:53 PM
Subscribers

Details

Summary

We use ps to collect the information of all processes in textdump. But it doesn't contain process arguments which however sometimes are very useful for debugging. Add the arguments in the diff.

Test Plan

Tested with the private build.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Please generate diff with whole context, use -U99999 arg to it (e.g. git diff -U99999 or svn diff -x -U9999999).

sys/ddb/db_ps.c
73 ↗(On Diff #46330)

p_args can be NULL.

74 ↗(On Diff #46330)

Put blank line after the declarations. Move initialization to the code block.

329 ↗(On Diff #46330)

No need for {}.

thu_panzura.com marked 3 inline comments as done.
This comment was removed by thu_panzura.com.
sys/ddb/db_ps.c
120 ↗(On Diff #46365)

I would write this as

ps_mode = modif[0] == 'a' ? PRINT_ARGS : PRINT_NONE;
239 ↗(On Diff #46365)

You do not need the check for != NULL there.

333 ↗(On Diff #46365)

... and there.

thu_panzura.com marked 3 inline comments as done.

Update the delta according to @kib 's comments

This revision is now accepted and ready to land.Aug 7 2018, 11:05 AM

I've just tested this and I see a couple of issues.

First, "ps /m" produces exactly the same output as plain "ps".
Not sure if 'm' was broken earlier or if this patch breaks it.

Then, I think that there is a missing space in the output of "ps /a":

db> ps /a
  pid  ppid  pgrp   uid  state   wmesg   wchan               cmd
  698     1   698     0  Ss+     ttyin   0xfffff800050184b0  getty/usr/libexec/getty 3wire ttyu0
  697     1   697     0  Ss+     ttyin   0xfffff800050164b0  getty/usr/libexec/getty Pc ttyv7
  696     1   696     0  Ss+     ttyin   0xfffff800050168b0  getty/usr/libexec/getty Pc ttyv6
  695     1   695     0  Ss+     ttyin   0xfffff80005016cb0  getty/usr/libexec/getty Pc ttyv5
  694     1   694     0  Ss+     ttyin   0xfffff800050170b0  getty/usr/libexec/getty Pc ttyv4
  693     1   693     0  Ss+     ttyin   0xfffff800050174b0  getty/usr/libexec/getty Pc ttyv3
  692     1   692     0  Ss+     ttyin   0xfffff800050178b0  getty/usr/libexec/getty Pc ttyv2
  691     1   691     0  Ss+     ttyin   0xfffff80005017cb0  getty/usr/libexec/getty Pc ttyv1
  690     1   690     0  Ss+     ttyin   0xfffff800050180b0  getty/usr/libexec/getty Pc ttyv0
  685   683    24     0  S+      nanslp  0xffffffff81df8671  sleepsleep 60
  684     1    24     0  S+      piperd  0xfffff80005c76000  loggerlogger -p daemon.notice -t fsck
  683     1    24     0  S+      wait    0xfffff80005d1c000  shsh /etc/rc autoboot
  639     1   639     0  Ss      nanslp  0xffffffff81df8670  cron/usr/sbin/cron -s
  635     1   635    25  Ss      pause   0xfffff80038243af8  sendmailsendmail: Queue runner@00:30:00 for /var/spool/clientmqueue
  632     1   632     0  Ss      select  0xfffff80005ea30c0  sendmailsendmail: accepting connections
  629     1   629     0  Ss      select  0xfffff800058039c0  sshd/usr/sbin/sshd
  602     1   602     0  Ss      select  0xfffff80005803a40  zfsd/usr/sbin/zfsd
...

Thanks @avg. I missed a space between the process name and the args. I will update the diff. It will look like

 4953     1  4953     0  Ss      rpcsvc  0xfffff8013fea9860  NLM: master /usr/sbin/rpc.lockd -p 32803
 4797     1  4797     0  Ss      nanslp  0xffffffff810d6ef2  cron /usr/sbin/cron -m  -s
 4783     1  4783     0  Ss      select  0xfffff80085a762c0  rpc.statd /usr/sbin/rpc.statd -p 662
 4659     1    27     0  S       wait    0xfffff801843b2538  bash /bin/bash /opt/pixel8/bin/monitor_master_ssh.sh
 4585   992    27     0  S       (threaded)                  replock-samba /opt/pixel8/bin/replock run
101918                   S       uwait   0xfffff801a52b4d00  replock-samba
101925                   S       uwait   0xfffff80085416e00  replock-samba
101926                   S       uwait   0xfffff8013f37e680  replock-samba

Update the diff. Add a space to split the process and args.

This revision now requires review to proceed.Aug 9 2018, 10:05 AM

Terry, thank you!

I see that 'm' was documented since the first version of the ddb.4 manual page, but I do not see any evidence that there ever was any actual support for it in the code.
I think it's a good time to remove that option from the manual.

Remove "m" option from manpage. I can't find out since when it was missing in git log as well.

This revision is now accepted and ready to land.Aug 9 2018, 11:12 AM
This revision was automatically updated to reflect the committed changes.