summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump
Commit message (Collapse)AuthorAgeFilesLines
* MFC 326184: Decode kevent structures logged via ktrace(2) in kdump.jhb2018-01-261-0/+108
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Add a new KTR_STRUCT_ARRAY ktrace record type which dumps an array of structures. 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 sysdecode_kevent_fflags. 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(). Note that this version of the change for 11.x does not include freebsd11 kevent structures or _WANT_FREEBSD11_KEVENT. It also does not include the change to decode the compat11.kevent system call in truss.
* MFC 319493,319509,319520,319595,319677,319679-319681,319688,319689,jhb2017-11-211-2/+55
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 319761-319768,320010,322899,322959,323020,323021,323151: Sync libsysdecode, kdump, and truss with head (aside from changes such as ino64 that are not applicable to 11). 319493: Decode the arguments passed to __cap_rights_get() and cap_rights_limit(). 319509: Decode the argument passed to cap_getmode(). The returned integer value is output. 319520: 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(). 319595: Decode arguments to dup, dup2, getdirentries, pread, and pwrite. - dup and dup2 print fd arguments in decimal. - pread and pwrite are similar to read and write with the addition of the file offset. - getdirentries displays the output entries as a string for now and also prints the value returned in *basep. Eventually the buffer for getdirentries should perhaps be decoded as an array of dirent structures. 319677: Decode arguments to ACL related system calls. This only decodes the raw arguments but not the contents of the struct acl objects. 319679: Decode arguments passed to extended attribute related system calls. The cmd argument passed to extattrctl() is not decoded as a string constant but is just printed in hex. The value is filesystem-specific but in practice is only used with UFS1 filesystems. 319680: Decode arguments to minherit(). 319681: Decode arguments to mlock(), mlockall(), and munlock(). 319688: Decode flags passed to mount(), nmount(), and unmount(). 319689: Decode arguments passed to msync(). 319761: Fix decoding of setpriority() arguments. The PRIO_* 'which' value is stored in the first argument to setpriority(2), not the last. While here, decode the arguments to getpriority(2). 319762: Decode arguments to getpriority() and setpriority(). 319763: Decode the arguments to ptrace(). This does not decode structures returned by ptrace(). 319764: Decode the arguments to quotactl(). 319765: 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. 319766: Decode the 'howto' argument to reboot(). 319767: Decode arguments to rtprio_thread() (same as rtprio()). 319768: Decode arguments to rtprio() and rtprio_thread(). 320010: Decode arguments to sched_* family of system calls. This includes decoding both scheduler policy constants and the sched_param structure for sched_get_priority_max(), sched_get_priority_min(), sched_getparam(), sched_getscheduler(), sched_rr_get_interval(), sched_setparam(), and sched_setscheduler(). 322899: Decode arguments passed to thr_set_name(). 322959: Decode extra signal information for caught signals. Decode fields from the siginfo_t stored in the PT_LWPINFO structure when a signal is caught by a traced process. This includes the signal code (si_code) as well as additional members such as si_addr, si_pid, etc. 323020: Trim stale prototype for ioctlname(). 323021: Decode signal information returned by system calls. Specifically, decode the siginfo structure returned by sigtimedwait(), sigwaitinfo(), and wait6(). While here, also decode the signal number returned in the second argument to sigwait(). 323151: 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. PR: 214885, 215448
* MFC r315170:ngie2017-05-301-2/+2
| | | | | | | | | | | r315170 (by imp): Adopt SRCTOP in usr.bin Prefer ${SRCTOP}/foo over ${.CURDIR}/../../foo and ${SRCTOP}/usr.bin/foo over ${.CURDIR}/../foo for paths in Makefiles. Silence on: arch@ (twice)
* MFC 315334: Decode arguments to chflagsat().jhb2017-05-241-0/+2
|
* MFC 303946:jhb2017-01-122-22/+0
| | | | Remove files unused after pulling system call names from libsysdecode.
* MFC 307538,307948,308602,308603,311151: Move kdump's mksubr into libsysdecode.jhb2017-01-123-894/+294
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 307538: 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 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. 307948: Use binary and (&) instead of logical to extract the mask of a capability. 308602: Generate and use a proper .depend file for tables.h. 308603: Move libsysdecode-specific hack out of buildworld. This should fix the lib32 build since it was not removing the generated ioctl.c. This file is generated by a find(1) call, so cannot use normal dependency tracking methods. 311151: 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.
* MFC 306565,306566: Use timercmp() and timersub() in kdump.jhb2017-01-091-16/+11
| | | | | | | | | | | | | | | | | | 306565: Use timercmp() and timersub() in kdump. Previously, kdump used the kernel-only timervalsub() macro which required defining _KERNEL when including <sys/time.h>. Now, kdump uses the existing userland API. The timercmp() usage to check for a backwards timestamp is also clearer and simpler than the previous code which checked the result of the subtraction for a negative value. While here, take advantage of the 3-arg timersub() to store the subtraction results in a tempory timeval instead of overwriting the timestamp in the ktrace record and then having to restore it. 306566: Don't declare the 'temp' timeval as static.
* MFC 306564: Expose kernel-only errno values if _WANT_KERNEL_ERRNO is defined.jhb2017-01-091-4/+1
| | | | | | | | | | | The kernel uses a few negative errno values for internal conditions such as requesting a system call restart. Normally these errno values are not exposed to userland. However, kdump needs access to these values as some of then can be present in a ktrace system call return record. Previously kdump was defining _KERNEL to gain access to ehse values, but was then having to manually declare 'errno' (and doing it incorrectly). Now, kdump uses _WANT_KERNEL_ERRNO instead of _KERNEL and uses the system-provided declaration of errno.
* MFC 306563: Decode arguments to truncate and ftruncate.jhb2017-01-071-0/+6
| | | | | In particular, decode the off_t argument as a 64-bit argument to fix decoding for 32-bit processes.
* MFC 306562: Handle 64-bit system call arguments (off_t, id_t).jhb2017-01-061-7/+37
| | | | | | | | | | | | In particular, 64-bit system call arguments use up two register_t arguments for 32-bit processes. They must also be aligned on a 64-bit boundary on 32-bit powerpc processes. This fixes the decoding of lseek(), procctl(), and wait6() arguments for 32-bit processes (both native and via freebsd32). Note that the ktrace system call return record only returns a single register, so the return value of lseek is always truncated to the low 32-bits for 32-bit processes.
* MFC r303990:kib2016-08-191-2/+0
| | | | Remove unused prototypes.
* MFC r302770:kib2016-07-201-0/+25
| | | | | | Trace timeval parameters to the getitimer(2) and setitimer(2) syscalls. Approved by: re (gjb)
* Fix humanized decoding of struct stat with respect to .st_mtimngie2016-05-221-1/+1
| | | | | | | | | | st_mtim was being incorrectly described as "stime=", not "mtime=". This was introduced with the original feature commit (r176471). MFC after: 1 week PR: 209699 Submitted by: naddy Sponsored by: EMC / Isilon Storage Division
* Use != 0 to be clearsjg2016-05-171-1/+1
|
* Allow -f - to read from stdin.sjg2016-05-171-2/+3
|
* Print the fchmodat mode in human readable fashionbapt2016-05-031-0/+1
| | | | MFC after: 1 week
* Fix reporting of the CloudABI ABI in kdump.jhb2016-03-091-6/+5
| | | | | | | | | | | | - Advertise the word size for CloudABI ABIs via the SV_LP64 flag. All of the other ABIs include either SV_ILP32 or SV_LP64. - Fix kdump to not assume a 32-bit ABI if the ABI flags field is non-zero but SV_LP64 isn't set. Instead, only assume a 32-bit ABI if SV_ILP32 is set and fallback to the unknown value of "00" if neither SV_LP64 nor SV_ILP32 is set. Reviewed by: kib, ed Differential Revision: https://reviews.freebsd.org/D5560
* Update dependencies.bdrewery2016-02-261-1/+3
| | | | Sponsored by: EMC / Isilon Storage Division
* Convert casperd(8) daemon to the libcasper.oshogbo2016-02-252-17/+20
| | | | | | | | | | | | | | | | | | | | After calling the cap_init(3) function Casper will fork from it's original process, using pdfork(2). Forking from a process has a lot of advantages: 1. We have the same cwd as the original process. 2. The same uid, gid and groups. 3. The same MAC labels. 4. The same descriptor table. 5. The same routing table. 6. The same umask. 7. The same cpuset(1). From now services are also in form of libraries. We also removed libcapsicum at all and converts existing program using Casper to new architecture. Discussed with: pjd, jonathan, ed, drysdale@google.com, emaste Partially reviewed by: drysdale@google.com, bdrewery Approved by: pjd (mentor) Differential Revision: https://reviews.freebsd.org/D4277
* Add simple support for CloudABI processes to kdump(1).jhb2016-02-251-0/+7
| | | | | | | | This does not decode arguments to system calls but should properly decode system call names and error return values. Reviewed by: ed Differential Revision: https://reviews.freebsd.org/D5412
* DIRDEPS_BUILD: Regenerate without local dependencies.bdrewery2016-02-241-6/+0
| | | | | | | | These are no longer needed after the recent 'beforebuild: depend' changes and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports skipping 'make depend'. Sponsored by: EMC / Isilon Storage Division
* Add handling for non-native error values to libsysdecode.jhb2016-02-231-68/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add two new functions, sysdecode_abi_to_freebsd_errno() and sysdecode_freebsd_to_abi_errno(), which convert errno values between the native FreeBSD ABI and other supported ABIs. Note that the mappings are not necessarily perfect meaning in some cases multiple errors in one ABI might map to a single error in another ABI. In that case, the reverse mapping will return one of the errors that maps, but which error is non-deterministic. Change truss to always report the raw error value to the user but use libsysdecode to map it to a native errno value that can be used with strerror() to generate a description. Previously truss reported the "converted" error value. Now the user will always see the exact error value that the application sees. Change kdump to report the truly raw error value to the user. Previously kdump would report the absolute value of the raw error value (so for Linux binaries it didn't output the FreeBSD error value, but the positive value of the Linux error). Now it reports the real (i.e. negative) error value for Linux binaries. Also, use libsysdecode to convert the native FreeBSD error reported in the ktrace record to the raw error used by the ABI. This means that the Linux ABI can now be handled directly in ktrsysret() and removes the need for linux_ktrsysret(). Reviewed by: bdrewery, kib Helpful notes: wblock (manpage) Differential Revision: https://reviews.freebsd.org/D5314
* DIRDEPS_BUILD: Update dependencies.bdrewery2016-02-161-4/+0
| | | | Sponsored by: EMC / Isilon Storage Division
* Add a SYSDECODE_ABI_ prefix to the ABI enums to avoid potential collisions.jhb2016-01-301-5/+5
| | | | | | Suggested by: jmallett Reviewed by: bdrewery, jmallett Differential Revision: https://reviews.freebsd.org/D5123
* Add support to libsysdecode for decoding system call names.jhb2016-01-262-107/+48
| | | | | | | | | | | | | | | | | | | | | | | | A new sysdecode_syscallname() function accepts a system call code and returns a string of the corresponding name (or NULL if the code is unknown). To support different process ABIs, the new function accepts a value from a new sysdecode_abi enum as its first argument to select the ABI in use. Current ABIs supported include FREEBSD (native binaries), FREEBSD32, LINUX, LINUX32, and CLOUDABI64. Note that not all ABIs are supported by all platforms. In general, a given ABI is only supported if a platform can execute binaries for that ABI. To simplify the implementation, libsysdecode's build reuses the existing pre-generated files from the kernel source tree rather than duplicating new copies of said files during the build. kdump(1) and truss(1) now use these functions to map system call identifiers to names. For kdump(1), a new 'syscallname()' function consolidates duplicated code from ktrsyscall() and ktrsyscallret(). The Linux ABI no longer requires custom handling for ktrsyscall() and linux_ktrsyscall() has been removed as a result. Reviewed by: bdrewery Differential Revision: https://reviews.freebsd.org/D4823
* DIRDEPS_BUILD: Update dependencies.bdrewery2016-01-071-3/+0
| | | | Sponsored by: EMC / Isilon Storage Division
* Move the mkioctls script to libsysdecode and use it to generate ajhb2015-12-223-132/+17
| | | | | | | | | | | sysdecode_ioctlname() function. This function matches the behavior of the truss variant in that it returns a pointer to a string description for known ioctls. The caller is responsible for displaying unknown ioctl requests. For kdump this meant moving the logic to handle unknown ioctl requests out of the generated function and into an ioctlname() function in kdump.c instead. Differential Revision: https://reviews.freebsd.org/D4610
* Start on a new library (libsysdecode) that provides routines for decodingjhb2015-12-154-191/+6
| | | | | | | | | | | | | | | | | system call information such as system call arguments. Initially this will consist of pulling duplicated code out of truss and kdump though it may prove useful for other utilities in the future. This commit moves the shared utrace(2) record parser out of kdump into the library and updates kdump and truss to use it. One difference from the previous version is that the library version treats unknown events that start with the "RTLD" signature as unknown events. This simplifies the interface and allows the consumer to decide how to handle all non-recognized events. Instead, this function only generates a string description for known malloc() and RTLD records. Reviewed by: bdrewery Differential Revision: https://reviews.freebsd.org/D4537
* Replace DPSRCS that work fine in SRCS.bdrewery2015-11-251-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is so that 'make depend' is not a required build step in these files. DPSRCS is overall unneeded. DPSRCS already contains SRCS, so anything which can safely be in SRCS should be. DPSRCS is mostly just a way to generate files that should not be linked into the final PROG/LIB. For headers and grammars it is safe for them to be in SRCS since they will be excluded during linking and installation. The only remaining uses of DPSRCS are for generating .c or .o files that must be built before 'make depend' can run 'mkdep' on the SRCS c files list. A semi-proper example is in tests/sys/kern/acct/Makefile where a checked-in .c file has an #include on a generated .c file. The generated .c file should not be linked into the final PROG though since it is #include'd. The more proper way here is just to build/link it in though without DPSRCS. Another example is in sys/modules/linux/Makefile where a shell script runs to parse a DPSRCS .o file that should not be linked into the module. Beyond those, the need for DPSRCS is largely unneeded, redundant, and forces 'make depend' to be ran. Generally, these Makefiles should avoid the need for DPSRCS and define proper dependencies for their files as well. An example of an improper usage and why this matters is in usr.bin/netstat. nl_defs.h was only in DPSRCS and so was not generated during 'make all', but only during 'make depend'. The files including it lacked proper depenencies on it, which forced running 'make depend' to workaround that bug. The 'make depend' target should mostly be used for incremental build help, not to produce a working build. This specific example was broken in the meta build until r287905 since it does not run 'make depend'. The gnu/lib/libreadline/readline case is fine since bsd.lib.mk has 'OBJS: SRCS:M*.h' when there is no .depend file. Sponsored by: EMC / Isilon Storage Division MFC after: 1 week
* truss: Add support for utrace(2).bdrewery2015-10-063-142/+191
| | | | | | | | | | | | | | This uses the kdump(1) utrace support code directly until a common library is created. This allows malloc(3) tracing with MALLOC_CONF=utrace:true and rtld tracing with LD_UTRACE=1. Unknown utrace(2) data is just printed as hex. PR: 43819 [inspired by] Reviewed by: jhb MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D3819
* Let the nv.h and dnv.h includes be only in sys directory.oshogbo2015-07-021-3/+3
| | | | | | | Change consumers to include those files from sys. Add duplicated files to ObsoleteFiles. Approved by: pjd (mentor)
* new dependssjg2015-06-161-1/+2
|
* Add ioctl.c, linux_syscalls.c, linux32_syscalls.c to beforedepend target.rodrigc2015-06-151-0/+6
| | | | These files need to be generated before mkdep is run.
* Use cpp -I$includedirrodrigc2015-06-151-1/+1
| | | | | | "cpp -I$1" was expanding to "cpp -Iprint" which was not the proper directory of header files.
* Create proper targets for linux*syscalls.csjg2015-06-141-8/+8
|
* Add META_MODE support.sjg2015-06-131-0/+33
|\ | | | | | | | | | | | | | | | | | | | | Off by default, build behaves normally. WITH_META_MODE we get auto objdir creation, the ability to start build from anywhere in the tree. Still need to add real targets under targets/ to build packages. Differential Revision: D2796 Reviewed by: brooks imp
| * dirdeps.mk now sets DEP_RELDIRsjg2015-06-081-2/+0
| |
| * Merge sync of headsjg2015-05-274-24/+42
| |\
| * \ Merge from head@274682sjg2014-11-192-19/+113
| |\ \
| * \ \ Merge head from 7/28sjg2014-08-191-0/+1
| |\ \ \
| * | | | Updated dependenciessjg2014-05-161-1/+0
| | | | |
| * | | | Updated dependenciessjg2014-05-101-0/+2
| | | | |
| * | | | Merge from headsjg2014-05-081-1/+1
| |\ \ \ \ | | |/ / /
| * | | | New/updated dependenciessjg2014-05-051-0/+2
| | | | |
| * | | | Merge headsjg2014-04-285-67/+172
| |\ \ \ \
| * \ \ \ \ Merge head@256284sjg2013-10-132-6/+110
| |\ \ \ \ \
| * | | | | | Tell cpp to only look where we told itsjg2013-10-121-1/+1
| | | | | | |
| * | | | | | Merge headsjg2013-09-111-0/+4
| |\ \ \ \ \ \
| * \ \ \ \ \ \ Merge from headsjg2013-09-052-41/+224
| |\ \ \ \ \ \ \
| * | | | | | | | Add stage-install.sh so we can do away with the need to havesjg2013-04-192-5/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | $STAGE_OBJTOP/include for src/include.
OpenPOWER on IntegriCloud