Commit Graph

416 Commits

Author SHA1 Message Date
John Baldwin
ee8aa41dca 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
2017-06-03 14:22:15 +00:00
John Baldwin
ebb2cc40d1 Decode the argument passed to cap_getmode().
The returned integer value is output.
2017-06-02 22:35:18 +00:00
John Baldwin
7136a1d97a Decode the arguments passed to __cap_rights_get() and cap_rights_limit().
Submitted by:	tobik
2017-06-02 13:33:50 +00:00
Michael Tuexen
738a93a461 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.
2017-05-25 14:27:54 +00:00
Michael Tuexen
c0b72375d8 Add support for sctp_generic_sendmsg() and sctp_generic_recvmsg(). 2017-05-03 16:03:33 +00:00
Michael Tuexen
fca08fe6a2 Add support for sendmsg() and recvmsg(). 2017-05-03 12:26:16 +00:00
Michael Tuexen
8b429b6569 Decode the fourth argument of sendto and recvfrom call. 2017-05-03 12:23:58 +00:00
Michael Tuexen
832af45715 Add support for [gs]etsockopt(). 2017-05-03 12:18:09 +00:00
Michael Tuexen
ecac235bb0 Decode the third argument of socket(). 2017-05-03 09:23:13 +00:00
Michael Tuexen
58227c6061 Add Socklent for handling args of type socklen_t. 2017-05-03 09:20:36 +00:00
Michael Tuexen
e8d2c81d5b Add support for listen() call. 2017-05-03 09:09:34 +00:00
John Baldwin
a776eeafdc Improve decoding of last arguments to ioctl() and sendto().
Decode the last argument to ioctl() as a pointer rather than an int.
Eventually this could use 'int' for the _IOWINT() case and pointers for
all others.

The last argument to sendto() is a socklen_t value, not a pointer.
2017-03-19 00:36:29 +00:00
John Baldwin
98fdbeec47 Decode arguments to madvise(). 2017-03-19 00:31:21 +00:00
John Baldwin
e261fb2a5b Add a Sizet type for 'size_t' values and use it instead of Int.
Various size_t arguments were previously decoded as Int values instead
which would have truncated values above 2^31 on 64-bit systems.
2017-03-19 00:27:07 +00:00
John Baldwin
94e854c517 Decode arguments passed to kldsym() and kldunloadf().
This does not currently decode the kld_sym_lookup structure passed to
kldsym().
2017-03-18 19:59:21 +00:00
John Baldwin
ab43bedcce Decode arguments passed to getfsstat().
Note that this does not yet decode the statfs structures returned by
getfsstat().
2017-03-18 18:31:45 +00:00
John Baldwin
dd92181f60 Decode flock() operation. 2017-03-18 18:26:56 +00:00
John Baldwin
27459358ed Decode file flags passed to *chflags*().
While here, decode arguments passed to fchflags() and chflagsat().
2017-03-18 18:21:41 +00:00
John Baldwin
d2a9748593 Decode arguments passed to posix_fadvise(). 2017-03-18 18:12:09 +00:00
John Baldwin
bed418c8bd Decode the arguments passed to cap_fcntls_get() and cap_fcntls_limit(). 2017-03-18 18:10:02 +00:00
John Baldwin
c05cc0d6c8 Automate the handling of QUAD_ALIGN and QUAD_SLOTS.
Previously, the offset in a system call description specified the
array index of the start of a system call argument.  For most system
call arguments this was the same as the index of the argument in the
function signature.  64-bit arguments (off_t and id_t values) passed
on 32-bit platforms use two slots in the array however.  This was
handled by adding (QUAD_SLOTS - 1) to the slot indicies of any
subsequent arguments after a 64-bit argument (though written as ("{
Quad, 1 }, { Int, 1 + QUAD_SLOTS }" rather than "{ Quad, 1 }, { Int, 2
+ QUAD_SLOTS - 1 }").  If a system call contained multiple 64-bit
arguments (such as posix_fadvise()), then additional arguments would
need to use 'QUAD_SLOTS * 2' but remember to subtract 2 from the
initial number, etc.  In addition, 32-bit powerpc requires 64-bit
arguments to be 64-bit aligned, so if the effective index in the array
of a 64-bit argument is odd, it needs QUAD_ALIGN added to the current
and any subsequent slots.  However, if the effective index in the
array of a 64-bit argument was even, QUAD_ALIGN was omitted.

This approach was messy and error prone.  This commit replaces it with
automated pre-processing of the system call table to do fixups for
64-bit argument offsets.  The offset in a system call description now
indicates the index of an argument in the associated function call's
signature.  A fixup function is run against each decoded system call
description during startup on 32-bit platforms.  The fixup function
maintains an 'offset' value which holds an offset to be added to each
remaining system call argument's index.  Initially offset is 0.  When
a 64-bit system call argument is encountered, the offset is first
aligned to a 64-bit boundary (only on powerpc) and then incremented to
account for the second argument slot used by the argument.  This
modified 'offset' is then applied to any remaining arguments.  This
approach does require a few things that were not previously required:

1) Each system call description must now list arguments in ascending
   order (existing ones all do) without using duplicate slots in the
   register array.  A new assert() should catch any future
   descriptions which violate this rule.

