svn commit: r227873 - head/usr.bin/procstat

Mikolaj Golub trociny at freebsd.org
Thu Nov 24 07:12:44 UTC 2011


On Wed, 23 Nov 2011 11:10:47 -0800 mdf at FreeBSD.org wrote:

 >>                        printf(" AT_IGNORE=0x%lu",
 >> -                           (unsigned long)aux->a_un.a_val);
 >> +                           (unsigned long)auxv[i].a_un.a_val);

 m> I didn't see this before, but this gives very misleading output.  The
 m> 0x prefix implies the output will be hex, but it's printed as decimal,
 m> here and below.

Oh. Thanks! Will fix.

 m> I don't know if there's a style preference for 0x%lx versus %#lx,
 m> though, or a preference for a different type for the print (uintmax_t,
 m> for example).  There is probably a preference for using u_long rather
 m> than unsigned long, since it's shorter.

It looks like both 0x%lx and %#lx are widely spread in our source, I like %#lx
a little more. It looks for me that (u_long) will be ok for now, so the chage
for the printf above would be:

printf(" AT_IGNORE=%#lx", (u_long)auxv[i].a_un.a_val);

Anyway, printing all values in the same format was considered by me as a
temporary solution. I am going to have format depending on a_type, so e.g.
AT_PAGESZ will be 4096, not 0x1000.

Also, now they are printed as one string for a process:

  PID COMM             AUXV
 2520 firefox-bin      AT_PHDR=0x400040 AT_PHENT=0x38 AT_PHNUM=0x7 AT_PAGESZ=0x1000 ...

I am considering changing this too, to something like below:

  PID COMM             AUXV        VALUE
 2520 firefox-bin      AT_PHDR     0x400040
 2520 firefox-bin      AT_PHENT    56
 2520 firefox-bin      AT_PHNUM    7
...

-- 
Mikolaj Golub


More information about the svn-src-all mailing list