History log of /freebsd-current/usr.bin/truss/Makefile
Revision Date Author Comments
# d0b2dbfa 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

Remove $FreeBSD$: one-line sh pattern

Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/


# 7fa2f2a6 06-Jan-2021 Alex Richardson <Alexander.Richardson@cl.cam.ac.uk>

Rename NO_WERROR -> MK_WERROR=no

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


# caa449b6 16-Jul-2019 John Baldwin <jhb@FreeBSD.org>

Use PT_GET_SC_ARGS and PT_GET_SC_RET in truss.

This removes all of the architecture-specific functions from truss.

A per-ABI structure is still needed to map syscall numbers to names
and FreeBSD errno values to ABI error values as well as hold syscall
counters. However, the linker set of ABI structures is now replaced
with a simple table mapping ABI names to structures. This approach
permits sharing the same ABI structure among separate names such as
i386 a.out and ELF binaries as well as ELF v1 vs ELF v2 for powerpc64.

A few differences are visible due to using PT_GET_SC_RET to fetch the
error value of a system call. Note that ktrace/kdump have had the
"new" behaviors for a long time already:
- System calls that return with EJUSTRETURN or ERESTART will now be
noticed and logged as such. Previously sigreturn (which uses
EJUSTRETURN) would report whatever random value was in the register
holding errno from the previous system call for example. Now it
reports EJUSTRETURN.
- System calls that return errno as their error value such as
posix_fallocate() and posix_fadvise() now report non-zero return
values as errors instead of success with a non-zero return value.

Reviewed by: kib
MFC after: 1 month
Sponsored by: DARPA
Differential Revision: https://reviews.freebsd.org/D20963


# 4be29fb3 21-Dec-2017 Ed Schouten <ed@FreeBSD.org>

Make truss work for CloudABI executables on i386.

The system call convention is different from i386 binaries running on
FreeBSD/amd64, but this is not noticeable by executables. On
FreeBSD/amd64, the vDSO already does padding of arguments and return
values to 64-bit values. On i386, it does not, meaning that system call
return values are simply stored in registers.


# d0aec748 20-Dec-2017 Ed Schouten <ed@FreeBSD.org>

Make truss(8) work for 32-bit CloudABI executables on ARM64.

This change effectively merges the existing 64-bit support for ARM64
with the 32-on-64-bit support for AMD64.


# ae8ef112 16-Dec-2017 Ed Schouten <ed@FreeBSD.org>

Make truss(8) work for i686-unknown-cloudabi binaries on FreeBSD/amd64.

This change copies the existing amd64_cloudabi64.c to amd64_cloudabi32.c
and reimplements the functions for fetching system call arguments and
return values to use the same scheme as used by the vDSO that is used
when running cloudabi32 executables.

As arguments are automatically padded to 64-bit words by the vDSO in
userspace, we can copy the arguments directly into the array used by
truss(8) internally.

Reviewed by: jhb
Differential Revision: https://reviews.freebsd.org/D13516


# a35f04fb 12-Mar-2017 Warner Losh <imp@FreeBSD.org>

Adopt SRCTOP in usr.bin

Prefer ${SRCTOP}/foo over ${.CURDIR}/../../foo and ${SRCTOP}/usr.bin/foo
over ${.CURDIR}/../foo for paths in Makefiles.

Differential Revision: https://reviews.freebsd.org/D9932
Sponsored by: Netflix
Silence on: arch@ (twice)


# 9289f547 17-Oct-2016 John Baldwin <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
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


# d3a5e7a3 08-Jun-2016 John Baldwin <jhb@FreeBSD.org>

Add support for truss'ing Linux/x86_64 binaries under amd64.

Prodding by: xmj


# 287b96dd 23-Feb-2016 John Baldwin <jhb@FreeBSD.org>

Add handling for non-native error values to libsysdecode.

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


# a5f14abf 26-Jan-2016 John Baldwin <jhb@FreeBSD.org>

Add support to libsysdecode for decoding system call names.

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


# 265e5898 22-Dec-2015 John Baldwin <jhb@FreeBSD.org>

Move the mkioctls script to libsysdecode and use it to generate a
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


# d6fb4894 14-Dec-2015 John Baldwin <jhb@FreeBSD.org>

Start on a new library (libsysdecode) that provides routines for decoding
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


# b0e78727 30-Oct-2015 Ed Schouten <ed@FreeBSD.org>

Make truss work for CloudABI processes on aarch64.