2) A system call description is still permitted to omit arguments
   (though none currently do), but if the call accepts 64-bit
   arguments those cannot be omitted or incorrect results will be
   displated on 32-bit systems.

Tested on:	amd64 and i386
2017-03-15 23:08:11 +00:00
John Baldwin
64f4703b9b Remove duplicate argument from linux_stat64() decoding. 2017-03-15 22:39:15 +00:00
Warner Losh
a35f04fba2 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)
2017-03-12 18:58:44 +00:00
Li-Wen Hsu
8ff21c23a5 Add RISC-V support for truss(1)
While here, extract NARGREG as a definition.

Reviewed by:	br
Differential Revision:	https://reviews.freebsd.org/D9249
2017-01-24 09:41:44 +00:00
John Baldwin
1175b23f77 Rework syscall structure lookups.
Avoid always using an O(n^2) loop over known syscall structures with
strcmp() on each system call.  Instead, use a per-ABI cache indexed by
the system call number. The first 1024 system calls (which should cover
all of the normal system calls in currently-supported ABIs) use a flat array
indexed by the system call number to find system call structure.  For other
system calls, a linked list of structures storing an integer to structure
mapping is stored in the ABI.  The linked list isn't very smart, but it
should only be used by buggy applications invoking unknown system calls.

This also fixes handling of unknown system calls which currently trigger
a NULL pointer dereference.

Reviewed by:	kib
MFC after:	2 weeks
2016-12-06 00:39:00 +00:00
John Baldwin
9289f547a2 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
2016-10-17 22:37:07 +00:00
John Baldwin
9ba323071d Fix printf format warning. 2016-10-11 17:11:17 +00:00
Ed Schouten
a5c3c5b14f Import the new automatically generated system call table for CloudABI.
Now that we've switched over to using the vDSO on CloudABI, it becomes a
lot easier for us to phase out old features. System call numbering is no
longer something that's part of the ABI. It's fully based on names. As
long as the numbering used by the kernel and the vDSO is consistent
(which it always is), it's all right.

Let's put this to the test by removing a system call (thread_tcb_set())
that's already unused for quite some time now, but was only left intact
to serve as a placeholder. Sync in the new system call table that uses
alphabetic sorting of system calls.

Obtained from:	https://github.com/NuxiNL/cloudabi
2016-08-19 17:49:35 +00:00
John Baldwin
c357102c5b Remove files unused after pulling system call names from libsysdecode. 2016-08-11 05:18:09 +00:00
Bryan Drewery
cca89ee385 Fix sorting in r303934.
Reported by:	jhb
X-MFC-With:	r303934
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 21:59:59 +00:00
Bryan Drewery
6178f8e8a6 Use proper argument length for rmdir(2) for r303934.
Reported by:	kib
X-MFC-With:	r303934
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 18:45:26 +00:00
Bryan Drewery
c870956d72 Support rmdir(2).
MFC after:	3 days
Sponsored by:	EMC / Isilon Storage Division
2016-08-10 18:19:17 +00:00
Baptiste Daroussin
0f21f5285b truss: fix uninitialized trussinfo->curthread in add_threads()/enter_syscall
trussinfo->curthread must be initialized before calling enter_syscall(),
it is used by t->proc->abi->fetch_args().
Without that truss is segfaulting and the attached program also crash.

Submitted by:	Nikita Kozlov (nikita@gandi.net)
Reviewed by:	jhb
MFC after:	3 days
Differential Revision:	https://reviews.freebsd.org/D7399
2016-08-02 22:47:06 +00:00
John Baldwin
d3a5e7a338 Add support for truss'ing Linux/x86_64 binaries under amd64.
Prodding by:	xmj
2016-06-09 02:21:07 +00:00
Pedro F. Giffuni
80c7cc1c8f Cleanup unnecessary semicolons from utilities we all love. 2016-04-15 22:31:22 +00:00
Ed Schouten
1f3bbfd875 Replace the CloudABI system call table by a machine generated version.
The type definitions and constants that were used by COMPAT_CLOUDABI64
are a literal copy of some headers stored inside of CloudABI's C
library, cloudlibc. What is annoying is that we can't make use of
cloudlibc's system call list, as the format is completely different and
doesn't provide enough information. It had to be synced in manually.

We recently decided to solve this (and some other problems) by moving
the ABI definitions into a separate file:

	https://github.com/NuxiNL/cloudabi/blob/master/cloudabi.txt

This file is processed by a pile of Python scripts to generate the
header files like before, documentation (markdown), but in our case more
importantly: a FreeBSD system call table.

This change discards the old files in sys/contrib/cloudabi and replaces
them by the latest copies, which requires some minor changes here and
there. Because cloudabi.txt also enforces consistent names of the system
call arguments, we have to patch up a small number of system call
implementations to use the new argument names.

