Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jan 2016 19:07:10 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r294849 - in head: lib/libsysdecode usr.bin/kdump usr.bin/truss
Message-ID:  <201601261907.u0QJ7A4r028489@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Tue Jan 26 19:07:09 2016
New Revision: 294849
URL: https://svnweb.freebsd.org/changeset/base/294849

Log:
  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

Added:
  head/lib/libsysdecode/syscallnames.c   (contents, props changed)
  head/lib/libsysdecode/sysdecode_syscallnames.3   (contents, props changed)
Modified:
  head/lib/libsysdecode/Makefile
  head/lib/libsysdecode/sysdecode.3
  head/lib/libsysdecode/sysdecode.h
  head/usr.bin/kdump/Makefile
  head/usr.bin/kdump/kdump.c
  head/usr.bin/truss/Makefile
  head/usr.bin/truss/aarch64-cloudabi64.c
  head/usr.bin/truss/aarch64-freebsd.c
  head/usr.bin/truss/amd64-cloudabi64.c
  head/usr.bin/truss/amd64-freebsd.c
  head/usr.bin/truss/amd64-freebsd32.c
  head/usr.bin/truss/amd64-linux32.c
  head/usr.bin/truss/arm-freebsd.c
  head/usr.bin/truss/i386-freebsd.c
  head/usr.bin/truss/i386-linux.c
  head/usr.bin/truss/main.c
  head/usr.bin/truss/mips-freebsd.c
  head/usr.bin/truss/powerpc-freebsd.c
  head/usr.bin/truss/powerpc64-freebsd.c
  head/usr.bin/truss/powerpc64-freebsd32.c
  head/usr.bin/truss/setup.c
  head/usr.bin/truss/sparc64-freebsd.c
  head/usr.bin/truss/truss.h

Modified: head/lib/libsysdecode/Makefile
==============================================================================
--- head/lib/libsysdecode/Makefile	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/lib/libsysdecode/Makefile	Tue Jan 26 19:07:09 2016	(r294849)
@@ -4,11 +4,14 @@
 
 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_ioctlname.3 \
+	sysdecode_syscallnames.3 \
 	sysdecode_utrace.3
 
 CLEANFILES= ioctl.c
@@ -23,6 +26,10 @@ CFLAGS+=-DPF
 
 # Workaround duplicate declarations in <netinet/ip_compat.h>
 CFLAGS.gcc.ioctl.c+= -Wno-redundant-decls
+
+# Workaround warning for unused ssi_cables[] in <dev/lmc/if_lmc.h>
+CFLAGS.gcc.ioctl.c+= -Wno-unused
+
 CFLAGS.gcc+=	${CFLAGS.gcc.${.IMPSRC}}
 
 ioctl.c: mkioctls

