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 mask. - 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 synopsis. Reviewed by: kib (several older versions), wblock (manpages) MFC after: 2 months Differential Revision: https://reviews.freebsd.org/D7847
123 lines
4.1 KiB
Makefile
123 lines
4.1 KiB
Makefile
# $FreeBSD$
|
|
|
|
.include <src.opts.mk>
|
|
|
|
PACKAGE=lib${LIB}
|
|
LIB= sysdecode
|
|
|
|
SRCS= errno.c flags.c ioctl.c signal.c syscallnames.c utrace.c
|
|
INCS= sysdecode.h
|
|
|
|
CFLAGS+= -I${.OBJDIR}
|
|
CFLAGS+= -I${.CURDIR}/../../sys
|
|
CFLAGS+= -I${.CURDIR}/../../libexec/rtld-elf
|
|
|
|
MAN= sysdecode.3 \
|
|
sysdecode_abi_to_freebsd_errno.3 \
|
|
sysdecode_cap_rights.3 \
|
|
sysdecode_enum.3 \
|
|
sysdecode_fcntl_arg.3 \
|
|
sysdecode_ioctlname.3 \
|
|
sysdecode_mask.3 \
|
|
sysdecode_quotactl_cmd.3 \
|
|
sysdecode_sigcode.3 \
|
|
sysdecode_sockopt_name.3 \
|
|
sysdecode_syscallnames.3 \
|
|
sysdecode_utrace.3
|
|
MLINKS= sysdecode_abi_to_freebsd_errno.3 sysdecode_freebsd_to_abi_errno.3
|
|
MLINKS+=sysdecode_enum.3 sysdecode_acltype.3 \
|
|
sysdecode_enum.3 sysdecode_atfd.3 \
|
|
sysdecode_enum.3 sysdecode_extattrnamespace.3 \
|
|
sysdecode_enum.3 sysdecode_fadvice.3 \
|
|
sysdecode_enum.3 sysdecode_fcntl_cmd.3 \
|
|
sysdecode_enum.3 sysdecode_idtype.3 \
|
|
sysdecode_enum.3 sysdecode_ipproto.3 \
|
|
sysdecode_enum.3 sysdecode_kldsym_cmd.3 \
|
|
sysdecode_enum.3 sysdecode_kldunload_flags.3 \
|
|
sysdecode_enum.3 sysdecode_lio_listio_mode.3 \
|
|
sysdecode_enum.3 sysdecode_madvice.3 \
|
|
sysdecode_enum.3 sysdecode_minherit_flags.3 \
|
|
sysdecode_enum.3 sysdecode_msgctl_cmd.3 \
|
|
sysdecode_enum.3 sysdecode_nfssvc_flags.3 \
|
|
sysdecode_enum.3 sysdecode_prio_which.3 \
|
|
sysdecode_enum.3 sysdecode_procctl_cmd.3 \
|
|
sysdecode_enum.3 sysdecode_ptrace_request.3 \
|
|
sysdecode_enum.3 sysdecode_rlimit.3 \
|
|
sysdecode_enum.3 sysdecode_rtprio_function.3 \
|
|
sysdecode_enum.3 sysdecode_scheduler_policy.3 \
|
|
sysdecode_enum.3 sysdecode_semctl_cmd.3 \
|
|
sysdecode_enum.3 sysdecode_shmctl_cmd.3 \
|
|
sysdecode_enum.3 sysdecode_shutdown_how.3 \
|
|
sysdecode_enum.3 sysdecode_sigbus_code.3 \
|
|
sysdecode_enum.3 sysdecode_sigchld_code.3 \
|
|
sysdecode_enum.3 sysdecode_sigfpe_code.3 \
|
|
sysdecode_enum.3 sysdecode_sigill_code.3 \
|
|
sysdecode_enum.3 sysdecode_signal.3 \
|
|
sysdecode_enum.3 sysdecode_sigprocmask_how.3 \
|
|
sysdecode_enum.3 sysdecode_sigsegv_code.3 \
|
|
sysdecode_enum.3 sysdecode_sigtrap_code.3 \
|
|
sysdecode_enum.3 sysdecode_sockaddr_family.3 \
|
|
sysdecode_enum.3 sysdecode_socketdomain.3 \
|
|
sysdecode_enum.3 sysdecode_sockettype.3 \
|
|
sysdecode_enum.3 sysdecode_sockopt_level.3 \
|
|
sysdecode_enum.3 sysdecode_umtx_op.3 \
|
|
sysdecode_enum.3 sysdecode_vmresult.3 \
|
|
sysdecode_enum.3 sysdecode_whence.3
|
|
MLINKS+=sysdecode_fcntl_arg.3 sysdecode_fcntl_arg_p.3
|
|
MLINKS+=sysdecode_mask.3 sysdecode_accessmode.3 \
|
|
sysdecode_mask.3 sysdecode_capfcntlrights.3 \
|
|
sysdecode_mask.3 sysdecode_fcntl_fileflags.3 \
|
|
sysdecode_mask.3 sysdecode_fileflags.3 \
|
|
sysdecode_mask.3 sysdecode_filemode.3 \
|
|
sysdecode_mask.3 sysdecode_flock_operation.3 \
|
|
sysdecode_mask.3 sysdecode_getfsstat_flags.3 \
|
|
sysdecode_mask.3 sysdecode_mlockall_flags.3 \
|
|
sysdecode_mask.3 sysdecode_mmap_flags.3 \
|
|
sysdecode_mask.3 sysdecode_mmap_prot.3 \
|
|
sysdecode_mask.3 sysdecode_mount_flags.3 \
|
|
sysdecode_mask.3 sysdecode_msg_flags.3 \
|
|
sysdecode_mask.3 sysdecode_msync_flags.3 \
|
|
sysdecode_mask.3 sysdecode_open_flags.3 \
|
|
sysdecode_mask.3 sysdecode_pipe2_flags.3 \
|
|
sysdecode_mask.3 sysdecode_reboot_howto.3 \
|
|
sysdecode_mask.3 sysdecode_rfork_flags.3 \
|
|
sysdecode_mask.3 sysdecode_semget_flags.3 \
|
|
sysdecode_mask.3 sysdecode_sendfile_flags.3 \
|
|
sysdecode_mask.3 sysdecode_shmat_flags.3 \
|
|
sysdecode_mask.3 sysdecode_socket_type.3 \
|
|
sysdecode_mask.3 sysdecode_thr_create_flags.3 \
|
|
sysdecode_mask.3 sysdecode_umtx_cvwait_flags.3 \
|
|
sysdecode_mask.3 sysdecode_umtx_rwlock_flags.3 \
|
|
sysdecode_mask.3 sysdecode_vmprot.3 \
|
|
sysdecode_mask.3 sysdecode_wait4_options.3 \
|
|
sysdecode_mask.3 sysdecode_wait6_options.3
|
|
|
|
CLEANFILES= ioctl.c tables.h
|
|
|
|
.if defined(COMPAT_32BIT)
|
|
CPP+= -m32
|
|
.endif
|
|
|
|
.if ${MK_PF} != "no"
|
|
CFLAGS+=-DPF
|
|
.endif
|
|
|
|
# Workaround duplicate declarations in <netinet/ip_compat.h>
|
|
CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls
|
|
|
|
# Workaround warning for unused ssi_cables[] in <dev/lmc/if_lmc.h>
|
|
CFLAGS.gcc.ioctl.c+= -Wno-unused
|
|
|
|
CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}}
|
|
|
|
tables.h: mktables
|
|
sh ${.CURDIR}/mktables ${DESTDIR}${INCLUDEDIR} > ${.TARGET}
|
|
|
|
ioctl.c: mkioctls
|
|
env MACHINE=${MACHINE} CPP="${CPP}" \
|
|
/bin/sh ${.CURDIR}/mkioctls ${DESTDIR}${INCLUDEDIR} > ${.TARGET}
|
|
|
|
beforedepend: ioctl.c tables.h
|
|
|
|
.include <bsd.lib.mk>
|