Page MenuHomeFreeBSD

make truss decode sysctl names
ClosedPublic

Authored by kaktus on Sep 17 2019, 1:56 PM.

Details

Summary

It'd be nice to actually see the sysctl names not the pointers to arrays in truss.

Depends on D21693

Test Plan

truss w

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

kaktus created this revision.Sep 17 2019, 1:56 PM
kib added inline comments.Sep 17 2019, 2:37 PM
usr.bin/truss/syscalls.c
2290

Are these available as symbolic constrants ? No, it seems.

Then it is time to add them to sys/sysctl.h and get rid of the numbers in the definition of sysctls from kern_sysctl.c and e.g. libc sysctlnametonib.

2318

spaces around '*'

alfix86_gmail.com added inline comments.
usr.bin/truss/syscalls.c
2279

just a note: int oid[CTL_MAXNAME] is correct (an OID can have CTL_MAXNAME levels in the kernel) but it is useless because the "undocumented interface" can handle up to "CTL__MAXNAME - 2" levels (except 0.3 name2oid), CTL_MAXNAME + 2 for qoid does not solve (unfortunately this false solution is quite widespread)

2294

I would wait to document the magical nodes yet, https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=240390

2320

here the problem (from the comment above), len + 2 could be 26 > CTL_MAXNAME

I apologize, I wrote some off-topic remark not important in this review (please don't consider them),
thanks to add the sysctl name support to truss.

kaktus updated this revision to Diff 62241.Sep 17 2019, 10:57 PM

Use constants defined in D21693.

kaktus edited the summary of this revision. (Show Details)Sep 17 2019, 11:00 PM
kaktus added inline comments.
usr.bin/truss/syscalls.c
2279

I couldn't find any obvious CTL_MAXNAME - 2 (apart of libjail, TBC) so if there is a truncation, it's probably because one of the in-kernel functions doesn't use CTL_MAXNAME + 2. I'll take a look at this but it's out of scope for this review anyway.

2294

I matched the names with the names functions responsible as used by kern/kern_sysctl.c Hope that helps.

kib added inline comments.Sep 18 2019, 6:37 AM
usr.bin/truss/syscalls.c
2279

Spaces around '+'.

2294

I suggest to print the rest of the input mib in numeric format.

2312

print numeric value as well

2322

Why not print the mib in <num>.<num>... format, esp. since you already fetched it ? The pointer as useless as it can be.

kaktus updated this revision to Diff 62259.Sep 18 2019, 8:34 AM
kaktus edited the summary of this revision. (Show Details)

Address @kib comments.

kib added inline comments.Sep 18 2019, 10:22 AM
usr.bin/truss/syscalls.c
515

The types of the second and fifth args are size_t, not int. It practically matters on 64bit big-endian hosts.

2296

Spaces around '+' and '-', there and till the end of the chunk.

kaktus updated this revision to Diff 62263.Sep 18 2019, 11:25 AM

Style and s/Int/Sizet/ where appropriate.

kib accepted this revision.Sep 18 2019, 2:06 PM
This revision is now accepted and ready to land.Sep 18 2019, 2:06 PM
This revision was automatically updated to reflect the committed changes.