This change copies over amd64-cloudabi64.c to aarch64-cloudabi.c and
adjusts it to fetch the proper registers on aarch64. To reduce the
amount of shared code, the errno conversion function is moved into a
separate source file.

Reviewed by: jhb, andrew
Differential Revision: https://reviews.freebsd.org/D4023


# 8c444cbc 13-Oct-2015 Bryan Drewery <bdrewery@FreeBSD.org>

Simplify syscall generation and ABI source file handling for the build.

This is to make the Makefile more easily extendable for new ABIs.

This also makes several other subtle changes:
- The build now is given a list of ABIs to use based on the MACHINE_ARCH or
MACHINE_CPUARCH. These ABIs have a related path in sys/ that is used
to generate their syscalls. For each ABI to build check for a
ABI.c, MACHINE_ARCH-ABI.c, or a MACHINE_CPUARCH-ABI.c. This matches
the old behavior needed for archs such as powerpc* and mips*.
- The ABI source file selection allows for simpler assignment of common
ABIs such as "fbsd32" from sys/compat/freebsd32, or cloudabi64.
- Expand 'fbsd' to 'freebsd' everywhere for consistency.
- Split out the powerpc-fbsd.c file into a powerpc64-freebsd32.c to be more
like the amd64-freebsd32.c file and to more easily allow the auto-generation
of ABI handling to work.
- Rename 'syscalls.h' to 'fbsd_syscalls.h' to lessen the ambiguity and
avoid confusion with syscall.h (such as in r288997).
- For non-native syscall header files, they are now renamed to be
ABI_syscalls.h, where ABI is what ABI the Makefile is building.
- Remove all of the makesyscalls config files. The "native" one being
name i386.conf was a long outstanding bug. They were all the same
except for the data they generated, so now it is just auto-generated
as a build artifact.
- The syscalls array is now fixed to be static in the syscalls header to
remove the compiler warning about non-extern. This was worked around
in the aarch64-fbsd.c file but not the others.
- All syscall table names are now just 'syscallnames' since they don't
need to be different as they are all static in their own ABI files. The
alternative is to name them ABI_syscallnames which does not seem
necessary.

Reviewed by: ed, jhb
MFC after: 3 weeks
Differential Revision: https://reviews.freebsd.org/D3851


# 808d9805 07-Oct-2015 Ed Schouten <ed@FreeBSD.org>

Properly format pointer size independent CloudABI system calls.

CloudABI has approximately 50 system calls that do not depend on the
pointer size of the system. As the ABI is pretty compact, it takes
little effort to each truss(8) the formatting rules for these system
calls. Start off by formatting pointer size independent system calls.

Changes:

- Make it possible to include the CloudABI system call definitions in
FreeBSD userspace builds. Add ${root}/sys to the truss(8) Makefile so
we can pull in <compat/cloudabi/cloudabi_syscalldefs.h>.
- Refactoring: patch up amd64-cloudabi64.c to use the CLOUDABI_*
constants instead of rolling our own table.
- Add table entries for all of the system calls.
- Add new generic formatting types (UInt, IntArray) that we'll be using
to format unsigned integers and arrays of integers.
- Add CloudABI specific formatting types.

Approved by: jhb
Differential Revision: https://reviews.freebsd.org/D3836


# 195aef99 06-Oct-2015 Bryan Drewery <bdrewery@FreeBSD.org>

truss: Add support for utrace(2).

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


# 2f9ebcc1 02-Oct-2015 Ed Schouten <ed@FreeBSD.org>

Make truss print CloudABI system call names.

This change adds the bits that are necessary to fetch system call
arguments and return values from trapframes for CloudABI. This allows us
to properly print system calls with the right name. We need to make sure
that we properly convert error numbers when system calls fail.

We still need to improve truss to pretty-print some of the system calls
that have flags.


# 728d82cd 11-Jun-2015 Simon J. Gerraty <sjg@FreeBSD.org>

Use INCLUDEDIR rather than hard coded /usr/include

Differential Revision: D2748
Reviewed by: brooks imp


# 0bc8845f 09-May-2013 Simon J. Gerraty <sjg@FreeBSD.org>

We no longer need to fiddle with INCLUDEDIR


# adf23bef 08-Nov-2012 Simon J. Gerraty <sjg@FreeBSD.org>

If we are staging, we need to look in the right place, for
the headers we want to examine.


# 085e2c21 09-Apr-2012 Dimitry Andric <dim@FreeBSD.org>

Since truss also uses kdump's mkioctls script, pass the value of ${CPP}
there too, similar to r234058.