The new header files can also be included directly in FreeBSD kernel
space without needing any includes/defines, so we can now remove
cloudabi_syscalldefs.h and cloudabi64_syscalldefs.h. Patch up the
sources to include the definitions directly from sys/contrib/cloudabi
instead.
2016-03-24 21:47:15 +00:00
John Baldwin
b9befd33b4 Use ptrace(2) LWP events to track threads reliably in truss.
- truss can now log the system call invoked by a thread during a
  voluntary process exit.  No return value is logged, but the value passed
  to exit() is included in the trace output.  Arguments passed to thread
  exit system calls such as thr_exit() are not logged as voluntary thread
  exits cannot be distinguished from involuntary thread exits during a
  system call.
- New events are now reported for thread births and exits similar to the
  recently added events for new child processes when following forks.

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D5561
2016-03-09 18:45:41 +00:00
John Baldwin
287b96dd25 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
2016-02-23 20:00:55 +00:00
John Baldwin
d70876fd7e Add support for displaying thread IDs to truss(1).
- Consolidate duplicate code for printing the metadata at the start of
  each line into a shared function.
- Add an -H option which will log the thread ID of the relevant thread
  for each event.

While here, remove some extraneous calls to clock_gettime() in
print_syscall() and print_syscall_ret().  The caller of print_syscall_ret()
always updates the current thread's "after" time before it is called.

Reviewed by:	kib
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D5363
2016-02-23 19:56:29 +00:00
John Baldwin
f8ed4050d5 Remove an unused variable that snuck into the previous revision. 2016-02-16 22:13:25 +00:00
John Baldwin
00ddbdf2ee Fetch the current thread and it's syscall state from the trussinfo object
instead of passing some of that state as arguments to print_syscall() and
print_syscallret().  This just makes the calls of these functions shorter
and easier to read.
2016-02-16 22:00:01 +00:00
Bryan Drewery
9d8a81b4e4 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-02-16 02:14:30 +00:00
John Baldwin
623277619d Correct the ABI name for Linux/i386 binaries under FreeBSD/i386.
This allows truss to work for these binaries again after r288424.

MFC after:	3 days
2016-02-15 20:27:16 +00:00
John Baldwin
142482cda6 Sign extend the error value for failing Linux/i386 system calls. This
restores the mapping of Linux errors to native FreeBSD errno values after
the refactoring in r288424.
2016-02-15 20:26:40 +00:00
John Baldwin
5842bd683f Add a SYSDECODE_ABI_ prefix to the ABI enums to avoid potential collisions.
Suggested by:	jmallett
Reviewed by:	bdrewery, jmallett
Differential Revision:	https://reviews.freebsd.org/D5123
2016-01-30 01:00:54 +00:00
John Baldwin
a5f14abfd2 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
2016-01-26 19:07:09 +00:00
Bryan Drewery
b8e3d9cc79 Update dependencies after r292622 moved the ioctl script.
Sponsored by:	EMC / Isilon Storage Division
2016-01-07 00:32:40 +00:00
John Baldwin
265e58989d 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
2015-12-22 20:33:49 +00:00
John Baldwin
d6fb489498 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
2015-12-15 00:05:07 +00:00
Ed Schouten
b0e787276b 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
2015-10-30 08:11:37 +00:00
Bryan Drewery
8c444cbc45 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
2015-10-13 18:23:51 +00:00
Bryan Drewery
7096af2e9e Let -c imply -S (hide signal output).
Without this, the signals are shown seemingly randomly in the output before
the final summary is shown.  This is especially noticeable when there is
not much output from the application being traced.

Discussed with:	jhb
Relnotes:	yes
2015-10-09 20:47:29 +00:00
Ed Schouten
808d980506 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
2015-10-08 05:27:45 +00:00
Bryan Drewery
04a97800bf Correct a comment. 2015-10-08 00:31:11 +00:00
Simon J. Gerraty
bd47c7ec11 Updated depends 2015-10-07 00:43:05 +00:00
Bryan Drewery
195aef9962 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
2015-10-06 21:58:38 +00:00
John Baldwin
f44fc79d0b Group the decoded system calls by ABI and sort the calls within each ABI.
Reviewed by:	bdrewery
Glanced at by:	kib
Differential Revision:	https://reviews.freebsd.org/D3823
2015-10-06 19:31:07 +00:00
Bryan Drewery
94746562ff Fix crash if a process sends itself a SIGTRAP. Just forward it as expected.
MFC after:	2 weeks [needs rewrite]
Relnotes:	yes
2015-10-05 21:39:07 +00:00
Bryan Drewery
47ff1ba642 Add decoding for modfind(2) 2015-10-05 18:11:30 +00:00
Bryan Drewery
6c61b0f324 Fix tracking of unknown syscalls for 'truss -c'.
This is done by changing get_syscall() to either lookup the known syscall
or add it into the list with the default handlers for printing.

This also simplifies some code to not have to check if the syscall variable
is set or NULL.

