freebsd-dev/usr.bin/truss
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
..
aarch64-cloudabi64.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
aarch64-freebsd.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
amd64-cloudabi64.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
amd64-freebsd32.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
amd64-freebsd.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
amd64-linux32.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
amd64-linux.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
arm-freebsd.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
extern.h Move mksubr from kdump into libsysdecode. 2016-10-17 22:37:07 +00:00
i386-freebsd.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
i386-linux.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
main.c Move mksubr from kdump into libsysdecode. 2016-10-17 22:37:07 +00:00
Makefile Adopt SRCTOP in usr.bin 2017-03-12 18:58:44 +00:00
Makefile.depend DIRDEPS_BUILD: Update dependencies. 2016-02-16 02:14:30 +00:00
mips-freebsd.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
powerpc64-freebsd32.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
powerpc64-freebsd.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
powerpc-freebsd.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
riscv64-freebsd.c Add RISC-V support for truss(1) 2017-01-24 09:41:44 +00:00
setup.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
sparc64-freebsd.c Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
syscall.h Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00
syscalls.c Automate the handling of QUAD_ALIGN and QUAD_SLOTS. 2017-03-15 23:08:11 +00:00
truss.1 Add support for displaying thread IDs to truss(1). 2016-02-23 19:56:29 +00:00
truss.h Rework syscall structure lookups. 2016-12-06 00:39:00 +00:00