MFC after: 1 week


# c04743da 21-Oct-2011 Dag-Erling Smørgrav <des@FreeBSD.org>

It turns out that truss also used kdump's mkioctls script, and expected
ioctlname() to return a pointer to the name rather than print it. This did
not show up in testing because truss had its own prototype for ioctlname(),
so it would build fine and run fine as long as the program being traced did
not issue an ioctl.

Teach mkioctls to generate different versions of ioctlname() based on its
first command-line argument.

Pointed out by: Garrett Cooper <yanegomi@gmail.com>


# a7d5f7eb 19-Oct-2010 Jamie Gritton <jamie@FreeBSD.org>

A new jail(8) with a configuration file, to replace the work currently done
by /etc/rc.d/jail.


# 4e583321 28-Aug-2010 Nathan Whitehorn <nwhitehorn@FreeBSD.org>

Fix breakage introduced in r211725 and improve functionality of truss on
64-bit powerpc by adding 32-bit compatibility features.


# 25faff34 23-Aug-2010 Warner Losh <imp@FreeBSD.org>

MFtbemd:

Prefer MACHNE_CPUARCH to MACHINE_ARCH in most contexts where you want
to test of all the CPUs of a given family conform.


# fe0506d7 09-Mar-2010 Marcel Moolenaar <marcel@FreeBSD.org>

Create the altix project branch. The altix project will add support
for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting
is a two-module system, consisting of a base compute module and a
CPU expansion module. SGI's NUMAFlex architecture can be an excellent
platform to test CPU affinity and NUMA-aware features in FreeBSD.


# b7946da9 02-Jan-2010 Ed Schouten <ed@FreeBSD.org>

Build usr.bin/ with WARNS=6 by default.

Also add some missing $FreeBSD$ to keep svn happy.


# d7f03759 19-Oct-2008 Ulf Lilleengen <lulf@FreeBSD.org>

- Import the HEAD csup code which is the basis for the cvsmode work.


# 9a55503e 16-May-2008 John Baldwin <jhb@FreeBSD.org>

Teach truss about 32-bit FreeBSD and Linux binaries on amd64. Some
additional work is needed to handle ABI-specific syscall argument parsing,
but this gets the basic tracing working.

MFC after: 1 week


# 5fb6bed9 05-Feb-2008 Dag-Erling Smørgrav <des@FreeBSD.org>

Revert CLEANDEPFILES commit per ru@'s request; it does not really solve
the problem. The correct fix will follow.


# 0d7cc1d0 03-Feb-2008 Dag-Erling Smørgrav <des@FreeBSD.org>

Normally, when a header file is removed from the build (as i4b headers
were recently), a simple 'make cleandepend; make depend' is sufficient
to keep the tree buildable after a cvs update when doing incremental
builds.

However, kdump and truss use a script which searches for header files
that define ioctls, and generates C code that includes them. This
script will usually not need updating when a header file is removed,
so the normal dependency mechanism will not realize that it needs to
be re-run. One is therefore left with code that references dead files
but will only be removed by a full 'make clean', which defeats the
purpose of incremental builds.

To work around this, modify the cleandepend target in bsd.dep.mk to
also remove any files listed in a new variable named CLEANDEPFILES,
and modify kdump's and truss's Makefiles accordingly.

MFC after: 2 weeks


# 5d2d083c 09-Apr-2007 Xin LI <delphij@FreeBSD.org>

Make use of ptrace(2) instead of procfs in truss(1), eliminating
yet another need of an available /proc/ mount.

Tested with: make universe
Submitted by: howardsu
Reviewed by: alfred


# a35d8893 24-Oct-2004 Ruslan Ermilov <ru@FreeBSD.org>

For variables that are only checked with defined(), don't provide
any fake value.


# 894b8f7a 23-Mar-2004 Alfred Perlstein <alfred@FreeBSD.org>

decode fcntl and mmap arguments.


# 1eb3be49 05-Jun-2003 Marcel Moolenaar <marcel@FreeBSD.org>

Use cat(1) instead of cp(1) so as not to break -DNOCLEAN builds
when the file permissions of source files don't allow writing.


# 568ef33f 20-Feb-2003 Ruslan Ermilov <ru@FreeBSD.org>

Removed extra parentheses.


# f84c971a 04-Aug-2002 Jake Burkholder <jake@FreeBSD.org>

Ported to sparc64.


# b2490f91 11-Apr-2002 Ruslan Ermilov <ru@FreeBSD.org>