Reviewed by:	jhb
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D3792
2015-10-05 18:08:35 +00:00
Bryan Drewery
0a71c082d2 Style fix. 2015-10-03 19:08:36 +00:00
Bryan Drewery
a776866b44 Add decoding for struct statfs.
Reviewed by:	jhb (briefly)
2015-10-03 18:57:15 +00:00
Konstantin Belousov
5821213b4c Add aarch64 support to truss(1).
Reviewed by:	jhb
Discussed with:	emaste (license)
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D3750
2015-10-02 13:30:56 +00:00
Ed Schouten
2f9ebcc1a5 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.
2015-10-02 11:17:15 +00:00
John Baldwin
66917ca9d2 Rather than groveling around in a socket address structure for a socket
address's length (and then overriding it if it "looks wrong"), use the
next argument to the system call to determine the length.  This is more
reliable since this is what the kernel depends on anyway and is also
simpler.
2015-10-01 18:18:58 +00:00
John Baldwin
72df19e7ab The id_t type used to pass IDs to wait6(2) and procctl(6) is a 64-bit
integer.  Fix the argument decoding to treat this as a quad instead of an
int.  This includes using QUAD_ALIGN and QUAD_SLOTS as necessary.  To
continue printing IDs in decimal, add a new QuadHex argument type that
prints a 64-bit integer in hex, use QuadHex for the existing off_t arguments,
repurpose Quad to print a 64-bit integer in decimal, and use Quad for id_t
arguments.

This fixes the decoding of wait6(2) and procctl(2) on 32-bit platforms.
2015-10-01 17:50:41 +00:00
John Baldwin
df438f423d - Remove extra integer argument from truncate() and ftruncate(). This is
probably fallout from the removal of the extra padding argument before
  off_t in 7.  However, that padding still exists for 32-bit powerpc, so
  use QUAD_ALIGN.
- Fix QUAD_ALIGN to be zero for powerpc64.  It should only be set to 1
  for 32-bit platforms that add padding to align 64-bit arguments.
2015-10-01 17:28:07 +00:00
John Baldwin
2b75c8ad3d Several changes to truss.
- Refactor the interface between the ABI-independent code and the
  ABI-specific backends.  The backends now provide smaller hooks to
  fetch system call arguments and return values.  The rest of the
  system call entry and exit handling that was previously duplicated
  among all the backends has been moved to one place.
- Merge the loop when waiting for an event with the loop for handling stops.
  This also means not emulating a procfs-like interface on top of ptrace().
  Instead, use a single event loop that fetches process events via waitid().
  Among other things this allows us to report the full 32-bit exit value.
- Use PT_FOLLOW_FORK to follow new child processes instead of forking a new
  truss process for each new child.  This allows one truss process to monitor
  a tree of processes and truss -c should now display one total for the
  entire tree instead of separate summaries per process.
- Use the recently added fields to ptrace_lwpinfo to determine the current
  system call number and argument count.  The latter is especially useful
  and fixes a regression since the conversion from procfs.  truss now
  generally prints the correct number of arguments for most system calls
  rather than printing extra arguments for any call not listed in the
  table in syscalls.c.
- Actually check the new ABI when processes call exec.  The comments claimed
  that this happened but it was not being done (perhaps this was another
  regression in the conversion to ptrace()).  If the new ABI after exec
  is not supported, truss detaches from the process.  If truss does not
  support the ABI for a newly executed process the process is killed
  before it returns from exec.
- Along with the refactor, teach the various ABI-specific backends to
  fetch both return values, not just the first.  Use this to properly
  report the full 64-bit return value from lseek().  In addition, the
  handler for "pipe" now pulls the pair of descriptors out of the
  return values (which is the true kernel system call interface) but
  displays them as an argument (which matches the interface exported by
  libc).
- Each ABI handler adds entries to a linker set rather than requiring
  a statically defined table of handlers in main.c.
- The arm and mips system call fetching code was changed to follow the
  same pattern as amd64 (and the in-kernel handler) of fetching register
  arguments first and then reading any remaining arguments from the
  stack.  This should fix indirect system call arguments on at least
  arm.
- The mipsn32 and n64 ABIs will now look for arguments in A4 through A7.
- Use register %ebp for the 6th system call argument for Linux/i386 ABIs
  to match the in-kernel argument fetch code.
- For powerpc binaries on a powerpc64 system, fetch the extra arguments
  on the stack as 32-bit values that are then copied into the 64-bit
  argument array instead of reading the 32-bit values directly into the
  64-bit array.

Reviewed by:	kib (earlier version)
Tested on:	amd64 (FreeBSD/amd64 & i386), i386, arm (earlier version)
Tested on:	powerpc64 (FreeBSD/powerpc64 & powerpc)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D3575
2015-09-30 19:13:32 +00:00
John Baldwin
9e07e493b3 Trim trailing whitespace. 2015-09-30 00:08:24 +00:00
John Baldwin
a061e3c50f Decode recently added procctl(2) operations. 2015-09-29 23:54:26 +00:00
John Baldwin
68055893c1 Handle the conditional decoding of execve() argument and environment
arrays generically rather than duplicating a hack in all of the backends.
- Add two new system call argument types and use them instead of StringArray
  for the argument and environment arguments execve and linux_execve.
- Honor the -a/-e flags in the handling of these new types.
- Instead of printing "<missing argument>" when the decoding is disabled,
  print the raw pointer value.
2015-08-20 14:51:11 +00:00
John Baldwin
890843c15b Rework the argv and env string fetching for execve to be more robust.
Before truss would fetch 100 string pointers and happily walk off the end
of the array if it never found a NULL.  This also means for a short argv
list it could fail entirely if the 100 string pointers spanned into an
unmapped page.

