diff options
author | jhb <jhb@FreeBSD.org> | 2016-01-26 19:07:09 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2016-01-26 19:07:09 +0000 |
commit | cd4a0ee266068abaf08833b8d76b0ad8b0cea721 (patch) | |
tree | 817dc34ebf9af56aa355e84eee2cf55753669285 /usr.bin/truss | |
parent | 1def741dc225d64b4a5b9f6ef7a3fb0b865294f5 (diff) | |
download | FreeBSD-src-cd4a0ee266068abaf08833b8d76b0ad8b0cea721.zip FreeBSD-src-cd4a0ee266068abaf08833b8d76b0ad8b0cea721.tar.gz |
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
Diffstat (limited to 'usr.bin/truss')
-rw-r--r-- | usr.bin/truss/Makefile | 23 | ||||
-rw-r--r-- | usr.bin/truss/aarch64-cloudabi64.c | 5 | ||||
-rw-r--r-- | usr.bin/truss/aarch64-freebsd.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/amd64-cloudabi64.c | 5 | ||||
-rw-r--r-- | usr.bin/truss/amd64-freebsd.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/amd64-freebsd32.c | 9 | ||||
-rw-r--r-- | usr.bin/truss/amd64-linux32.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/arm-freebsd.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/i386-freebsd.c | 9 | ||||
-rw-r--r-- | usr.bin/truss/i386-linux.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/main.c | 1 | ||||
-rw-r--r-- | usr.bin/truss/mips-freebsd.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/powerpc-freebsd.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/powerpc64-freebsd.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/powerpc64-freebsd32.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/setup.c | 4 | ||||
-rw-r--r-- | usr.bin/truss/sparc64-freebsd.c | 6 | ||||
-rw-r--r-- | usr.bin/truss/truss.h | 3 |
18 files changed, 35 insertions, 84 deletions
diff --git a/usr.bin/truss/Makefile b/usr.bin/truss/Makefile index a6e4524..b28098c 100644 --- a/usr.bin/truss/Makefile +++ b/usr.bin/truss/Makefile @@ -8,13 +8,6 @@ LIBADD= sysdecode CFLAGS+= -I${.CURDIR} -I. -I${.CURDIR}/../../sys -# Define where to generate syscalls for each ABI. -ABI_SYSPATH.freebsd= sys/kern -ABI_SYSPATH.freebsd32= sys/compat/freebsd32 -ABI_SYSPATH.cloudabi64= sys/compat/cloudabi64 -ABI_SYSPATH.i386-linux= sys/i386/linux -ABI_SYSPATH.amd64-linux32= sys/amd64/linux32 - ABIS+= freebsd # Each ABI is expected to have an ABI.c, MACHINE_ARCH-ABI.c or # MACHINE_CPUARCH-ABI.c file that will be used to map the syscall arguments. @@ -42,21 +35,7 @@ ABI_SRCS= ${abi}.c ${MACHINE_ARCH}-${abi}.c ${MACHINE_CPUARCH}-${abi}.c abi_src= ${f} .endif .endfor -SRCS:= ${SRCS} ${abi_src} ${abi}_syscalls.h -CLEANFILES+= ${abi}_syscalls.conf ${abi}_syscalls.master ${abi}_syscalls.h -${abi}_syscalls.conf: ${.CURDIR}/makesyscallsconf.sh - /bin/sh ${.CURDIR}/makesyscallsconf.sh ${abi} ${.TARGET} - -${abi}_syscalls.master: ${.CURDIR:H:H}/${ABI_SYSPATH.${abi}}/syscalls.master - cp -f ${.ALLSRC} ${.TARGET} - -${abi}_syscalls.h: ${abi}_syscalls.master ${abi}_syscalls.conf \ - ${.CURDIR:H:H}/sys/kern/makesyscalls.sh - /bin/sh ${.CURDIR:H:H}/sys/kern/makesyscalls.sh \ - ${abi}_syscalls.master ${abi}_syscalls.conf -# Eliminate compiler warning about non-static global. - sed -i '' '/^const char \*/s/^/static /' ${.TARGET}.tmp - mv ${.TARGET}.tmp ${.TARGET} +SRCS:= ${SRCS} ${abi_src} .endfor .include <bsd.prog.mk> diff --git a/usr.bin/truss/aarch64-cloudabi64.c b/usr.bin/truss/aarch64-cloudabi64.c index ad6afc2..099cb1e 100644 --- a/usr.bin/truss/aarch64-cloudabi64.c +++ b/usr.bin/truss/aarch64-cloudabi64.c @@ -33,9 +33,9 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <stdio.h> +#include <sysdecode.h> #include "cloudabi.h" -#include "cloudabi64_syscalls.h" #include "truss.h" static int @@ -81,8 +81,7 @@ aarch64_cloudabi64_fetch_retval(struct trussinfo *trussinfo, long *retval, static struct procabi aarch64_cloudabi64 = { "CloudABI ELF64", - syscallnames, - nitems(syscallnames), + CLOUDABI64, aarch64_cloudabi64_fetch_args, aarch64_cloudabi64_fetch_retval }; diff --git a/usr.bin/truss/aarch64-freebsd.c b/usr.bin/truss/aarch64-freebsd.c index 1ec2b66..454bba7 100644 --- a/usr.bin/truss/aarch64-freebsd.c +++ b/usr.bin/truss/aarch64-freebsd.c @@ -39,11 +39,10 @@ __FBSDID("$FreeBSD$"); #include <machine/ucontext.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd_syscalls.h" - static int aarch64_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -100,8 +99,7 @@ aarch64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) static struct procabi aarch64_freebsd = { "FreeBSD ELF64", - syscallnames, - nitems(syscallnames), + FREEBSD, aarch64_fetch_args, aarch64_fetch_retval }; diff --git a/usr.bin/truss/amd64-cloudabi64.c b/usr.bin/truss/amd64-cloudabi64.c index 5982b66..38768ff 100644 --- a/usr.bin/truss/amd64-cloudabi64.c +++ b/usr.bin/truss/amd64-cloudabi64.c @@ -33,9 +33,9 @@ __FBSDID("$FreeBSD$"); #include <errno.h> #include <stdio.h> +#include <sysdecode.h> #include "cloudabi.h" -#include "cloudabi64_syscalls.h" #include "truss.h" static int @@ -90,8 +90,7 @@ amd64_cloudabi64_fetch_retval(struct trussinfo *trussinfo, long *retval, static struct procabi amd64_cloudabi64 = { "CloudABI ELF64", - syscallnames, - nitems(syscallnames), + CLOUDABI64, amd64_cloudabi64_fetch_args, amd64_cloudabi64_fetch_retval }; diff --git a/usr.bin/truss/amd64-freebsd.c b/usr.bin/truss/amd64-freebsd.c index 0461616..8a211a0 100644 --- a/usr.bin/truss/amd64-freebsd.c +++ b/usr.bin/truss/amd64-freebsd.c @@ -41,11 +41,10 @@ __FBSDID("$FreeBSD$"); #include <machine/psl.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd_syscalls.h" - static int amd64_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -122,8 +121,7 @@ amd64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) static struct procabi amd64_freebsd = { "FreeBSD ELF64", - syscallnames, - nitems(syscallnames), + FREEBSD, amd64_fetch_args, amd64_fetch_retval }; diff --git a/usr.bin/truss/amd64-freebsd32.c b/usr.bin/truss/amd64-freebsd32.c index 82eb6cd..adce798 100644 --- a/usr.bin/truss/amd64-freebsd32.c +++ b/usr.bin/truss/amd64-freebsd32.c @@ -42,11 +42,10 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd32_syscalls.h" - static int amd64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -118,8 +117,7 @@ amd64_freebsd32_fetch_retval(struct trussinfo *trussinfo, long *retval, static struct procabi amd64_freebsd32 = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + FREEBSD32, amd64_freebsd32_fetch_args, amd64_freebsd32_fetch_retval }; @@ -128,8 +126,7 @@ PROCABI(amd64_freebsd32); static struct procabi amd64_freebsd32_aout = { "FreeBSD a.out", - syscallnames, - nitems(syscallnames), + FREEBSD32, amd64_freebsd32_fetch_args, amd64_freebsd32_fetch_retval }; diff --git a/usr.bin/truss/amd64-linux32.c b/usr.bin/truss/amd64-linux32.c index 17e5fdc..dd1d833 100644 --- a/usr.bin/truss/amd64-linux32.c +++ b/usr.bin/truss/amd64-linux32.c @@ -40,11 +40,10 @@ __FBSDID("$FreeBSD$"); #include <machine/psl.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "amd64-linux32_syscalls.h" - static int amd64_linux32_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -132,8 +131,7 @@ amd64_linux32_fetch_retval(struct trussinfo *trussinfo, long *retval, static struct procabi amd64_linux32 = { "Linux ELF32", - syscallnames, - nitems(syscallnames), + LINUX32, amd64_linux32_fetch_args, amd64_linux32_fetch_retval }; diff --git a/usr.bin/truss/arm-freebsd.c b/usr.bin/truss/arm-freebsd.c index aa7bccc..5722c91 100644 --- a/usr.bin/truss/arm-freebsd.c +++ b/usr.bin/truss/arm-freebsd.c @@ -42,11 +42,10 @@ __FBSDID("$FreeBSD$"); #include <machine/ucontext.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd_syscalls.h" - static int arm_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -129,8 +128,7 @@ arm_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) static struct procabi arm_freebsd = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + FREEBSD, arm_fetch_args, arm_fetch_retval }; diff --git a/usr.bin/truss/i386-freebsd.c b/usr.bin/truss/i386-freebsd.c index d9d72aa..c166596 100644 --- a/usr.bin/truss/i386-freebsd.c +++ b/usr.bin/truss/i386-freebsd.c @@ -41,11 +41,10 @@ __FBSDID("$FreeBSD$"); #include <machine/psl.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd_syscalls.h" - static int i386_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -111,8 +110,7 @@ i386_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) static struct procabi i386_freebsd = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + FREEBSD, i386_fetch_args, i386_fetch_retval }; @@ -121,8 +119,7 @@ PROCABI(i386_freebsd); static struct procabi i386_freebsd_aout = { "FreeBSD a.out", - syscallnames, - nitems(syscallnames), + FREEBSD, i386_fetch_args, i386_fetch_retval }; diff --git a/usr.bin/truss/i386-linux.c b/usr.bin/truss/i386-linux.c index 9166271..5fdae8e 100644 --- a/usr.bin/truss/i386-linux.c +++ b/usr.bin/truss/i386-linux.c @@ -40,11 +40,10 @@ __FBSDID("$FreeBSD$"); #include <machine/psl.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "i386-linux_syscalls.h" - static int i386_linux_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -131,8 +130,7 @@ i386_linux_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) static struct procabi i386_linux = { "Linux ELF32", - syscallnames, - nitems(syscallnames), + LINUX, i386_linux_fetch_args, i386_linux_fetch_retval }; diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index 5eec953..531d7db 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include <signal.h> #include <stdio.h> #include <stdlib.h> +#include <sysdecode.h> #include <time.h> #include <unistd.h> diff --git a/usr.bin/truss/mips-freebsd.c b/usr.bin/truss/mips-freebsd.c index 0c504b8..f4b5a7e 100644 --- a/usr.bin/truss/mips-freebsd.c +++ b/usr.bin/truss/mips-freebsd.c @@ -41,11 +41,10 @@ __FBSDID("$FreeBSD$"); #include <machine/reg.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd_syscalls.h" - static int mips_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -132,8 +131,7 @@ static struct procabi mips_freebsd = { #else "FreeBSD ELF32", #endif - syscallnames, - nitems(syscallnames), + FREEBSD, mips_fetch_args, mips_fetch_retval }; diff --git a/usr.bin/truss/powerpc-freebsd.c b/usr.bin/truss/powerpc-freebsd.c index 90c3663..6a245df 100644 --- a/usr.bin/truss/powerpc-freebsd.c +++ b/usr.bin/truss/powerpc-freebsd.c @@ -37,11 +37,10 @@ __FBSDID("$FreeBSD$"); #include <machine/frame.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd_syscalls.h" - static int powerpc_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -113,8 +112,7 @@ powerpc_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) static struct procabi powerpc_freebsd = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + FREEBSD, powerpc_fetch_args, powerpc_fetch_retval }; diff --git a/usr.bin/truss/powerpc64-freebsd.c b/usr.bin/truss/powerpc64-freebsd.c index fafaa1b..68a0b5d 100644 --- a/usr.bin/truss/powerpc64-freebsd.c +++ b/usr.bin/truss/powerpc64-freebsd.c @@ -37,11 +37,10 @@ __FBSDID("$FreeBSD$"); #include <machine/frame.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd_syscalls.h" - static int powerpc64_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -109,8 +108,7 @@ powerpc64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) static struct procabi powerpc64_freebsd = { "FreeBSD ELF64", - syscallnames, - nitems(syscallnames), + FREEBSD, powerpc64_fetch_args, powerpc64_fetch_retval }; diff --git a/usr.bin/truss/powerpc64-freebsd32.c b/usr.bin/truss/powerpc64-freebsd32.c index fc0ffb8..ee37ead 100644 --- a/usr.bin/truss/powerpc64-freebsd32.c +++ b/usr.bin/truss/powerpc64-freebsd32.c @@ -37,11 +37,10 @@ __FBSDID("$FreeBSD$"); #include <machine/frame.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd32_syscalls.h" - static int powerpc64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -118,8 +117,7 @@ powerpc64_freebsd32_fetch_retval(struct trussinfo *trussinfo, long *retval, int static struct procabi powerpc64_freebsd32 = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + FREEBSD32, powerpc64_freebsd32_fetch_args, powerpc64_freebsd32_fetch_retval }; diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index 74678e6..c0c15f0 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <sysdecode.h> #include <time.h> #include <unistd.h> @@ -335,8 +336,7 @@ enter_syscall(struct trussinfo *info, struct ptrace_lwpinfo *pl) return; } - if (t->cs.number >= 0 && t->cs.number < t->proc->abi->nsyscalls) - t->cs.name = t->proc->abi->syscallnames[t->cs.number]; + t->cs.name = sysdecode_syscallname(t->proc->abi->abi, t->cs.number); if (t->cs.name == NULL) fprintf(info->outfile, "-- UNKNOWN %s SYSCALL %d --\n", t->proc->abi->type, t->cs.number); diff --git a/usr.bin/truss/sparc64-freebsd.c b/usr.bin/truss/sparc64-freebsd.c index a4dba92..23486d7 100644 --- a/usr.bin/truss/sparc64-freebsd.c +++ b/usr.bin/truss/sparc64-freebsd.c @@ -43,11 +43,10 @@ __FBSDID("$FreeBSD$"); #include <stddef.h> #include <stdio.h> +#include <sysdecode.h> #include "truss.h" -#include "freebsd_syscalls.h" - static int sparc64_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -116,8 +115,7 @@ sparc64_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp) static struct procabi sparc64_freebsd = { "FreeBSD ELF64", - syscallnames, - nitems(syscallnames), + FREEBSD, sparc64_fetch_args, sparc64_fetch_retval }; diff --git a/usr.bin/truss/truss.h b/usr.bin/truss/truss.h index 5a57de7..5ef2444 100644 --- a/usr.bin/truss/truss.h +++ b/usr.bin/truss/truss.h @@ -41,8 +41,7 @@ struct trussinfo; struct procabi { const char *type; - const char **syscallnames; - int nsyscalls; + enum sysdecode_abi abi; int (*fetch_args)(struct trussinfo *, u_int); int (*fetch_retval)(struct trussinfo *, long *, int *); }; |