Added: head/lib/libsysdecode/syscallnames.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libsysdecode/syscallnames.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -0,0 +1,105 @@
+/*-
+ * Copyright (c) 2015 John H. Baldwin <jhb@FreeBSD.org>
+ * 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 <sys/cdefs.h>
+__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 <sys/param.h>
+#include <stdio.h>
+#include <sysdecode.h>
+
+static
+#include <kern/syscalls.c>
+
+#if defined(__amd64__) || defined(__powerpc64__)
+static
+#include <compat/freebsd32/freebsd32_syscalls.c>
+#endif
+
+#if defined(__amd64__) || defined(__i386__)
+static
+#ifdef __amd64__
+#include <amd64/linux/linux_syscalls.c>
+#else
+#include <i386/linux/linux_syscalls.c>
+#endif
+#endif
+
+#ifdef __amd64__
+static
+#include <amd64/linux32/linux32_syscalls.c>
+#endif
+
+#if defined(__amd64__) || defined(__aarch64__)
+static
+#include <compat/cloudabi64/cloudabi64_syscalls.c>
+#endif
+
+const char *
+sysdecode_syscallname(enum sysdecode_abi abi, unsigned int code)
+{
+
+	switch (abi) {
+	case FREEBSD:
+		if (code < nitems(syscallnames))
+			return (syscallnames[code]);
+		break;
+#if defined(__amd64__) || defined(__powerpc64__)
+	case FREEBSD32:
+		if (code < nitems(freebsd32_syscallnames))
+			return (freebsd32_syscallnames[code]);
+		break;
+#endif
+#if defined(__amd64__) || defined(__i386__)
+	case LINUX:
+		if (code < nitems(linux_syscallnames))
+			return (linux_syscallnames[code]);
+		break;
+#endif
+#ifdef __amd64__
+	case LINUX32:
+		if (code < nitems(linux32_syscallnames))
+			return (linux32_syscallnames[code]);
+		break;
+#endif
+#if defined(__amd64__) || defined(__aarch64__)
+	case CLOUDABI64:
+		if (code < nitems(cloudabi64_syscallnames))
+			return (cloudabi64_syscallnames[code]);
+		break;
+#endif
+	default:
+		break;
+	}
+	return (NULL);
+}

Modified: head/lib/libsysdecode/sysdecode.3
==============================================================================
--- head/lib/libsysdecode/sysdecode.3	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/lib/libsysdecode/sysdecode.3	Tue Jan 26 19:07:09 2016	(r294849)
@@ -25,7 +25,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd December 10, 2015
+.Dd January 24, 2016
 .Dt SYSDECODE 3
 .Os
 .Sh NAME
@@ -38,8 +38,34 @@ The
 .Nm
 library includes several functions that provide descriptive names of
 values associated with system calls.
+.Ss Supported ABIs
+Some functions in this library provide ABI-specific descriptions.
+The supported ABIs are named by the
+.Vt enum sysdecode_abi
+enumeration.
+.Pp
+.Bl -tag -width "Li UNKNOWN_ABI" -compact
+.It Li FREEBSD
+Native FreeBSD binaries.
+Supported on all platforms.
+.It Li FREEBSD32
+32-bit FreeBSD binaries.
+Supported on amd64 and powerpc64.
+.It Li LINUX
+Linux binaries of the same platform.
+Supported on amd64 and i386.
+.It Li LINUX32
+32-bit Linux binaries.
+Supported on amd64.
+.It Li CLOUDABI64
+64-bit CloudABI binaries.
+Supported on aarch64 and amd64.
+.It Li UNKNOWN_ABI
+A placeholder for use when the ABI is not known.
+.El
 .Sh SEE ALSO
 .Xr sysdecode_ioctlname 3 ,
+.Xr sysdecode_syscallnames 3 ,
 .Xr sysdecode_utrace 3
 .Sh HISTORY
 The

Modified: head/lib/libsysdecode/sysdecode.h
==============================================================================
--- head/lib/libsysdecode/sysdecode.h	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/lib/libsysdecode/sysdecode.h	Tue Jan 26 19:07:09 2016	(r294849)
@@ -29,7 +29,17 @@
 #ifndef __SYSDECODE_H__
 #define	__SYSDECODE_H__
 
+enum sysdecode_abi {
+	UNKNOWN_ABI = 0,
+	FREEBSD,
+	FREEBSD32,
+	LINUX,
+	LINUX32,
+	CLOUDABI64
+};
+
 const char *sysdecode_ioctlname(unsigned long _val);
+const char *sysdecode_syscallname(enum sysdecode_abi _abi, unsigned int _code);
 int	sysdecode_utrace(FILE *_fp, void *_buf, size_t _len);
 
 #endif /* !__SYSDECODE_H__ */

Added: head/lib/libsysdecode/sysdecode_syscallnames.3
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lib/libsysdecode/sysdecode_syscallnames.3	Tue Jan 26 19:07:09 2016	(r294849)
@@ -0,0 +1,67 @@
+.\"
+.\" Copyright (c) 2016 John Baldwin <jhb@FreeBSD.org>
+.\" 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 January 24, 2016
+.Dt sysdecode_syscallnames 3
+.Os
+.Sh NAME
+.Nm sysdecode_syscallnames
+.Nd lookup name of system calls
+.Sh LIBRARY
+.Lb libsysdecode
+.Sh SYNOPSIS
+.Ft const char *
+.Fn sysdecode_syscallnames "enum sysdecode_abi abi" "unsigned int code"
+.Sh DESCRIPTION
+This function returns a pointer to the name of a system call identified by
+.Fa code
+for the process ABI
+.Fa abi .
+If
+.Fa code
+specifies an unknown system call or
+.Fa abi
+is an unsupported ABI,
+.Nm
+returns
+.Dv NULL .
+.Pp
+For the list of supported ABIs,
+see
+.Xr sysdecode 3 .
+.Sh RETURN VALUES
+The
+.Nm
+function returns a pointer to a string on success or
+.Dv NULL
+if either
+.Fa code
+or
+.Fa ABI
+is invalid .
+.Sh SEE ALSO
+.Xr sysdecode 3