Instead, fetch page-aligned blocks of string pointers in a loop fetching
each string until a NULL is found.

While here, make use of the open memstream file descriptor instead of
allocating a temporary array.  This allows us to fetch each string once
instead of twice.
2015-08-20 14:33:30 +00:00
John Baldwin
b38fbc2e54 ino_t is unsigned, so use uintmax_t instead of intmax_t when printing it.
Submitted by:	bde (sort of)
2015-08-19 20:10:58 +00:00
John Baldwin
a143677385 Always use %j with an intmax_t cast to print time_t values. time_t is
longer than long on 32-bit platforms with a 64-bit time_t.

Inspired by:	mail from bde
2015-08-19 20:09:14 +00:00
John Baldwin
4e3da534fc Various style and whitespace fixes. 2015-08-19 20:02:03 +00:00
John Baldwin
9346bf6f4a Use nitems(). 2015-08-19 19:59:42 +00:00
John Baldwin
c915ff0349 Expand the decoding of kevent structures.
- Print the ident value as decimal instead of hexadecimal for filter types
  that use "small" values such as file descriptors and PIDs.
- Decode NOTE_* flags in the fflags field of kevents for several system
  filter types.
2015-08-19 01:44:56 +00:00
John Baldwin
f083f6894c Change the argument formatting function to use a stdio FILE object opened
with open_memstream() to build the string for each argument.  This allows
for more complicated argument building without resorting to intermediate
malloc's, etc.

Related, the strsig*() functions no longer return allocated strings but
use a static global buffer instead.
2015-08-19 00:49:50 +00:00
John Baldwin
e462b12755 Use an xlat table and xlookup() instead of a home-rolled version for the
sigprocmask operation type.
2015-08-17 19:08:48 +00:00
John Baldwin
fb7eabb0bf Tidy the linux_socketcall decoding:
- Don't exit if get_struct() fails, instead print the raw pointer value to
  match all other argument decoding cases.
- Use an xlat table instead of a home-rolled switch for the operation name.
- Display the nested socketcall args structure as a structure instead of as
  two inline arguments.
2015-08-17 18:47:39 +00:00
John Baldwin
c9c2e2dc06 Decode the optional SOCK_NONBLOCK and SOCK_CLOEXEC flags passed in a
socket type.
2015-08-17 17:57:01 +00:00
John Baldwin
b289a8d78a - Decode the arguments for several signal-related system calls: sigpending,
sigqueue, sigreturn, sigsuspend, sigtimedwait, sigwait, sigwaitinfo, and
  thr_kill.
- Print signal sets as a structure (with {}'s) and in particular use this to
  differentiate empty sets from a NULL pointer.
- Decode arguments for some other system calls: issetugid, pipe2, sysarch
  (operations are only decoded for amd64 and i386), and thr_self.
2015-08-17 17:52:28 +00:00
John Baldwin
1e2ec671fc Consistently use both leading and trailing spaces inside of the {}'s
when pretty-printing structures.  Most structures used both spaces,
but some only used a trailing space and some used neither.
2015-08-06 20:05:40 +00:00
John Baldwin
0a46af44bf Whitespace fixes to consistently use spaces before }'s and
wrap long lines.
2015-08-06 19:36:47 +00:00
John Baldwin
7d89732757 Decode the arguments passed to the *at() family of system calls. This is
especially useful now that libc's open() always calls openat().  While here,
fix a few other things:
- Decode the mode argument passed to access(), eaccess(), and faccessat().
- Decode the atfd paramete to pretty-print AT_FDCWD.
- Decode the special AT_* flags used with some of the *at() system calls.
- Decode arguments for fchmod(), lchmod(), fchown(), lchown(), eaccess(),
  and futimens().
- Decode both of the timeval structures passed to futimes() instead of just
  the first one.
2015-08-06 19:08:33 +00:00
John Baldwin
e82ce59c37 Decode the arguments to mkfifo() and fix an off-by-one error in the arguments
to mknod().
2015-08-06 18:32:32 +00:00
John Baldwin
19d637849e Don't mark the fcntl flag argument as an output parameter so that it is
always decoded.  Previously the argument was not decoded if fcntl() failed.
2015-08-06 18:28:15 +00:00
John Baldwin
d98d7ba0b4 Add recently added values of various flags and enumerations including
kevent filters, kevent flags, flags to mmap, seek locations, fcntl
operations, file flags, socket domains, open flags, resource limits, and
pathconf values.
2015-08-06 01:49:18 +00:00
John Baldwin
abb3f965d1 Rework get_string() to make it more robust when fetching strings of unknown
length.  In particular, instead of blinding fetching 1k blocks, do an initial
fetch up to the end of the current page followed by page-sized fetches up to
the maximum size.  Previously if the 1k buffer crossed a page boundary and
the second page was not valid, the entire operation would fail.
2015-08-05 18:14:01 +00:00
John Baldwin
7582c8ea08 Whitespace fix: remove some spurious spaces before commas. 2015-08-05 18:10:46 +00:00
Ed Maste
6df1985625 truss: follow pdfork()ed descendents with -f
PR:		201276
Reported by:	David Drysdale
Reviewed by:	oshogbo
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D2976
2015-07-24 16:57:13 +00:00
Simon J. Gerraty
2ef6d5a7b9 new depends 2015-06-16 23:37:19 +00:00
Simon J. Gerraty
ccfb965433 Add META_MODE support.
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
2015-06-13 19:20:56 +00:00
Simon J. Gerraty
728d82cdd2 Use INCLUDEDIR rather than hard coded /usr/include
Differential Revision:	D2748
Reviewed by:	brooks imp
2015-06-11 14:25:53 +00:00
Simon J. Gerraty
44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Simon J. Gerraty
9268022b74 Merge from head@274682 2014-11-19 01:07:58 +00:00
John Baldwin
53e1ffbbce The current POSIX semaphore implementation stores the _has_waiters flag
in a separate word from the _count.  This does not permit both items to
be updated atomically in a portable manner.  As a result, sem_post()
must always perform a system call to safely clear _has_waiters.

