History log of /freebsd-head/lib/libsysdecode/flags.c
Revision Date Author Comments
4e7f425fc9957becb7f3db56f0d7be9455d0c54f 19-Feb-2020 dim <dim@FreeBSD.org> Merge ^/head r358075 through r358130.
66a791667c93978f89cd93b2e2f0dcb31d489c92 19-Feb-2020 kevans <kevans@FreeBSD.org> libsysdecode: grab shmflags from sys/mman.h, add decode method

Any SHM_* flag here is (and likely will continue to be) a shmflag that may
be passed to shm_open2(), with exception to SHM_ANON. This is a prereq to
adding appropriate support to truss/kdump.

Reviewed by: kaktus (slightly earlier version)
Differential Revision: https://reviews.freebsd.org/D23733
613101d06e3ac07b954733b864c88c91c00e4845 30-Sep-2019 kaktus <kaktus@FreeBSD.org> libsysdecode: decode PROT_MAX flags

Extend libsysdecode to pretty-print PROT_MAX flags and fix decoding of regular protection flags broken since r349240.

mmap(0x0,40960,0x30000,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 34366234624 (0x800632000)
11439 protmax CALL mmap(0,0xa000,0x30000<><invalid>196608,0x21002<MAP_PRIVATE|MAP_ANON|MAP_NOCORE>,0xffffffff,0)

mmap(0x0,40960,PROT_MAX(PROT_READ|PROT_WRITE)|PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_NOCORE,-1,0x0) = 34366234624 (0x800632000)
11439 protmax CALL mmap(0,0xa000,0x30000<PROT_MAX(PROT_READ|PROT_WRITE)|PROT_READ|PROT_WRITE>,0x21002<MAP_PRIVATE|MAP_ANON|MAP_NOCORE>,0xffffffff,0)

Reviewed by: kib (mentor)
Approved by: kib (mentor)
Differential Revision: https://reviews.freebsd.org/D21706
9c6508ad9d1567f761830d8a9b2f420b5964027f 05-Feb-2019 dim <dim@FreeBSD.org> Merge ^/head r343712 through r343806.
c3a5a53eb872996b2e456ce78cdbf95c1d7909fb 04-Feb-2019 tuexen <tuexen@FreeBSD.org> Add missing SCTP_EOR entry.

MFC after: 3 days
9db463347151d8955a9d58ec0d62535906947a69 15-Jan-2018 tuexen <tuexen@FreeBSD.org> Add support for decoding the nxt_flags, rcv_flags, and snd_flags of
SCTP level cmsgs.
aab0289ab1e1680ac2abeee8477c3e97f43ce1d4 15-Jan-2018 tuexen <tuexen@FreeBSD.org> Add support for decoding the type of a cmsg.
dc1ea661c79a876985c0680fb5106f731164e051 14-Jan-2018 tuexen <tuexen@FreeBSD.org> Add a function is decode the sinfo_flags of struct sctp_sndrcvinfo.
5c419e6ba67c099eea625e9a7509265916fe7657 14-Jan-2018 tuexen <tuexen@FreeBSD.org> Add suppor for the supported PR-SCTP policies.
bac78aa2a49020f1e67b0d1b05e5daf2213879ae 25-Nov-2017 jhb <jhb@FreeBSD.org> Decode kevent structures logged via ktrace(2) in kdump.

- Add a new KTR_STRUCT_ARRAY ktrace record type which dumps an array of

The structure name in the record payload is preceded by a size_t
containing the size of the individual structures. Use this to
replace the previous code that dumped the kevent arrays dumped for
kevent(). kdump is now able to decode the kevent structures rather
than dumping their contents via a hexdump.

One change from before is that the 'changes' and 'events' arrays are
not marked with separate 'read' and 'write' annotations in kdump
output. Instead, the first array is the 'changes' array, and the
second array (only present if kevent doesn't fail with an error) is
the 'events' array. For kevent(), empty arrays are denoted by an
entry with an array containing zero entries rather than no record.

- Move kevent decoding tables from truss to libsysdecode.

This adds three new functions to decode members of struct kevent:
sysdecode_kevent_filter, sysdecode_kevent_flags, and

kdump uses these helper functions to pretty-print kevent fields.

- Move structure definitions for freebsd11 and freebsd32 kevent
structures to <sys/event.h> so that they can be shared with userland.
The 32-bit structures are only exposed if _WANT_KEVENT32 is defined.
The freebsd11 structures are only exposed if _WANT_FREEBSD11_KEVENT is
defined. The 32-bit freebsd11 structure requires both.

- Decode freebsd11 kevent structures in truss for the compat11.kevent()
system call.

- Log 32-bit kevent structures via ktrace for 32-bit compat kevent()
system calls.

- While here, constify the 'void *data' argument to ktrstruct().

Reviewed by: kib (earlier version)
MFC after: 1 month
Differential Revision: https://reviews.freebsd.org/D12470
ccb52dc3ef3076e40000a51cba89978beae827d5 07-Nov-2017 jhb <jhb@FreeBSD.org> Wrap to 80 columns. No functional change.
409e046ace92eabfbf861c01fec4b0351c2b0578 25-Oct-2017 imp <imp@FreeBSD.org> RB_POWERCYCLE needs to be handled like RB_POWEROFF for decoding.

Sponsored by: Netflix
007c856ab0914c7d9a223dda66f827a8b10dd6b0 17-Sep-2017 emaste <emaste@FreeBSD.org> libsysdecode: report invalid cap_rights_t

Previously we'd have an assertion failure in cap_rights_is_set if
sysdecode_cap_rights is called with an invalid cap_rights_t, so test for
validity first.

PR: 222258
Reviewed by: cem
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D12391
7735433fd2ccb5c0830fe81d129704dbf132b445 04-Sep-2017 jhb <jhb@FreeBSD.org> Decode pathconf() names, *at() flags, and sysarch() numbers in libsysdecode.

Move tables that were previously in truss over to libsysdecode. truss
output is unchanged, but kdump has been updated to decode these fields.
In addition, sysdecode_sysarch_number() should support all platforms
whereas the old table in truss only supported x86.
57cd391d21ff8ad805c6d7bd1fbc9d5b37943fe9 10-Jun-2017 jhb <jhb@FreeBSD.org> Improve decoding of RB_AUTOBOOT in the 'howto' argument to reboot().

The reboot() system call accepts a mode (RB_AUTOBOOT, RB_HALT, RB_POWEROFF,
or RB_REROOT) as well as zero or more optional flags in 'howto'.
However, RB_AUTOBOOT was only displayed if 'howto' was exactly 0.
Combinations like 'RB_AUTOBOOT | RB_DUMP' were decoded as 'RB_DUMP'.
Instead, imply that RB_AUTOBOOT was specified if none of the other "mode"
flags were specified.
838d4edd0a38d39d1c1edd8a2b03c5deaf6c8535 03-Jun-2017 dim <dim@FreeBSD.org> Merge ^/head r319480 through r319547.
48d2ad88bbdc6dc2db7ca4f9a2897bdd79463590 03-Jun-2017 jhb <jhb@FreeBSD.org> Decode the 'who' argument passed to getrusage().

Add a new sysdecode_getrusage_who() which decodes the RUSAGE_* constant
passed as the first argument to getrusage(). Use this function in both
kdump and truss to decode the first argument to getrusage().

PR: 215448
Submitted by: Anton Yuzhaninov <citrin+pr@citrin.ru>
MFC after: 1 month
a947803dbc3232b117b16e13465849d64f5f9ab0 25-May-2017 tuexen <tuexen@FreeBSD.org> Improve the decoding of the third argument of the socket() call.

Decoding of the third argument depends on the first one. For doing this,
add a corresponding function to libsysdecode.

Thanks to jhb@ for suggesting this.
89fb1dd8eadbb7b7a460dba98a32788c33f72b4a 04-May-2017 tuexen <tuexen@FreeBSD.org> Add support for socket option names related to the level IPPROTO_UDPLITE.
e222d355a05f2fa56287a33e785f427d46fdd945 03-May-2017 tuexen <tuexen@FreeBSD.org> Add support for socket option names related to the IPPROTO_IPV6 level.
59713b3e8cc22aee2336a10c12da4026b9624544 03-May-2017 tuexen <tuexen@FreeBSD.org> Add support for socket option names related to the IPPROTO_SCTP level.
a8429c675016730a11cea73afad8801086df9905 16-Mar-2017 smh <smh@FreeBSD.org> Fix libsysdecode vmprot flag decoding

Fix the regex used to find vmprot table entries and add the missing include.

This fixes kdumps output of PFLT arguments which would previously look like:
5202 101546 ktrace PFLT 0x5ae000 0x2<><invalid>2

They now display correctly:
5202 101546 ktrace PFLT 0x5ac000 0x2<VM_PROT_WRITE>

MFC after: 1 week
1d24ae662536652977bf21b89ce2d360549968db 14-Mar-2017 tobik <tobik@FreeBSD.org> Fix sysdecode_cap_rights which currently prints bogus capability rights

PR: 217787
Reviewed by: jhb, emaste
Approved by: jhb
c49d6e5b66c9f0116a49b9e2240482979c64a973 03-Jan-2017 jhb <jhb@FreeBSD.org> Update libsysdecode for getfsstat() 'flags' argument changing to 'mode'.

As a followup to r310638, update libsysdecode (and kdump) to decode the
'mode' argument to getfsstat(). sysdecode_getfsstat_flags() has been
renamed to sysdecode_getfsstat_mode() and now treats the argument as an
enumerated value rather than a mask of flags.
f57d15e36b0253e6742db0045de96885c56760c0 25-Oct-2016 jhb <jhb@FreeBSD.org> Use binary and (&) instead of logical to extract the mask of a capability.

CID: 1365227
Submitted by: cem
27ec61a4375f38949fd0636093b5d362ddd043a8 17-Oct-2016 jhb <jhb@FreeBSD.org> Move mksubr from kdump into libsysdecode.

Restructure this script so that it generates a header of tables instead
of a source file. The tables are included in a flags.c source file which
provides functions to decode various system call arguments.

For functions that decode an enumeration, the function returns a pointer
to a string for known values and NULL for unknown values.

For functions that do more complex decoding (typically of a bitmask), the
function accepts a pointer to a FILE object (open_memstream() can be used
as a string builder) to which decoded values are written. If the
function operates on a bitmask, the function returns true if any bits
were decoded or false if the entire value was valid. Additionally, the
third argument accepts a pointer to a value to which any undecoded bits
are stored. This pointer can be NULL if the caller doesn't care about
remaining bits.

Convert kdump over to using decoder functions from libsysdecode instead of
mksubr. truss also uses decoders from libsysdecode instead of private
lookup tables, though lookup tables for objects not decoded by kdump remain
in truss for now. Eventually most of these tables should move into
libsysdecode as the automated table generation approach from mksubr is
less stale than the static tables in truss.

Some changes have been made to truss and kdump output:
- The flags passed to open() are now properly decoded in that one of
O_RDONLY, O_RDWR, O_WRONLY, or O_EXEC is always included in a decoded
- Optional arguments to open(), openat(), and fcntl() are only printed
in kdump if they exist (e.g. the mode is only printed for open() if
O_CREAT is set in the flags).
- Print argument to F_GETLK/SETLK/SETLKW in kdump as a pointer, not int.
- Include all procctl() commands.
- Correctly decode pipe2() flags in truss by not assuming full
open()-like flags with O_RDONLY, etc.
- Decode file flags passed to *chflags() as file flags (UF_* and SF_*)
rather than as a file mode.
- Fix decoding of quotactl() commands by splitting out the two command
components instead of assuming the raw command value matches the
primary command component.

In addition, truss and kdump now build without triggering any warnings.
All of the sysdecode manpages now include the required headers in the

Reviewed by: kib (several older versions), wblock (manpages)
MFC after: 2 months
Differential Revision: https://reviews.freebsd.org/D7847