aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/truss
Commit message (Collapse)AuthorAgeFilesLines
* truss: Properly display first argument to nmountTiago Gasiba2025-10-311-1/+1
| | | | | | | | | The first argument to nmount(2) is an nvlist in the form of an iovec, which truss already knows how to decode. Set the correct flag so this happens automatically. MFC after: 1 week PR: 290667
* truss: Add a decoder for inotify_add_watch_at(2)Mark Johnston2025-07-042-1/+7
| | | | | MFC after: 3 months Sponsored by: Klara, Inc.
* truss.1: Reference sysdecode(3)Mateusz Piotrowski2025-06-181-2/+3
| | | | MFC after: 1 week
* truss: Fix grammar in error messagesCy Schubert2024-11-251-3/+3
| | | | MFC after: 3 days
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* Translate linux_newlstat name argumentJohn F. Carr2024-03-201-0/+2
| | | | | PR: 277847 MFC after: 1 week
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-162-2/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
* Remove $FreeBSD$: one-line .c patternWarner Losh2023-08-163-6/+0
| | | | Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-163-6/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* truss: Kill dead codeWarner Losh2023-04-211-5/+0
| | | | | | If it doesn't exist, we don't need it in the table... Sponsored by: Netflix
* Update/fix Makefile.depend for userlandSimon J. Gerraty2023-04-191-1/+0
|
* truss: Add preadv(2) and pwritev(2).Thomas Munro2023-02-211-0/+6
| | | | | | | | | We already knew how to decode readv(2)/writev(2). Add the versions with an offset. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D27531 MFC after: 2 weeks
* truss: remove now-unused special case for MIPSEd Maste2022-10-171-6/+1
| | | | | | Reviewed by: mhorne, imp Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37022
* kdump: Decode getitimer, setitimer which argumentDmitry Chagin2022-06-222-2/+12
| | | | | | Reviewed by: jhb (previous version, without truss) Differential revision: https://reviews.freebsd.org/D35231 MFC after: 2 weeks
* truss: Make control message header parsing more robustMark Johnston2022-06-141-0/+10
| | | | | | | | | | | | print_cmsg() was assuming that the control message chain is well-formed, but that isn't necessarily the case for sendmsg(2). In particular, if cmsg_len is zero, print_cmsg() will loop forever. Check for truncated headers and try to recover if possible. Reviewed by: tuexen MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D35476
* truss: add ppoll(2) argument decodingChristian Weisgerber2022-05-171-0/+3
| | | | | | PR: 264029 Approved by: emaste MFC after: 3 days
* syscallarg_t: Add a type for system call argumentsBrooks Davis2022-03-284-10/+10
| | | | | | | | | | | | | | This more clearly differentiates system call arguments from integer registers and return values. On current architectures it has no effect, but on architectures where pointers are not integers (CHERI) and may not even share registers (CHERI-MIPS) it is necessiary to differentiate between system call arguments (syscallarg_t) and integer register values (register_t). Obtained from: CheriBSD Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D33780
* fd: add close_range(..., CLOSE_RANGE_CLOEXEC)Mateusz Guzik2022-03-032-0/+6
| | | | | | | | For compatibility with Linux. MFC after: 3 days Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D34424
* Revert "syscallarg_t: Add a type for system call arguments"Brooks Davis2022-01-123-7/+7
| | | | | | | | Missed issues in truss on at least armv7 and powerpcspe need to be resolved before recommit. This reverts commit 3889fb8af0b611e3126dc250ebffb01805152104. This reverts commit 1544e0f5d1f1e3b8c10a64cb899a936976ca7ea4.
* syscallarg_t: Add a type for system call argumentsBrooks Davis2022-01-123-7/+7
| | | | | | | | | | | | | | This more clearly differentiates system call arguments from integer registers and return values. On current architectures it has no effect, but on architectures where pointers are not integers (CHERI) and may not even share registers (CHERI-MIPS) it is necessiary to differentiate between system call arguments (syscallarg_t) and integer register values (register_t). Obtained from: CheriBSD Reviewed by: imp, kib Differential Revision: https://reviews.freebsd.org/D33780
* truss(1): detach more carefullyKonstantin Belousov2022-01-121-3/+16
| | | | | | | | | | | | | | | | | | | | | When detaching, truss(1) sends SIGSTOP to the traced process to ensure that it is detaching in the steady state. But it is possible, for multithreaded process, that wait() call returns event other than our SIGSTOP notification. As result, SIGSTOP might sit in some thread' sigqueue, which makes SIGCONT a nop. Then, the process is stopped when the queued SIGSTOP is acted upon. To handle this, loop until we drain everything before SIGSTOP, and see that the process is stopped. Note that the earlier fix makes it safe to have some more debugging events longering after SIGSTOP is acted upon. They will be ignored after PT_DETACH. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33861
* truss: remove write-only variableKonstantin Belousov2022-01-121-2/+0
| | | | | | | Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D33861
* struct kevent_freebsd11 -> struct freebsd11_keventBrooks Davis2021-11-151-2/+2
| | | | | | | | | Rename to match the naming of syscalls and allow 32 to be appended without making an ugly name like kevent_freebsd1132. While here, make the kevent changelist argument const. Reviewed by: kib
* truss: Decode correctly 64bits arguments on 32bits arm.Olivier Houchard2021-09-221-12/+6
| | | | | | | | | Mostly revert ebbc3140ca0d7eee154f7a67ccdae7d3d88d13fd. We don't need to special-case anything for arm64, the check for the pointer size is already done for us, just keep the bits about having arm and arm64 having to add padding for 32bits binaries. MFC after: 1 week
* truss: Decode correctly 64bits arguments on 32bits arm.Olivier Houchard2021-09-221-8/+14
| | | | | | | | When decoding 32bits arm syscall, make sure we account for the padding when decoding 64bits args. Do it too when using a 64bits truss on a 32bits binary. MFC After: 1 week PR: 256199
* Drop cloudabiKonstantin Belousov2021-09-213-296/+1
| | | | | | | | | | | | | According to https://github.com/NuxiNL/cloudlibc: CloudABI is no longer being maintained. It was an awesome experiment, but it never got enough traction to be sustainable. There is no reason to keep it in FreeBSD. Approved by: ed (private mail) Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D31923
* lio_listio(2): Allow LIO_READV and LIO_WRITEV.Thomas Munro2021-08-221-1/+1
| | | | | | | | | | | | | Allow multiple vector IOs to be started with one system call. aio_readv() and aio_writev() already used these opcodes under the covers. This commit makes them available to user space. Being non-standard extensions, they're only visible if __BSD_VISIBLE is defined, like the functions. Reviewed by: asomers, kib MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D31627
* truss: minor cleanup and pedantic warning fixesAlex Richardson2021-06-162-30/+44
| | | | | | | | | | Noticed while porting the recent truss compat32 changes to CheriBSD. This also fixes i386 tracing by zero-extending user addresses instead of sign-extending them. Reviewed By: jhb MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D30211
* truss: fix handling of 64-bit arguments/return values for compat32Alex Richardson2021-06-161-23/+17
| | | | | | | | | | | | | | | | Deciding whether to combine two values to a 64-bit one should be based on the process ABI, and not dependent on whether truss is compiled for an LP64 ABI. This is a follow-up cleanup for D27625. I found this while looking for uses of the `__LP64__` macro (since using this is wrong for CHERI systems). Test Plan: truss still works. Since I tested on AMD64 and all syscalls in the trace have their quad argument last there was no difference in the output. Should fix output for compat32 on MIPS64 though. Reviewed By: jhb MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D27637
* truss: Decode FreeBSD 11 mknod(2) and mknodat(2)Mark Johnston2021-05-121-2/+6
| | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation
* truss: Add missing underscore to compat_prefix for FreeBSD32Alex Richardson2021-05-111-1/+1
| | | | | | | | I accidentally dropped this in the final version of D27625, so it didn't actually work as intended. I found this while testing the MFC to stable/13. MFC after: immediately Fixes: 7daca4e2043f ("truss: improved support for decoding compat32 arguments")
* poll(2): Add POLLRDHUP.Thomas Munro2021-04-281-1/+1
| | | | | | | | | | Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if requested. Triggered when the remote peer shuts down writing or closes its end. Reviewed by: kib MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D29757
* truss: improved support for decoding compat32 argumentsAlex Richardson2021-03-253-45/+87
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently running `truss -a -e` does not decode any argument values for freebsd32_* syscalls (open/readlink/etc.) This change checks whether a syscall starts with freebsd{32,64}_ and if so strips that prefix when looking up the syscall information. To ensure that the truss logs include the real syscall name we create a copy of the syscall information struct with the updated. The other problem is that when reading string array values, truss naively iterates over an array of char* and fetches the pointer value. This will result in arguments not being loaded if the pointer is not aligned to sizeof(void*), which can happens in the compat32 case. If it happens to be aligned, we would end up printing every other value. To fix this problem, this changes adds a pointer_size member to the procabi struct and uses that to correctly read indirect arguments as 64/32 bit addresses in the the compat32 case (and also compat64 on CheriBSD). The motivating use-case for this change is using truss for 64-bit programs on a CHERI system, but most of the diff also applies to 32-bit compat on a 64-bit system, so I'm upstreaming this instead of keeping it as a local CheriBSD patch. Output of `truss -aef ldd32 /usr/bin/ldd32` before: 39113: freebsd32_mmap(0x0,0x1000,0x3,0x1002,0xffffffff,0x0,0x0) = 543440896 (0x20644000) 39113: freebsd32_ioctl(0x1,0x402c7413,0xffffd2a0) = 0 (0x0) /usr/bin/ldd32: 39113: write(1,"/usr/bin/ldd32:\n",16) = 16 (0x10) 39113: fork() = 39114 (0x98ca) 39114: <new process> 39114: freebsd32_execve(0xffffd97e,0xffffd680,0x20634000) EJUSTRETURN 39114: freebsd32_mmap(0x0,0x20000,0x3,0x1002,0xffffffff,0x0,0x0) = 541237248 (0x2042a000) 39114: freebsd32_mprotect(0x20427000,0x1000,0x1) = 0 (0x0) 39114: issetugid() = 0 (0x0) 39114: openat(AT_FDCWD,"/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory' 39114: openat(AT_FDCWD,"/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3) 39114: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0#\0\0\0\0"...,128) = 128 (0x80) 39114: freebsd32_fstat(0x3,0xffffbd98) = 0 (0x0) 39114: freebsd32_pread(0x3,0x2042f000,0x23,0x80,0x0) = 35 (0x23) 39114: close(3) = 0 (0x0) 39114: openat(AT_FDCWD,"/usr/lib32/libc.so.7",O_RDONLY|O_CLOEXEC|O_VERIFY,00) = 3 (0x3) 39114: freebsd32_fstat(0x3,0xffffc7d0) = 0 (0x0) 39114: freebsd32_mmap(0x0,0x1000,0x1,0x40002,0x3,0x0,0x0) = 541368320 (0x2044a000) After: 783: freebsd32_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_ALIGNED(12),-1,0x0) = 543543296 (0x2065d000) 783: freebsd32_ioctl(1,TIOCGETA,0xffffd7b0) = 0 (0x0) /usr/bin/ldd32: 783: write(1,"/usr/bin/ldd32:\n",16) = 16 (0x10) 784: <new process> 783: fork() = 784 (0x310) 784: freebsd32_execve("/usr/bin/ldd32",[ "(null)" ],[ "LD_32_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_TRACE_LOADED_OBJECTS_PROGNAME=/usr/bin/ldd32", "LD_32_TRACE_LOADED_OBJECTS=yes", "LD_TRACE_LOADED_OBJECTS=yes", "USER=root", "LOGNAME=root", "HOME=/root", "SHELL=/bin/csh", "BLOCKSIZE=K", "MAIL=/var/mail/root", "MM_CHARSET=UTF-8", "LANG=C.UTF-8", "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin", "TERM=vt100", "HOSTTYPE=FreeBSD", "VENDOR=amd", "OSTYPE=FreeBSD", "MACHTYPE=x86_64", "SHLVL=1", "PWD=/root", "GROUP=wheel", "HOST=freebsd-amd64", "EDITOR=vi", "PAGER=less" ]) EJUSTRETURN 784: freebsd32_mmap(0x0,135168,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,-1,0x0) = 541212672 (0x20424000) 784: freebsd32_mprotect(0x20421000,4096,PROT_READ) = 0 (0x0) 784: issetugid() = 0 (0x0) 784: sigfastblock(0x1,0x204234fc) = 0 (0x0) 784: open("/etc/libmap32.conf",O_RDONLY|O_CLOEXEC,00) ERR#2 'No such file or directory' 784: open("/var/run/ld-elf32.so.hints",O_RDONLY|O_CLOEXEC,00) = 3 (0x3) 784: read(3,"Ehnt\^A\0\0\0\M^@\0\0\0\v\0\0\0"...,128) = 128 (0x80) 784: freebsd32_fstat(3,{ mode=-r--r--r-- ,inode=18680,size=32768,blksize=0 }) = 0 (0x0) 784: freebsd32_pread(3,"/usr/lib32\0",11,0x80) = 11 (0xb) Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D27625
* truss: split counting of syscalls and syscall calling conventionAlex Richardson2021-03-044-63/+67
| | | | | | | | | | | | | | This change is a refactoring cleanup to improve support for compat32 syscalls (and compat64 on CHERI systems). Each process ABI now has it's own struct sycall instead of using one global list. The list of all syscalls is replaced with a list of seen syscalls. Looking up the syscall argument passing convention now interates over the fixed-size array instead of using a link-list that's populated on startup so we no longer need the init_syscall() function. The actual functional changes are in D27625. Reviewed By: jhb Differential Revision: https://reviews.freebsd.org/D27636
* truss: Decode sendfile(2) argumentsMark Johnston2021-02-052-0/+24
| | | | MFC after: 2 weeks
* Rename i386's Linux ELF to Linux ELF32Jessica Clarke2021-01-211-1/+1
| | | | | | | | | This is what amd64 calls the i386 Linux ABI in order to distinguish it from the amd64 Linux ABI, and matches the nomenclature used for the FreeBSD ABIs where they always have the size suffix in the name. Reviewed by: trasz Differential Revision: https://reviews.freebsd.org/D27647
* Rename NO_WERROR -> MK_WERROR=noAlex Richardson2021-01-071-1/+0
| | | | | | | | As suggested in D27598. This also supports MK_WERROR.clang=no and MK_WERROR.gcc=no to support the existing NO_WERROR.<compiler> uses. Reviewed By: brooks Differential Revision: https://reviews.freebsd.org/D27601
* truss: Add AIO syscalls.Thomas Munro2020-12-102-0/+172
| | | | | | | | | | | | Display the arguments of aio_read(2), aio_write(2), aio_suspend(2), aio_error(2), aio_return(2), aio_cancel(2), aio_fsync(2), aio_mlock(2), aio_waitcomplete(2) and lio_listio(2) in human-readable form. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D27518 Notes: svn path=/head/; revision=368500
* kdump/truss: decode new _umtx_op flagsKyle Evans2020-12-091-3/+17
| | | | | | | | | | | | | | | | | | | | In both cases, print the flag bits first followed by the command. Output now looks something like this: (ktrace) _umtx_op(0x8605f7008,0xf<UMTX_OP_WAIT_UINT_PRIVATE>,0,0,0) _umtx_op(0x9fffdce8,0x80000003<UMTX_OP__32BIT|UMTX_OP_WAKE>,0x1,0,0) (truss) _umtx_op(0x7fffffffda50,UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0) _umtx_op(0x9fffdd08,UMTX_OP__32BIT|UMTX_OP_WAKE,0x1,0x0,0x0) = 0 (0x0) Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D27325 Notes: svn path=/head/; revision=368481
* Enable iterating all sysctls, even ones with CTLFLAG_SKIPRyan Moeller2020-10-051-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Add an "nextnoskip" sysctl that allows for listing of sysctls intended to be normally skipped for cost reasons. This makes it so the names/descriptions of those sysctls can be discovered with sysctl -aN/sysctl -ad/sysctl -at. It also makes it so children are visited when a node flagged with CTLFLAG_SKIP is explicitly requested. The intended use case is to mark the root "kstat" node with CTLFLAG_SKIP so that the extensive and expensive stats are skipped by default but may still be easily obtained without having to know them all (which may not even be possible) and request each one-by-one. Reviewed by: jhb MFC after: 2 weeks Relnotes: yes Sponsored by: iXsystems, Inc. Differential Revision: https://reviews.freebsd.org/D26560 Notes: svn path=/head/; revision=366465
* truss: print more information about traced sysctlsPawel Biernacki2020-07-051-24/+42
| | | | | | | | MFC after: 2 weeks Sponsored by: Mysterious Code Ltd. Notes: svn path=/head/; revision=362947
* Decode the file descriptor argument to closefrom(2) as an Integer.Christian S.J. Peron2020-05-211-0/+2
| | | | | | | | | | | | This is consistent with what we are doing for close(2) and it makes it a bit easier to follow when debugging file descriptor operations. i.e. many other syscalls are decoding fds as integers rather than base 16 numbers. MFC after: 1 week Notes: svn path=/head/; revision=361316
* vfs: add realpathat syscallMateusz Guzik2020-02-201-0/+3
| | | | | | | | | | | | | | | | | | realpath(3) is used a lot e.g., by clang and is a major source of getcwd and fstatat calls. This can be done more efficiently in the kernel. This works by performing a regular lookup while saving the name and found parent directory. If the terminal vnode is a directory we can resolve it using usual means. Otherwise we can use the name saved by lookup and resolve the parent. See the review for sample syscall counts. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D23574 Notes: svn path=/head/; revision=358172
* truss: fix shm_open2 oversight (BinString -> Name)Kyle Evans2020-02-191-1/+1
| | | | | | | | BinString assumes a length in the next argument; Name is more appropriate for the final argument. Notes: svn path=/head/; revision=358118
* truss: decode shm_open2Kyle Evans2020-02-192-0/+7
| | | | | | | | | | | | | | | shm_open2 is similar to shm_open, except it also takes shmflags and optional name to label the anonymous region for, e.g., debugging purposes. The appropriate support for decoding shmflags was added to libsysdecode in r358115. This is a part of D23733. Reviewed by: kaktus Notes: svn path=/head/; revision=358116
* Miscellaneous typo fixesEd Maste2020-02-071-1/+1
| | | | | | | | Submitted by: Gordon Bergling <gbergling_gmail.com> Differential Revision: https://reviews.freebsd.org/D23453 Notes: svn path=/head/; revision=357664
* truss: centralize pointer-constructing casts.Brooks Davis2019-10-311-107/+104
| | | | | | | | | | | | | | | In nearly all cases, the caller has a uintptr_t compatible argument so this eliminates a large number of casts. Add a print_pointer function to centralize printing pointers. Reviewed by: jhb Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22212 Notes: svn path=/head/; revision=354232
* Fix a typo in a comment.John Baldwin2019-10-031-1/+1
| | | | Notes: svn path=/head/; revision=353058