This change removes the _has_waiters field and instead uses the high bit
of _count as the _has_waiters flag.  A new umtx object type (_usem2) and
two new umtx operations are added (SEM_WAIT2 and SEM_WAKE2) to implement
these semantics.  The older operations are still supported under the
COMPAT_FREEBSD9/10 options.  The POSIX semaphore API in libc has
been updated to use the new implementation.  Note that the new
implementation is not compatible with the previous implementation.
However, this only affects static binaries (which cannot be helped by
symbol versioning).  Binaries using a dynamic libc will continue to work
fine.  SEM_MAGIC has been bumped so that mismatched binaries will error
rather than corrupting a shared semaphore.  In addition, a padding field
has been added to sem_t so that it remains the same size.

Differential Revision:	https://reviews.freebsd.org/D961
Reported by:	adrian
Reviewed by:	kib, jilles (earlier version)
Sponsored by:	Norse
2014-10-24 20:02:44 +00:00
John Baldwin
5817298f31 Retire the unimplemented MAP_RENAME and MAP_NORESERVE flags to mmap(2).
Older binaries are still permitted to use these flags.

PR:		193961 (exp-run in ports)
Differential Revision:	https://reviews.freebsd.org/D848
Reviewed by:	kib
2014-10-18 12:28:51 +00:00
John Baldwin
fdb5bf37fa Decode the arguments passed to _umtx_op(). In particular, decode the
opcode.

MFC after:	1 week
Sponsored by:	Norse
2014-10-13 16:37:06 +00:00
Andrew Turner
b8fd1e31d9 Unify interrupts bit definition and usage. While here remove PSR_C_bit.
Submitted by:	Svatopluk Kraus <onwahe at gmail.com>,
		Michal Meloun <meloun at miracle.cz>
Differential Revision: https://reviews.freebsd.org/D754
2014-09-10 15:25:15 +00:00
Andrew Turner
adc9488df4 Stop accessing the saved stack pointer by looking past the end of the
array of registers.

Submitted by:	Michal Meloun <meloun at miracle.cz>
2014-09-10 13:07:01 +00:00
Simon J. Gerraty
ee7b0571c2 Merge head from 7/28 2014-08-19 06:50:54 +00:00
Marcel Moolenaar
e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00
Simon J. Gerraty
fae50821ae Updated dependencies 2014-05-16 14:09:51 +00:00
Simon J. Gerraty
76b28ad6ab Updated dependencies 2014-05-10 05:16:28 +00:00
Simon J. Gerraty
3b8f084595 Merge head 2014-04-28 07:50:45 +00:00
Steven Hartland
1c99a22a29 Add Linux socket call decoding to truss
MFC after:	1 month
2014-04-24 14:12:35 +00:00
Attilio Rao
ce42e79310 Remove dead code from umtx support:
- Retire long time unused (basically always unused) sys__umtx_lock()
  and sys__umtx_unlock() syscalls
- struct umtx and their supporting definitions
- UMUTEX_ERROR_CHECK flag
- Retire UMTX_OP_LOCK/UMTX_OP_UNLOCK from _umtx_op() syscall

__FreeBSD_version is not bumped yet because it is expected that further
breakages to the umtx interface will follow up in the next days.
However there will be a final bump when necessary.

Sponsored by:	EMC / Isilon storage division
Reviewed by:	jhb
2014-03-18 21:32:03 +00:00
Simon J. Gerraty
3caf0790a8 Merge head@256284 2013-10-13 02:35:19 +00:00
John Baldwin
55648840de Extend the support for exempting processes from being killed when swap is
exhausted.
- Add a new protect(1) command that can be used to set or revoke protection
  from arbitrary processes.  Similar to ktrace it can apply a change to all
  existing descendants of a process as well as future descendants.
- Add a new procctl(2) system call that provides a generic interface for
  control operations on processes (as opposed to the debugger-specific
  operations provided by ptrace(2)).  procctl(2) uses a combination of
  idtype_t and an id to identify the set of processes on which to operate
  similar to wait6().
- Add a PROC_SPROTECT control operation to manage the protection status
  of a set of processes.  MADV_PROTECT still works for backwards
  compatability.
