Index: lib/libsysdecode/Makefile =================================================================== --- lib/libsysdecode/Makefile +++ lib/libsysdecode/Makefile @@ -4,12 +4,19 @@ LIB= sysdecode -SRCS= ioctl.c utrace.c +SRCS= ioctl.c syscallnames.c utrace.c INCS= sysdecode.h +CFLAGS+= -I${.CURDIR}/../../sys + MAN+= sysdecode.3 \ + sysdecode_freebsd.3 \ sysdecode_ioctlname.3 \ sysdecode_utrace.3 +MLINKS+=sysdecode_freebsd.3 sysdecode_cloudabi64.3 \ + sysdecode_freebsd.3 sysdecode_freebsd32.3 \ + sysdecode_freebsd.3 sysdecode_linux.3 \ + sysdecode_freebsd.3 sysdecode_linux32.3 CLEANFILES= ioctl.c @@ -23,6 +30,10 @@ # Workaround duplicate declarations in CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls + +# Workaround warning for unused ssi_cables[] in +CFLAGS.gcc.ioctl.c+= -Wno-unused + CFLAGS.gcc+= ${CFLAGS.gcc.${.IMPSRC}} ioctl.c: mkioctls Index: lib/libsysdecode/syscallnames.c =================================================================== --- /dev/null +++ lib/libsysdecode/syscallnames.c @@ -0,0 +1,111 @@ +/*- + * Copyright (c) 2015 John H. Baldwin + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +__FBSDID("$FreeBSD$"); + +/* + * Map system call codes to names for the supported ABIs on each + * platform. Rather than regnerating system call name tables locally + * during the build, use the generated tables in the kernel source + * tree. + */ + +#include +#include +#include + +static +#include + +const char * +sysdecode_freebsd(unsigned int code) +{ + + if (code < nitems(syscallnames)) + return (syscallnames[code]); + return (NULL); +} + +#if defined(__amd64__) || defined(__powerpc64__) +static +#include + +const char * +sysdecode_freebsd32(unsigned int code) +{ + + if (code < nitems(freebsd32_syscallnames)) + return (freebsd32_syscallnames[code]); + return (NULL); +} +#endif + +#if defined(__amd64__) || defined(__aarch64__) +static +#include + +const char * +sysdecode_cloudabi64(unsigned int code) +{ + + if (code < nitems(cloudabi64_syscallnames)) + return (cloudabi64_syscallnames[code]); + return (NULL); +} +#endif + +#if defined(__amd64__) || defined(__i386__) +static +#ifdef __amd64__ +#include +#else +#include +#endif + +const char * +sysdecode_linux(unsigned int code) +{ + + if (code < nitems(linux_syscallnames)) + return (linux_syscallnames[code]); + return (NULL); +} +#endif + +#ifdef __amd64__ +static +#include + +const char * +sysdecode_linux32(unsigned int code) +{ + + if (code < nitems(linux32_syscallnames)) + return (linux32_syscallnames[code]); + return (NULL); +} +#endif Index: lib/libsysdecode/sysdecode.h =================================================================== --- lib/libsysdecode/sysdecode.h +++ lib/libsysdecode/sysdecode.h @@ -29,7 +29,20 @@ #ifndef __SYSDECODE_H__ #define __SYSDECODE_H__ +#if defined(__amd64__) || defined(__aarch64__) +const char *sysdecode_cloudabi64(unsigned int _code); +#endif +const char *sysdecode_freebsd(unsigned int _code); +#if defined(__amd64__) || defined(__powerpc64__) +const char *sysdecode_freebsd32(unsigned int _code); +#endif const char *sysdecode_ioctlname(unsigned long _val); +#if defined(__amd64__) || defined(__i386__) +const char *sysdecode_linux(unsigned int _code); +#if defined(__amd64__) +const char *sysdecode_linux32(unsigned int _code); +#endif +#endif int sysdecode_utrace(FILE *_fp, void *_buf, size_t _len); #endif /* !__SYSDECODE_H__ */ Index: lib/libsysdecode/sysdecode.3 =================================================================== --- lib/libsysdecode/sysdecode.3 +++ lib/libsysdecode/sysdecode.3 @@ -39,6 +39,7 @@ library includes several functions that provide descriptive names of values associated with system calls. .Sh SEE ALSO +.Xr sysdecode_freebsd 3 , .Xr sysdecode_ioctlname 3 , .Xr sysdecode_utrace 3 .Sh HISTORY Index: lib/libsysdecode/sysdecode_freebsd.3 =================================================================== --- /dev/null +++ lib/libsysdecode/sysdecode_freebsd.3 @@ -0,0 +1,96 @@ +.\" +.\" Copyright (c) 2015 John Baldwin +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 2, 2015 +.Dt sysdecode_freebsd 3 +.Os +.Sh NAME +.Nm sysdecode_cloudabi64 , +.Nm sysdecode_freebsd , +.Nm sysdecode_freebsd32 , +.Nm sysdecode_linux , +.Nm sysdecode_linux32 +.Nd lookup name of system calls +.Sh LIBRARY +.Lb libsysdecode +.Sh SYNOPSIS +.Ft const char * +.Fn sysdecode_cloudabi64 "unsigned int code" +.Ft const char * +.Fn sysdecode_freebsd "unsigned int code" +.Ft const char * +.Fn sysdecode_freebsd32 "unsigned int code" +.Ft const char * +.Fn sysdecode_linux "unsigned int code" +.Ft const char * +.Fn sysdecode_linux32 "unsigned int code" +.Sh DESCRIPTION +These functions return a pointer to the name of a system call identified by +.Fa code +for different process ABIs. +If +.Fa code +specifies an unknown system call, +these functions return +.Dv NULL . +.Pp +The +.Fn sysdecode_freebsd +function returns the name of the native FreeBSD system call identified by +.Fa code . +.Pp +The +.Fn sysdecode_freebsd32 +function returns the name of the 32-bit FreeBSD system call identified by +.Fa code . +This function is only supported on amd64 and powerpc64. +.Pp +The +.fn sysdecode_cloudabi64 +function returns the name of the 64-bit CloudABI system call identified by +.Fa code . +This function is only supported on aarch64 and amd64. +.Pp +The +.Fn sysdecode_linux +function returns the name of the native Linux system call identified by +.Fa code . +This function is only supported on amd64 and i386. +.Pp +The +.Fn sysdecode_linux32 +function returns the name of the 32-bit Linux system call identified by +.Fa code . +This function is only supported on amd64. +.Sh RETURN VALUES +These functions return a pointer to a string on success or +.Dv NULL +if +.Fa code +is unknown. +.Sh SEE ALSO +.Xr sysdecode 3 Index: usr.bin/kdump/Makefile =================================================================== --- usr.bin/kdump/Makefile +++ usr.bin/kdump/Makefile @@ -19,25 +19,6 @@ CLEANFILES= kdump_subr.c kdump_subr.h -.if (${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386") -beforedepend: linux_syscalls.c - -CLEANFILES+= linux_syscalls.c -kdump.o: linux_syscalls.c -linux_syscalls.c: linux_syscalls.conf - sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \ - ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux/syscalls.master ${.CURDIR}/linux_syscalls.conf -.endif -.if (${MACHINE_ARCH} == "amd64") -beforedepend: linux32_syscalls.c - -CLEANFILES+= linux32_syscalls.c -kdump.o: linux32_syscalls.c -linux32_syscalls.c: linux32_syscalls.conf - sh ${.CURDIR}/../../sys/kern/makesyscalls.sh \ - ${.CURDIR}/../../sys/${MACHINE_ARCH}/linux32/syscalls.master ${.CURDIR}/linux32_syscalls.conf -.endif - kdump_subr.h: mksubr sh ${.CURDIR}/mksubr ${DESTDIR}${INCLUDEDIR} | \ sed -n 's/^\([a-z].*)\)$$/void \1;/p' >${.TARGET} Index: usr.bin/kdump/kdump.c =================================================================== --- usr.bin/kdump/kdump.c +++ usr.bin/kdump/kdump.c @@ -122,8 +122,7 @@ #define TIMESTAMP_ELAPSED 0x2 #define TIMESTAMP_RELATIVE 0x4 -extern const char *signames[], *syscallnames[]; -extern int nsyscalls; +extern const char *signames[]; static int timestamp, decimal, fancy = 1, suppressdata, tail, threads, maxdata, resolv = 0, abiflag = 0, syscallno = 0; @@ -145,11 +144,7 @@ #if defined(__amd64__) || defined(__i386__) -void linux_ktrsyscall(struct ktr_syscall *, u_int); void linux_ktrsysret(struct ktr_sysret *, u_int); -extern const char *linux_syscallnames[]; - -#include /* * from linux.h @@ -169,12 +164,6 @@ }; #endif -#if defined(__amd64__) -extern const char *linux32_syscallnames[]; - -#include -#endif - struct proc_info { TAILQ_ENTRY(proc_info) info; @@ -401,13 +390,7 @@ drop_logged = 0; switch (ktr_header.ktr_type) { case KTR_SYSCALL: -#if defined(__amd64__) || defined(__i386__) - if ((sv_flags & SV_ABI_MASK) == SV_ABI_LINUX) - linux_ktrsyscall((struct ktr_syscall *)m, - sv_flags); - else -#endif - ktrsyscall((struct ktr_syscall *)m, sv_flags); + ktrsyscall((struct ktr_syscall *)m, sv_flags); break; case KTR_SYSRET: #if defined(__amd64__) || defined(__i386__) @@ -687,10 +670,6 @@ } #include -#define KTRACE -#include -#undef KTRACE -int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]); static void ioctlname(unsigned long val) @@ -706,26 +685,56 @@ printf("%#lx", val); } +static void +syscallname(u_int code, u_int sv_flags) +{ + const char *name; + + if (sv_flags == 0) + name = sysdecode_freebsd(code); + else { + switch (sv_flags & SV_ABI_MASK) { + case SV_ABI_FREEBSD: + name = sysdecode_freebsd(code); + break; +#if defined(__amd64__) || defined(__i386__) + case SV_ABI_LINUX: +#ifdef __amd64__ + if (sv_flags & SV_ILP32) + name = sysdecode_linux32(code); + else +#endif + name = sysdecode_linux(code); + break; +#endif + default: + name = NULL; + } + } + + if (name == NULL) + printf("[%d]", code); + else { + printf("%s", name); + if (syscallno) + printf("[%d]", code); + } +} + void -ktrsyscall(struct ktr_syscall *ktr, u_int flags) +ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags) { int narg = ktr->ktr_narg; register_t *ip; intmax_t arg; - if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || - (ktr->ktr_code >= nsyscalls || ktr->ktr_code < 0)) - printf("[%d]", ktr->ktr_code); - else { - printf("%s", syscallnames[ktr->ktr_code]); - if (syscallno) - printf("[%d]", ktr->ktr_code); - } + syscallname(ktr->ktr_code, sv_flags); ip = &ktr->ktr_args[0]; if (narg) { char c = '('; if (fancy && - (flags == 0 || (flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) { + (sv_flags == 0 || + (sv_flags & SV_ABI_MASK) == SV_ABI_FREEBSD)) { switch (ktr->ktr_code) { case SYS_bindat: case SYS_connectat: @@ -1332,21 +1341,13 @@ } void -ktrsysret(struct ktr_sysret *ktr, u_int flags) +ktrsysret(struct ktr_sysret *ktr, u_int sv_flags) { register_t ret = ktr->ktr_retval; int error = ktr->ktr_error; - int code = ktr->ktr_code; - if ((flags != 0 && ((flags & SV_ABI_MASK) != SV_ABI_FREEBSD)) || - (code >= nsyscalls || code < 0)) - printf("[%d] ", code); - else { - printf("%s", syscallnames[code]); - if (syscallno) - printf("[%d]", code); - printf(" "); - } + syscallname(ktr->ktr_code, sv_flags); + printf(" "); if (error == 0) { if (fancy) { @@ -1851,56 +1852,14 @@ } #if defined(__amd64__) || defined(__i386__) - -#if defined(__amd64__) -#define NLINUX_SYSCALLS(v) ((v) & SV_ILP32 ? \ - nitems(linux32_syscallnames) : nitems(linux_syscallnames)) -#define LINUX_SYSCALLNAMES(v, i) ((v) & SV_ILP32 ? \ - linux32_syscallnames[i] : linux_syscallnames[i]) -#else -#define NLINUX_SYSCALLS(v) (nitems(linux_syscallnames)) -#define LINUX_SYSCALLNAMES(v, i) (linux_syscallnames[i]) -#endif - -void -linux_ktrsyscall(struct ktr_syscall *ktr, u_int sv_flags) -{ - int narg = ktr->ktr_narg; - unsigned code = ktr->ktr_code; - register_t *ip; - - if (ktr->ktr_code < 0 || code >= NLINUX_SYSCALLS(sv_flags)) - printf("[%d]", ktr->ktr_code); - else { - printf("%s", LINUX_SYSCALLNAMES(sv_flags, ktr->ktr_code)); - if (syscallno) - printf("[%d]", ktr->ktr_code); - } - ip = &ktr->ktr_args[0]; - if (narg) { - char c = '('; - while (narg > 0) - print_number(ip, narg, c); - putchar(')'); - } - putchar('\n'); -} - void linux_ktrsysret(struct ktr_sysret *ktr, u_int sv_flags) { register_t ret = ktr->ktr_retval; - unsigned code = ktr->ktr_code; int error = ktr->ktr_error; - if (ktr->ktr_code < 0 || code >= NLINUX_SYSCALLS(sv_flags)) - printf("[%d] ", ktr->ktr_code); - else { - printf("%s ", LINUX_SYSCALLNAMES(sv_flags, code)); - if (syscallno) - printf("[%d]", code); - printf(" "); - } + syscallname(ktr->ktr_code, sv_flags); + printf(" "); if (error == 0) { if (fancy) { Index: usr.bin/truss/Makefile =================================================================== --- usr.bin/truss/Makefile +++ usr.bin/truss/Makefile @@ -8,13 +8,6 @@ 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_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 Index: usr.bin/truss/aarch64-cloudabi64.c =================================================================== --- usr.bin/truss/aarch64-cloudabi64.c +++ usr.bin/truss/aarch64-cloudabi64.c @@ -33,9 +33,9 @@ #include #include +#include #include "cloudabi.h" -#include "cloudabi64_syscalls.h" #include "truss.h" static int @@ -81,8 +81,7 @@ static struct procabi aarch64_cloudabi64 = { "CloudABI ELF64", - syscallnames, - nitems(syscallnames), + sysdecode_cloudabi64, aarch64_cloudabi64_fetch_args, aarch64_cloudabi64_fetch_retval }; Index: usr.bin/truss/aarch64-freebsd.c =================================================================== --- usr.bin/truss/aarch64-freebsd.c +++ usr.bin/truss/aarch64-freebsd.c @@ -39,11 +39,10 @@ #include #include +#include #include "truss.h" -#include "freebsd_syscalls.h" - static int aarch64_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -100,8 +99,7 @@ static struct procabi aarch64_freebsd = { "FreeBSD ELF64", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, aarch64_fetch_args, aarch64_fetch_retval }; Index: usr.bin/truss/amd64-cloudabi64.c =================================================================== --- usr.bin/truss/amd64-cloudabi64.c +++ usr.bin/truss/amd64-cloudabi64.c @@ -33,9 +33,9 @@ #include #include +#include #include "cloudabi.h" -#include "cloudabi64_syscalls.h" #include "truss.h" static int @@ -90,8 +90,7 @@ static struct procabi amd64_cloudabi64 = { "CloudABI ELF64", - syscallnames, - nitems(syscallnames), + sysdecode_cloudabi64, amd64_cloudabi64_fetch_args, amd64_cloudabi64_fetch_retval }; Index: usr.bin/truss/amd64-freebsd.c =================================================================== --- usr.bin/truss/amd64-freebsd.c +++ usr.bin/truss/amd64-freebsd.c @@ -41,11 +41,10 @@ #include #include +#include #include "truss.h" -#include "freebsd_syscalls.h" - static int amd64_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -122,8 +121,7 @@ static struct procabi amd64_freebsd = { "FreeBSD ELF64", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, amd64_fetch_args, amd64_fetch_retval }; Index: usr.bin/truss/amd64-freebsd32.c =================================================================== --- usr.bin/truss/amd64-freebsd32.c +++ usr.bin/truss/amd64-freebsd32.c @@ -42,11 +42,10 @@ #include #include +#include #include "truss.h" -#include "freebsd32_syscalls.h" - static int amd64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -118,8 +117,7 @@ static struct procabi amd64_freebsd32 = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd32, amd64_freebsd32_fetch_args, amd64_freebsd32_fetch_retval }; @@ -128,8 +126,7 @@ static struct procabi amd64_freebsd32_aout = { "FreeBSD a.out", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd32, amd64_freebsd32_fetch_args, amd64_freebsd32_fetch_retval }; Index: usr.bin/truss/amd64-linux32.c =================================================================== --- usr.bin/truss/amd64-linux32.c +++ usr.bin/truss/amd64-linux32.c @@ -40,11 +40,10 @@ #include #include +#include #include "truss.h" -#include "amd64-linux32_syscalls.h" - static int amd64_linux32_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -132,8 +131,7 @@ static struct procabi amd64_linux32 = { "Linux ELF32", - syscallnames, - nitems(syscallnames), + sysdecode_linux32, amd64_linux32_fetch_args, amd64_linux32_fetch_retval }; Index: usr.bin/truss/arm-freebsd.c =================================================================== --- usr.bin/truss/arm-freebsd.c +++ usr.bin/truss/arm-freebsd.c @@ -42,11 +42,10 @@ #include #include +#include #include "truss.h" -#include "freebsd_syscalls.h" - static int arm_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -129,8 +128,7 @@ static struct procabi arm_freebsd = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, arm_fetch_args, arm_fetch_retval }; Index: usr.bin/truss/i386-freebsd.c =================================================================== --- usr.bin/truss/i386-freebsd.c +++ usr.bin/truss/i386-freebsd.c @@ -41,11 +41,10 @@ #include #include +#include #include "truss.h" -#include "freebsd_syscalls.h" - static int i386_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -111,8 +110,7 @@ static struct procabi i386_freebsd = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, i386_fetch_args, i386_fetch_retval }; @@ -121,8 +119,7 @@ static struct procabi i386_freebsd_aout = { "FreeBSD a.out", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, i386_fetch_args, i386_fetch_retval }; Index: usr.bin/truss/i386-linux.c =================================================================== --- usr.bin/truss/i386-linux.c +++ usr.bin/truss/i386-linux.c @@ -40,11 +40,10 @@ #include #include +#include #include "truss.h" -#include "i386-linux_syscalls.h" - static int i386_linux_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -131,8 +130,7 @@ static struct procabi i386_linux = { "Linux ELF32", - syscallnames, - nitems(syscallnames), + sysdecode_linux, i386_linux_fetch_args, i386_linux_fetch_retval }; Index: usr.bin/truss/mips-freebsd.c =================================================================== --- usr.bin/truss/mips-freebsd.c +++ usr.bin/truss/mips-freebsd.c @@ -41,11 +41,10 @@ #include #include +#include #include "truss.h" -#include "freebsd_syscalls.h" - static int mips_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -132,8 +131,7 @@ #else "FreeBSD ELF32", #endif - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, mips_fetch_args, mips_fetch_retval }; Index: usr.bin/truss/powerpc-freebsd.c =================================================================== --- usr.bin/truss/powerpc-freebsd.c +++ usr.bin/truss/powerpc-freebsd.c @@ -37,11 +37,10 @@ #include #include +#include #include "truss.h" -#include "freebsd_syscalls.h" - static int powerpc_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -113,8 +112,7 @@ static struct procabi powerpc_freebsd = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, powerpc_fetch_args, powerpc_fetch_retval }; Index: usr.bin/truss/powerpc64-freebsd.c =================================================================== --- usr.bin/truss/powerpc64-freebsd.c +++ usr.bin/truss/powerpc64-freebsd.c @@ -37,11 +37,10 @@ #include #include +#include #include "truss.h" -#include "freebsd_syscalls.h" - static int powerpc64_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -109,8 +108,7 @@ static struct procabi powerpc64_freebsd = { "FreeBSD ELF64", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, powerpc64_fetch_args, powerpc64_fetch_retval }; Index: usr.bin/truss/powerpc64-freebsd32.c =================================================================== --- usr.bin/truss/powerpc64-freebsd32.c +++ usr.bin/truss/powerpc64-freebsd32.c @@ -37,11 +37,10 @@ #include #include +#include #include "truss.h" -#include "freebsd32_syscalls.h" - static int powerpc64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -118,8 +117,7 @@ static struct procabi powerpc64_freebsd32 = { "FreeBSD ELF32", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd32, powerpc64_freebsd32_fetch_args, powerpc64_freebsd32_fetch_retval }; Index: usr.bin/truss/setup.c =================================================================== --- usr.bin/truss/setup.c +++ usr.bin/truss/setup.c @@ -335,8 +335,7 @@ 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 = t->proc->abi->syscall_name(t->cs.number); if (t->cs.name == NULL) fprintf(info->outfile, "-- UNKNOWN %s SYSCALL %d --\n", t->proc->abi->type, t->cs.number); Index: usr.bin/truss/sparc64-freebsd.c =================================================================== --- usr.bin/truss/sparc64-freebsd.c +++ usr.bin/truss/sparc64-freebsd.c @@ -43,11 +43,10 @@ #include #include +#include #include "truss.h" -#include "freebsd_syscalls.h" - static int sparc64_fetch_args(struct trussinfo *trussinfo, u_int narg) { @@ -116,8 +115,7 @@ static struct procabi sparc64_freebsd = { "FreeBSD ELF64", - syscallnames, - nitems(syscallnames), + sysdecode_freebsd, sparc64_fetch_args, sparc64_fetch_retval }; Index: usr.bin/truss/truss.h =================================================================== --- usr.bin/truss/truss.h +++ usr.bin/truss/truss.h @@ -41,8 +41,7 @@ struct procabi { const char *type; - const char **syscallnames; - int nsyscalls; + const char *(*syscall_name)(u_int); int (*fetch_args)(struct trussinfo *, u_int); int (*fetch_retval)(struct trussinfo *, long *, int *); };