Modified: head/usr.bin/kdump/Makefile
==============================================================================
--- head/usr.bin/kdump/Makefile	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/kdump/Makefile	Tue Jan 26 19:07:09 2016	(r294849)
@@ -19,25 +19,6 @@ NO_WERROR?=	YES
 
 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}

Modified: head/usr.bin/kdump/kdump.c
==============================================================================
--- head/usr.bin/kdump/kdump.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/kdump/kdump.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -122,8 +122,7 @@ void usage(void);
 #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 @@ static struct ktr_header ktr_header;
 
 #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 <linux_syscalls.c>
 
 /*
  * from linux.h
@@ -169,12 +164,6 @@ static int bsd_to_linux_errno[ELAST + 1]
 };
 #endif
 
-#if defined(__amd64__)
-extern const char *linux32_syscallnames[];
-
-#include <linux32_syscalls.c>
-#endif
-
 struct proc_info
 {
 	TAILQ_ENTRY(proc_info)	info;
@@ -401,13 +390,7 @@ main(int argc, char *argv[])
 		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 @@ dumpheader(struct ktr_header *kth)
 }
 
 #include <sys/syscall.h>
-#define KTRACE
-#include <sys/kern/syscalls.c>
-#undef KTRACE
-int nsyscalls = sizeof (syscallnames) / sizeof (syscallnames[0]);
 
 static void
 ioctlname(unsigned long val)
@@ -706,26 +685,57 @@ ioctlname(unsigned long val)
 		printf("%#lx", val);
 }
 
+static enum sysdecode_abi
+syscallabi(u_int sv_flags)
+{
+
+	if (sv_flags == 0)
+		return (FREEBSD);
+	switch (sv_flags & SV_ABI_MASK) {
+	case SV_ABI_FREEBSD:
+		return (FREEBSD);
+#if defined(__amd64__) || defined(__i386__)
+	case SV_ABI_LINUX:
+#ifdef __amd64__
+		if (sv_flags & SV_ILP32)
+			return (LINUX32);
+#endif
+		return (LINUX);
+#endif
+	default:
+		return (UNKNOWN_ABI);
+	}
+}
+
+static void
+syscallname(u_int code, u_int sv_flags)
+{
+	const char *name;
+
+	name = sysdecode_syscallname(syscallabi(sv_flags), code);
+	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 +1342,13 @@ ktrsyscall(struct ktr_syscall *ktr, u_in
 }
 
 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 +1853,14 @@ ktrfaultend(struct ktr_faultend *ktr)
 }
 
 #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) {

Modified: head/usr.bin/truss/Makefile
==============================================================================
--- head/usr.bin/truss/Makefile	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/Makefile	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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
 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>

Modified: head/usr.bin/truss/aarch64-cloudabi64.c
==============================================================================
--- head/usr.bin/truss/aarch64-cloudabi64.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/aarch64-cloudabi64.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 t
 
 static struct procabi aarch64_cloudabi64 = {
 	"CloudABI ELF64",
-	syscallnames,
-	nitems(syscallnames),
+	CLOUDABI64,
 	aarch64_cloudabi64_fetch_args,
 	aarch64_cloudabi64_fetch_retval
 };

Modified: head/usr.bin/truss/aarch64-freebsd.c
==============================================================================
--- head/usr.bin/truss/aarch64-freebsd.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/aarch64-freebsd.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 *t
 
 static struct procabi aarch64_freebsd = {
 	"FreeBSD ELF64",
-	syscallnames,
-	nitems(syscallnames),
+	FREEBSD,
 	aarch64_fetch_args,
 	aarch64_fetch_retval
 };

Modified: head/usr.bin/truss/amd64-cloudabi64.c
==============================================================================
--- head/usr.bin/truss/amd64-cloudabi64.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/amd64-cloudabi64.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 tru
 
 static struct procabi amd64_cloudabi64 = {
 	"CloudABI ELF64",
-	syscallnames,
-	nitems(syscallnames),
+	CLOUDABI64,
 	amd64_cloudabi64_fetch_args,
 	amd64_cloudabi64_fetch_retval
 };

Modified: head/usr.bin/truss/amd64-freebsd.c
==============================================================================
--- head/usr.bin/truss/amd64-freebsd.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/amd64-freebsd.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 *tru
 
 static struct procabi amd64_freebsd = {
 	"FreeBSD ELF64",
-	syscallnames,
-	nitems(syscallnames),
+	FREEBSD,
 	amd64_fetch_args,
 	amd64_fetch_retval
 };

Modified: head/usr.bin/truss/amd64-freebsd32.c
==============================================================================
--- head/usr.bin/truss/amd64-freebsd32.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/amd64-freebsd32.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 trus
 
 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
 };

Modified: head/usr.bin/truss/amd64-linux32.c
==============================================================================
--- head/usr.bin/truss/amd64-linux32.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/amd64-linux32.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 trussi
 
 static struct procabi amd64_linux32 = {
 	"Linux ELF32",
-	syscallnames,
-	nitems(syscallnames),
+	LINUX32,
 	amd64_linux32_fetch_args,
 	amd64_linux32_fetch_retval
 };

Modified: head/usr.bin/truss/arm-freebsd.c
==============================================================================
--- head/usr.bin/truss/arm-freebsd.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/arm-freebsd.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 *truss
 
 static struct procabi arm_freebsd = {
 	"FreeBSD ELF32",
-	syscallnames,
-	nitems(syscallnames),
+	FREEBSD,
 	arm_fetch_args,
 	arm_fetch_retval
 };

Modified: head/usr.bin/truss/i386-freebsd.c
==============================================================================
--- head/usr.bin/truss/i386-freebsd.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/i386-freebsd.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 *trus
 
 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
 };

Modified: head/usr.bin/truss/i386-linux.c
==============================================================================
--- head/usr.bin/truss/i386-linux.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/i386-linux.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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
 
 static struct procabi i386_linux = {
 	"Linux ELF32",
-	syscallnames,
-	nitems(syscallnames),
+	LINUX,
 	i386_linux_fetch_args,
 	i386_linux_fetch_retval
 };

Modified: head/usr.bin/truss/main.c
==============================================================================
--- head/usr.bin/truss/main.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/main.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$");
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <sysdecode.h>
 #include <time.h>
 #include <unistd.h>
 

Modified: head/usr.bin/truss/mips-freebsd.c
==============================================================================
--- head/usr.bin/truss/mips-freebsd.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/mips-freebsd.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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
 };

Modified: head/usr.bin/truss/powerpc-freebsd.c
==============================================================================
--- head/usr.bin/truss/powerpc-freebsd.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/powerpc-freebsd.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 *t
 
 static struct procabi powerpc_freebsd = {
 	"FreeBSD ELF32",
-	syscallnames,
-	nitems(syscallnames),
+	FREEBSD,
 	powerpc_fetch_args,
 	powerpc_fetch_retval
 };

Modified: head/usr.bin/truss/powerpc64-freebsd.c
==============================================================================
--- head/usr.bin/truss/powerpc64-freebsd.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/powerpc64-freebsd.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 
 
 static struct procabi powerpc64_freebsd = {
 	"FreeBSD ELF64",
-	syscallnames,
-	nitems(syscallnames),
+	FREEBSD,
 	powerpc64_fetch_args,
 	powerpc64_fetch_retval
 };

Modified: head/usr.bin/truss/powerpc64-freebsd32.c
==============================================================================
--- head/usr.bin/truss/powerpc64-freebsd32.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/powerpc64-freebsd32.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 
 
 static struct procabi powerpc64_freebsd32 = {
 	"FreeBSD ELF32",
-	syscallnames,
-	nitems(syscallnames),
+	FREEBSD32,
 	powerpc64_freebsd32_fetch_args,
 	powerpc64_freebsd32_fetch_retval
 };

Modified: head/usr.bin/truss/setup.c
==============================================================================
--- head/usr.bin/truss/setup.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/setup.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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, st
 		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);

Modified: head/usr.bin/truss/sparc64-freebsd.c
==============================================================================
--- head/usr.bin/truss/sparc64-freebsd.c	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/sparc64-freebsd.c	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 *t
 
 static struct procabi sparc64_freebsd = {
 	"FreeBSD ELF64",
-	syscallnames,
-	nitems(syscallnames),
+	FREEBSD,
 	sparc64_fetch_args,
 	sparc64_fetch_retval
 };

Modified: head/usr.bin/truss/truss.h
==============================================================================
--- head/usr.bin/truss/truss.h	Tue Jan 26 18:39:31 2016	(r294848)
+++ head/usr.bin/truss/truss.h	Tue Jan 26 19:07:09 2016	(r294849)
@@ -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 *);
 };



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601261907.u0QJ7A4r028489>