- Add a p_flag2 to struct proc (and a corresponding ki_flag2 to kinfo_proc)
  the first bit of which is used to track if P_PROTECT should be inherited
  by new child processes.

Reviewed by:	kib, jilles (earlier version)
Approved by:	re (delphij)
MFC after:	1 month
2013-09-19 18:53:42 +00:00
John Baldwin
34763d1c9d - Decode the idtype argument passed to wait6() in kdump and truss.
- Don't treat an options argument of 0 to wait4() as an error in
  kdump.
- Decode the wait options passed to wait4() and wait6() in truss
  and decode the returned rusage and exit status.

Approved by:	re (kib)
MFC after:	1 week
2013-09-12 18:08:25 +00:00
Simon J. Gerraty
d466a5b069 Merge head 2013-09-11 18:16:18 +00:00
John Baldwin
edb572a38c Add a mmap flag (MAP_32BIT) on 64-bit platforms to request that a mapping use
an address in the first 2GB of the process's address space.  This flag should
have the same semantics as the same flag on Linux.

To facilitate this, add a new parameter to vm_map_find() that specifies an
optional maximum virtual address.  While here, fix several callers of
vm_map_find() to use a VMFS_* constant for the findspace argument instead of
TRUE and FALSE.

Reviewed by:	alc
Approved by:	re (kib)
2013-09-09 18:11:59 +00:00
Simon J. Gerraty
d1d0158641 Merge from head 2013-09-05 20:18:59 +00:00
John Baldwin
bf59b2c504 Remove incorrect 'const' qualifier from pointers to dynamic string
buffers I added in the previous commit.

Pointy hat to:	jhb
MFC after:	1 month
2013-08-19 17:09:14 +00:00
John Baldwin
5aa60b6f21 Add new mmap(2) flags to permit applications to request specific virtual
address alignment of mappings.
- MAP_ALIGNED(n) requests a mapping aligned on a boundary of (1 << n).
  Requests for n >= number of bits in a pointer or less than the size of
  a page fail with EINVAL.  This matches the API provided by NetBSD.
- MAP_ALIGNED_SUPER is a special case of MAP_ALIGNED.  It can be used
  to optimize the chances of using large pages.  By default it will align
  the mapping on a large page boundary (the system is free to choose any
  large page size to align to that seems best for the mapping request).
  However, if the object being mapped is already using large pages, then
  it will align the virtual mapping to match the existing large pages in
  the object instead.
- Internally, VMFS_ALIGNED_SPACE is now renamed to VMFS_SUPER_SPACE, and
  VMFS_ALIGNED_SPACE(n) is repurposed for specifying a specific alignment.
  MAP_ALIGNED(n) maps to using VMFS_ALIGNED_SPACE(n), while
  MAP_ALIGNED_SUPER maps to VMFS_SUPER_SPACE.
- mmap() of a device object now uses VMFS_OPTIMAL_SPACE rather than
  explicitly using VMFS_SUPER_SPACE.  All device objects are forced to
  use a specific color on creation, so VMFS_OPTIMAL_SPACE is effectively
  equivalent.

Reviewed by:	alc
MFC after:	1 month
2013-08-16 21:13:55 +00:00
Mark Johnston
9e1db66eb4 Properly print arguments to vfork(2) and rfork(2).
PR:		180976
Submitted by:	Yuri <yuri@tsoft.com> (original patch)
MFC after:	1 week
2013-08-01 02:57:04 +00:00
Mateusz Guzik
8f99c21f94 truss: recognize O_DIRECTORY, O_EXEC, O_TTY_INIT and O_CLOEXEC
MFC after:	3 days
2013-06-30 13:14:46 +00:00
Simon J. Gerraty
3655322b21 updated dirdeps 2013-05-09 22:29:33 +00:00
Simon J. Gerraty
0bc8845fb9 We no longer need to fiddle with INCLUDEDIR 2013-05-09 22:28:16 +00:00
Simon J. Gerraty
69e6d7b75e sync from head 2013-04-12 20:48:55 +00:00
Simon J. Gerraty
7cf3a1c6b2 Updated dependencies 2013-03-11 17:21:52 +00:00
Olivier Houchard
57fb38ba93 Add arm bits to truss. 2013-03-07 23:44:35 +00:00
Xin LI
d9dcc46365 Revert r247300 for now. I'll post a new changeset for review. 2013-02-26 19:46:59 +00:00
Xin LI
285a4c7c59 Expose timespec and timeval macros when __BSD_VISIBLE is defined. This
allows userland application to use the following macros:

	timespecclear, timespecisset, timespeccmp, timespecadd,
	timespecsub;

	timevalclear, timevalisset, timevalcmp.