I now don't seem to be able to reproduce the -DNOCLEAN buildworld
breakage with ioctl.c. The .depend file should track dependencies
just fine, and the worst we can have is to miss new ioctls.

But I still think it's a good idea to have -DNOCLEAN build produce
the same ioctl.c as it would without -DNOCLEAN.

Prodded for a long time by: bde


# e35f9517 08-Feb-2002 Mark Murray <markm@FreeBSD.org>

Remove NO_WERRORs and WARNS=n's. To be revisited after GCC3.


# 1be5d704 11-Dec-2001 Mark Murray <markm@FreeBSD.org>

Partial WARNS=1 fizes with NO_WERROR set to prevent world breakage.
Use __FBSDID().


# c137d678 14-Sep-2000 Jordan K. Hubbard <jkh@FreeBSD.org>

cc -O -pipe -I/usr/src/usr.bin/kdump/../ktrace -I/usr/src/usr.bin/kdump/../.. Fix ioctl.c creation to deal with the depend case more properly.

Submitted by: Ruslan Ermilov <ru@sunbay.com>


# 6b616872 14-Sep-2000 Jordan K. Hubbard <jkh@FreeBSD.org>

remove .PHONY to avoid gratuitous rebuild of ioctl.c each time.

Approved by: sef


# ed7cf099 01-Aug-2000 Ruslan Ermilov <ru@FreeBSD.org>

Make auto-generated ioctl.c to be always considered out of date
since it could potentially depend on any ${DESTDIR}/usr/include
preprocessor file. This fixes the broken -DNOCLEAN world build
I experienced yesterday.


# 6468017b 03-Dec-1999 Marcel Moolenaar <marcel@FreeBSD.org>

Fix for the new usage of mkioctls


# 0917704b 14-Nov-1999 Marcel Moolenaar <marcel@FreeBSD.org>

${MACHINE} -> ${MACHINE_ARCH}

All Makefiles now use MACHINE_ARCH for the target architecture.
Unification is required for cross-building.

Tags added to:
sys/boot/Makefile
sys/boot/arc/loader/Makefile
sys/kern/Makefile
usr.bin/cpp/Makefile
usr.bin/gcore/Makefile
usr.bin/truss/Makefile

usr.bin/gcore/Makefile:
fixed typo: MACHINDE -> MACHINE_ARCH


# c668c156 07-Oct-1998 KATO Takenori <kato@FreeBSD.org>

Use MACHINE_ARCH instead of MACHINE to detect x86 arch.

Pointed out by: Akio Morita <amorita@meadow.scphys.kyoto-u.ac.jp>


# 50cc4492 02-Oct-1998 Sean Eric Fagan <sef@FreeBSD.org>

Alpha support for truss. I tested this on both bento and beast (thanks,
Jordan, for pointing me at beast!). There should be no change for the
i386 version.


# e46b9936 09-Jan-1998 Sean Eric Fagan <sef@FreeBSD.org>

Revert the changes yet again, after some email from Bruce. Sorry.


# 19db2a3c 08-Jan-1998 Sean Eric Fagan <sef@FreeBSD.org>

Proper way to do the previous mis-commit. Still not quite right, because
some header files (e.g., <err.h>) include <machine/something.h>, and this
will not pick up the right header files, so it may be removed eventually
anyway. But some people who are not willing to build the right way
apparantly want this, so this is for them.


# 41ccb632 08-Jan-1998 Sean Eric Fagan <sef@FreeBSD.org>

Get rid of the bogus include -- it is incomplete (as it doesn't handle
anything other than <sys/*.h>), and unnecessary in most cases. (The
situations where it is necesary can be dealt with by manually-made symlinks,
which is acceptable since they should only occur during testing. Remember:
the tree does not compile well if you do not have matching header files
installed. Half-baked -I directives don't cover enough of the cases.)


# ad6af66e 06-Jan-1998 John-Mark Gurney <jmg@FreeBSD.org>

include sys so it builds on 2.2.x
also, fix misspelling of -1 (as EOF for getopt)


# 970649f9 05-Dec-1997 Sean Eric Fagan <sef@FreeBSD.org>

First cut at printing out ioctl names intelligently. Note that this doesn't
handle linux ioctls (yet?). This uses the mkioctl script from kdump,
bless its little heart.

Reviewed by: Mike Smith


# bbeaf6c0 05-Dec-1997 Sean Eric Fagan <sef@FreeBSD.org>

Truss program. Requires procfs.