MFC after:	1 month
2013-02-26 02:13:02 +00:00
Simon J. Gerraty
f5f7c05209 Updated dependencies 2013-02-16 01:23:54 +00:00
David E. O'Brien
d9a447559b Sync with HEAD. 2013-02-08 16:10:16 +00:00
Mateusz Guzik
c2b51d4457 truss: use 'e' flag for fopen instead of fcntl(.., FD_CLOEXEC) 2013-01-27 03:17:35 +00:00
Mateusz Guzik
8ff44cbb80 truss: if file requested with -o flag could not be opened print the reason
MFC after:	3 days
2013-01-27 03:14:54 +00:00
Simon J. Gerraty
adf23bef06 If we are staging, we need to look in the right place, for
the headers we want to examine.
2012-11-08 21:27:46 +00:00
Simon J. Gerraty
7cd2dcf076 Updated/new Makefile.depend 2012-11-08 21:24:17 +00:00
Simon J. Gerraty
23090366f7 Sync from head 2012-11-04 02:52:03 +00:00
Andrey Zonov
5695afded4 - Make truss thread-aware.
Approved by:	kib (mentor)
MFC after:	2 weeks
2012-09-16 14:38:01 +00:00
Andrey Zonov
896fc4638a - Fix detaching under some circumstances.
When truss is detaching from very active process it is possible to
  hang on waitpid(2) in restore_proc() forever, because
  ptrace(PT_SYSCALL) must be called before detaching, to allow the
  debugging process to continue execution.  Also when truss called with
  '-c' argument, it does not print anything after detach, because it
  immediately exits from restore_proc().

  To fix these two problems make detaching deferred, but then it is
  impossible to detach from a process which does not do any system call.
  To fix this issue use sigaction(2) instead of signal(3) to disable
  SA_RESTART flag for waitpid(2) that makes it non-restartable.  Remove
  global variable child_pid, because now detaching is handled in context
  where child's pid is known.

Reported by:	mjg
Tested by:	mjg, swills
Approved by:	kib (mentor)
MFC after:	2 weeks
2012-09-12 13:06:57 +00:00
Andrey Zonov
310da894b7 - Remove unused variables.
- Remove redundant return after err(3) call.

Approved by:	kib (mentor)
2012-09-11 16:30:26 +00:00
Andrey Zonov
94355cfdfd - Style(9) cleanup.
Approved by:	kib (mentor)
2012-09-02 11:03:18 +00:00
Andrey Zonov
46448452c0 - Remove unused variables.
- Fix warnings about comparing signed and unsigned ints.

Approved by:	kib (mentor)
2012-08-30 08:54:13 +00:00
Andrey Zonov
3ff6b7162e - Put arguments for print_syscall_ret() function in proper order.
Bug was introduced in r192025.

Approved by:	kib (mentor)
2012-08-23 12:20:29 +00:00
Marcel Moolenaar
7750ad47a9 Sync FreeBSD's bmake branch with Juniper's internal bmake branch.
Requested by: Simon Gerraty <sjg@juniper.net>
2012-08-22 19:25:57 +00:00
Andrey Zonov
be305c9c9f - Use pid_t type instead of just int.
Approved by:	kib (mentor)
2012-08-21 14:58:51 +00:00
Dimitry Andric
085e2c2102 Since truss also uses kdump's mkioctls script, pass the value of ${CPP}
there too, similar to r234058.

MFC after:	1 week
2012-04-09 15:34:22 +00:00
Ed Schouten
a02c83afc5 Add more static keywords to truss(1) source code.
There are some tables in the source code that are only used by the
individual source files themselves. Therefore there is no need to export
them.
2011-12-10 18:27:55 +00:00
Konstantin Belousov
97695ad4cd Use explicit information from the kernel to detect the traps due to
syscall entry and leave.

Based on submision by:	Dan Nelson <dnelson allantgroup com>
MFC after:	1 month
2011-12-04 18:43:09 +00:00
Dag-Erling Smørgrav
c04743dac1 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>
2011-10-21 11:08:25 +00:00
Benedict Reuschling
b2bf146e3e Fix typos in comments, no functional changes.
Found by:       codespell
Reviewed by:    alfred
MFC after:      1 week
2011-05-19 20:35:40 +00:00
Jilles Tjoelker
de55508483 Simplify various code that allowed for sys_signame being lower case.
This was changed in r218285.
2011-03-06 19:50:47 +00:00
John Baldwin
ad01891403 Properly check for errors from waitpid().
Submitted by:	gcooper
MFC after:	1 week
2011-02-15 12:42:18 +00:00
Jilles Tjoelker
12dacf622b Make sys_signame upper case.
This matches the constants from <signal.h> with 'SIG' removed, which POSIX
requires kill and trap to accept and 'kill -l' to write.

'kill -l', 'trap', 'trap -l' output is now upper case.

In Turkish locales, signal names with an upper case 'I' are now accepted,
while signal names with a lower case 'i' are no longer accepted, and the
output of 'killall -l' now contains proper capital 'I' without dot instead
of a dotted capital 'I'.
2011-02-04 16:40:50 +00:00
Jaakko Heinonen
cdfc719c2e Don't write the terminating NUL past end of buffer.
PR:		bin/152345
Submitted by:	Mateusz Guzik
2010-12-06 09:18:11 +00:00
Jaakko Heinonen
e04c378683 Set FD_CLOEXEC for the output file only when the file has been specified
with the -o option. Setting the flag for stderr (the default) could
cause the traced process to redirect stderr to a random file.

PR:		bin/152151
Submitted by:	ashish
MFC after:	5 days
2010-11-13 09:28:49 +00:00