svn commit: r289239 - head/usr.bin/truss
Bryan Drewery
bdrewery at FreeBSD.org
Tue Oct 13 18:23:54 UTC 2015
Author: bdrewery
Date: Tue Oct 13 18:23:51 2015
New Revision: 289239
URL: https://svnweb.freebsd.org/changeset/base/289239
Log:
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
Added:
head/usr.bin/truss/aarch64-freebsd.c
- copied, changed from r289238, head/usr.bin/truss/aarch64-fbsd.c
head/usr.bin/truss/amd64-freebsd.c
- copied, changed from r289057, head/usr.bin/truss/amd64-fbsd.c
head/usr.bin/truss/amd64-freebsd32.c
- copied, changed from r289057, head/usr.bin/truss/amd64-fbsd32.c
head/usr.bin/truss/arm-freebsd.c
- copied, changed from r289057, head/usr.bin/truss/arm-fbsd.c
head/usr.bin/truss/i386-freebsd.c
- copied, changed from r289057, head/usr.bin/truss/i386-fbsd.c
head/usr.bin/truss/makesyscallsconf.sh (contents, props changed)
head/usr.bin/truss/mips-freebsd.c
- copied, changed from r289057, head/usr.bin/truss/mips-fbsd.c
head/usr.bin/truss/powerpc-freebsd.c
- copied, changed from r289057, head/usr.bin/truss/powerpc-fbsd.c
head/usr.bin/truss/powerpc64-freebsd.c
- copied, changed from r289057, head/usr.bin/truss/powerpc64-fbsd.c
head/usr.bin/truss/powerpc64-freebsd32.c
- copied, changed from r289057, head/usr.bin/truss/powerpc-fbsd.c
head/usr.bin/truss/sparc64-freebsd.c
- copied, changed from r289057, head/usr.bin/truss/sparc64-fbsd.c
Deleted:
head/usr.bin/truss/aarch64-fbsd.c
head/usr.bin/truss/amd64-fbsd.c
head/usr.bin/truss/amd64-fbsd32.c
head/usr.bin/truss/amd64cloudabi64.conf
head/usr.bin/truss/amd64linux32.conf
head/usr.bin/truss/arm-fbsd.c
head/usr.bin/truss/fbsd32.conf
head/usr.bin/truss/i386-fbsd.c
head/usr.bin/truss/i386.conf
head/usr.bin/truss/i386linux.conf
head/usr.bin/truss/mips-fbsd.c
head/usr.bin/truss/powerpc-fbsd.c
head/usr.bin/truss/powerpc64-fbsd.c
head/usr.bin/truss/sparc64-fbsd.c
Modified:
head/usr.bin/truss/Makefile
head/usr.bin/truss/Makefile.depend.amd64
head/usr.bin/truss/amd64-cloudabi64.c
head/usr.bin/truss/amd64-linux32.c
head/usr.bin/truss/i386-linux.c
Modified: head/usr.bin/truss/Makefile
==============================================================================
--- head/usr.bin/truss/Makefile Tue Oct 13 17:34:18 2015 (r289238)
+++ head/usr.bin/truss/Makefile Tue Oct 13 18:23:51 2015 (r289239)
@@ -2,87 +2,64 @@
NO_WERROR=
PROG= truss
-SRCS= main.c setup.c syscalls.c syscalls.h ioctl.c
-
-.if exists(${.CURDIR}/${MACHINE_ARCH}-fbsd.c)
-SRCS+= ${MACHINE_ARCH}-fbsd.c
-.else
-SRCS+= ${MACHINE_CPUARCH}-fbsd.c
-.endif
+SRCS= main.c setup.c syscalls.c ioctl.c
.PATH: ${.CURDIR:H}/kdump
SRCS+= utrace.c
CFLAGS+= -I${.CURDIR} -I. -I${.CURDIR}/../../sys
-CLEANFILES= syscalls.master syscalls.h ioctl.c
-
-.SUFFIXES: .master
-
-syscalls.master: ${.CURDIR}/../../sys/kern/syscalls.master
- cat ${.ALLSRC} > syscalls.master
-
-syscalls.h: syscalls.master
- /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh syscalls.master \
- ${.CURDIR}/i386.conf
+CLEANFILES= ioctl.c
ioctl.c: ${.CURDIR}/../kdump/mkioctls
env MACHINE=${MACHINE} CPP="${CPP}" \
/bin/sh ${.CURDIR}/../kdump/mkioctls return ${DESTDIR}${INCLUDEDIR} > ${.TARGET}
+# 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.
.if ${MACHINE_CPUARCH} == "i386"
-SRCS+= i386-linux.c linux_syscalls.h
-CLEANFILES+=i386l-syscalls.master linux_syscalls.h
-
-i386l-syscalls.master: ${.CURDIR}/../../sys/i386/linux/syscalls.master
- cat ${.ALLSRC} > ${.TARGET}
-
-linux_syscalls.h: i386l-syscalls.master
- /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \
- ${.CURDIR}/i386linux.conf
+ABIS+= i386-linux
.endif
-
.if ${MACHINE_CPUARCH} == "amd64"
-SRCS+= amd64-linux32.c linux32_syscalls.h
-CLEANFILES+=amd64l32-syscalls.master linux32_syscalls.h
-
-amd64l32-syscalls.master: ${.CURDIR}/../../sys/amd64/linux32/syscalls.master
- cat ${.ALLSRC} > ${.TARGET}
-
-linux32_syscalls.h: amd64l32-syscalls.master
- /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \
- ${.CURDIR}/amd64linux32.conf
-
-SRCS+= amd64-fbsd32.c freebsd32_syscalls.h
-CLEANFILES+=fbsd32-syscalls.master freebsd32_syscalls.h
-
-fbsd32-syscalls.master: ${.CURDIR}/../../sys/compat/freebsd32/syscalls.master
- cat ${.ALLSRC} > ${.TARGET}
-
-freebsd32_syscalls.h: fbsd32-syscalls.master
- /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \
- ${.CURDIR}/fbsd32.conf
-
-SRCS+= amd64-cloudabi64.c cloudabi64_syscalls.h
-CLEANFILES+=amd64cloudabi64-syscalls.master cloudabi64_syscalls.h
-
-amd64cloudabi64-syscalls.master: ${.CURDIR}/../../sys/compat/cloudabi64/syscalls.master
- cat ${.ALLSRC} > ${.TARGET}
-
-cloudabi64_syscalls.h: amd64cloudabi64-syscalls.master
- /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \
- ${.CURDIR}/amd64cloudabi64.conf
+ABIS+= amd64-linux32
+ABIS+= freebsd32
+ABIS+= cloudabi64
.endif
-
.if ${MACHINE_ARCH} == "powerpc64"
-SRCS+= powerpc-fbsd.c freebsd32_syscalls.h
-CLEANFILES+=fbsd32-syscalls.master freebsd32_syscalls.h
-
-fbsd32-syscalls.master: ${.CURDIR}/../../sys/compat/freebsd32/syscalls.master
- cat ${.ALLSRC} > ${.TARGET}
+ABIS+= freebsd32
+.endif
-freebsd32_syscalls.h: fbsd32-syscalls.master
- /bin/sh ${.CURDIR}/../../sys/kern/makesyscalls.sh ${.ALLSRC} \
- ${.CURDIR}/fbsd32.conf
+.for abi in ${ABIS}
+# Find the right file to handle this ABI.
+abi_src=
+ABI_SRCS= ${abi}.c ${MACHINE_ARCH}-${abi}.c ${MACHINE_CPUARCH}-${abi}.c
+.for f in ${ABI_SRCS}
+.if exists(${.CURDIR}/${f}) && empty(abi_src)
+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}
+.endfor
.include <bsd.prog.mk>
Modified: head/usr.bin/truss/Makefile.depend.amd64
==============================================================================
--- head/usr.bin/truss/Makefile.depend.amd64 Tue Oct 13 17:34:18 2015 (r289238)
+++ head/usr.bin/truss/Makefile.depend.amd64 Tue Oct 13 18:23:51 2015 (r289239)
@@ -19,12 +19,12 @@ DIRDEPS = \
# local dependencies - needed for -jN in clean tree
amd64-cloudabi64.o: cloudabi64_syscalls.h
amd64-cloudabi64.po: cloudabi64_syscalls.h
-amd64-fbsd.o: syscalls.h
-amd64-fbsd.po: syscalls.h
-amd64-fbsd32.o: freebsd32_syscalls.h
-amd64-fbsd32.po: freebsd32_syscalls.h
-amd64-linux32.o: linux32_syscalls.h
-amd64-linux32.po: linux32_syscalls.h
+amd64-freebsd.o: freebsd_syscalls.h
+amd64-freebsd.po: freebsd_syscalls.h
+amd64-freebsd32.o: freebsd32_syscalls.h
+amd64-freebsd32.po: freebsd32_syscalls.h
+amd64-linux32.o: amd64-linux32_syscalls.h
+amd64-linux32.po: amd64-linux32_syscalls.h
ioctl.o: ioctl.c
ioctl.po: ioctl.c
.endif
Copied and modified: head/usr.bin/truss/aarch64-freebsd.c (from r289238, head/usr.bin/truss/aarch64-fbsd.c)
==============================================================================
--- head/usr.bin/truss/aarch64-fbsd.c Tue Oct 13 17:34:18 2015 (r289238, copy source)
+++ head/usr.bin/truss/aarch64-freebsd.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -42,8 +42,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-extern const char *syscallnames[]; /* silence compiler */
-#include "syscalls.h"
+#include "freebsd_syscalls.h"
static int
aarch64_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -99,7 +98,7 @@ aarch64_fetch_retval(struct trussinfo *t
return (0);
}
-static struct procabi aarch64_fbsd = {
+static struct procabi aarch64_freebsd = {
"FreeBSD ELF64",
syscallnames,
nitems(syscallnames),
@@ -107,4 +106,4 @@ static struct procabi aarch64_fbsd = {
aarch64_fetch_retval
};
-PROCABI(aarch64_fbsd);
+PROCABI(aarch64_freebsd);
Modified: head/usr.bin/truss/amd64-cloudabi64.c
==============================================================================
--- head/usr.bin/truss/amd64-cloudabi64.c Tue Oct 13 17:34:18 2015 (r289238)
+++ head/usr.bin/truss/amd64-cloudabi64.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -171,8 +171,8 @@ amd64_cloudabi64_fetch_retval(struct tru
static struct procabi amd64_cloudabi64 = {
"CloudABI ELF64",
- cloudabi64_syscallnames,
- nitems(cloudabi64_syscallnames),
+ syscallnames,
+ nitems(syscallnames),
amd64_cloudabi64_fetch_args,
amd64_cloudabi64_fetch_retval
};
Copied and modified: head/usr.bin/truss/amd64-freebsd.c (from r289057, head/usr.bin/truss/amd64-fbsd.c)
==============================================================================
--- head/usr.bin/truss/amd64-fbsd.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/amd64-freebsd.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#include "syscalls.h"
+#include "freebsd_syscalls.h"
static int
amd64_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -120,7 +120,7 @@ amd64_fetch_retval(struct trussinfo *tru
return (0);
}
-static struct procabi amd64_fbsd = {
+static struct procabi amd64_freebsd = {
"FreeBSD ELF64",
syscallnames,
nitems(syscallnames),
@@ -128,4 +128,4 @@ static struct procabi amd64_fbsd = {
amd64_fetch_retval
};
-PROCABI(amd64_fbsd);
+PROCABI(amd64_freebsd);
Copied and modified: head/usr.bin/truss/amd64-freebsd32.c (from r289057, head/usr.bin/truss/amd64-fbsd32.c)
==============================================================================
--- head/usr.bin/truss/amd64-fbsd32.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/amd64-freebsd32.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -32,7 +32,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-/* FreeBSD/i386-specific system call handling. */
+/* FreeBSD/amd64-freebsd32-specific system call handling. */
#include <sys/ptrace.h>
#include <sys/syscall.h>
@@ -48,7 +48,7 @@ __FBSDID("$FreeBSD$");
#include "freebsd32_syscalls.h"
static int
-amd64_fbsd32_fetch_args(struct trussinfo *trussinfo, u_int narg)
+amd64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg)
{
struct ptrace_io_desc iorequest;
struct reg regs;
@@ -98,7 +98,7 @@ amd64_fbsd32_fetch_args(struct trussinfo
}
static int
-amd64_fbsd32_fetch_retval(struct trussinfo *trussinfo, long *retval,
+amd64_freebsd32_fetch_retval(struct trussinfo *trussinfo, long *retval,
int *errorp)
{
struct reg regs;
@@ -116,22 +116,22 @@ amd64_fbsd32_fetch_retval(struct trussin
return (0);
}
-static struct procabi amd64_fbsd32 = {
+static struct procabi amd64_freebsd32 = {
"FreeBSD ELF32",
- freebsd32_syscallnames,
- nitems(freebsd32_syscallnames),
- amd64_fbsd32_fetch_args,
- amd64_fbsd32_fetch_retval
+ syscallnames,
+ nitems(syscallnames),
+ amd64_freebsd32_fetch_args,
+ amd64_freebsd32_fetch_retval
};
-PROCABI(amd64_fbsd32);
+PROCABI(amd64_freebsd32);
-static struct procabi amd64_fbsd32_aout = {
+static struct procabi amd64_freebsd32_aout = {
"FreeBSD a.out",
- freebsd32_syscallnames,
- nitems(freebsd32_syscallnames),
- amd64_fbsd32_fetch_args,
- amd64_fbsd32_fetch_retval
+ syscallnames,
+ nitems(syscallnames),
+ amd64_freebsd32_fetch_args,
+ amd64_freebsd32_fetch_retval
};
-PROCABI(amd64_fbsd32_aout);
+PROCABI(amd64_freebsd32_aout);
Modified: head/usr.bin/truss/amd64-linux32.c
==============================================================================
--- head/usr.bin/truss/amd64-linux32.c Tue Oct 13 17:34:18 2015 (r289238)
+++ head/usr.bin/truss/amd64-linux32.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#include "linux32_syscalls.h"
+#include "amd64-linux32_syscalls.h"
static int
amd64_linux32_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -132,8 +132,8 @@ amd64_linux32_fetch_retval(struct trussi
static struct procabi amd64_linux32 = {
"Linux ELF32",
- linux32_syscallnames,
- nitems(linux32_syscallnames),
+ syscallnames,
+ nitems(syscallnames),
amd64_linux32_fetch_args,
amd64_linux32_fetch_retval
};
Copied and modified: head/usr.bin/truss/arm-freebsd.c (from r289057, head/usr.bin/truss/arm-fbsd.c)
==============================================================================
--- head/usr.bin/truss/arm-fbsd.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/arm-freebsd.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#include "syscalls.h"
+#include "freebsd_syscalls.h"
static int
arm_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -127,7 +127,7 @@ arm_fetch_retval(struct trussinfo *truss
return (0);
}
-static struct procabi arm_fbsd = {
+static struct procabi arm_freebsd = {
"FreeBSD ELF32",
syscallnames,
nitems(syscallnames),
@@ -135,4 +135,4 @@ static struct procabi arm_fbsd = {
arm_fetch_retval
};
-PROCABI(arm_fbsd);
+PROCABI(arm_freebsd);
Copied and modified: head/usr.bin/truss/i386-freebsd.c (from r289057, head/usr.bin/truss/i386-fbsd.c)
==============================================================================
--- head/usr.bin/truss/i386-fbsd.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/i386-freebsd.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#include "syscalls.h"
+#include "freebsd_syscalls.h"
static int
i386_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -109,7 +109,7 @@ i386_fetch_retval(struct trussinfo *trus
return (0);
}
-static struct procabi i386_fbsd = {
+static struct procabi i386_freebsd = {
"FreeBSD ELF32",
syscallnames,
nitems(syscallnames),
@@ -117,9 +117,9 @@ static struct procabi i386_fbsd = {
i386_fetch_retval
};
-PROCABI(i386_fbsd);
+PROCABI(i386_freebsd);
-static struct procabi i386_fbsd_aout = {
+static struct procabi i386_freebsd_aout = {
"FreeBSD a.out",
syscallnames,
nitems(syscallnames),
@@ -127,5 +127,5 @@ static struct procabi i386_fbsd_aout = {
i386_fetch_retval
};
-PROCABI(i386_fbsd_aout);
+PROCABI(i386_freebsd_aout);
Modified: head/usr.bin/truss/i386-linux.c
==============================================================================
--- head/usr.bin/truss/i386-linux.c Tue Oct 13 17:34:18 2015 (r289238)
+++ head/usr.bin/truss/i386-linux.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#include "linux_syscalls.h"
+#include "i386-linux_syscalls.h"
static int
i386_linux_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -131,8 +131,8 @@ i386_linux_fetch_retval(struct trussinfo
static struct procabi i386_linux = {
"Linux ELF32",
- linux_syscallnames,
- nitems(linux_syscallnames),
+ syscallnames,
+ nitems(syscallnames),
i386_linux_fetch_args,
i386_linux_fetch_retval
};
Added: head/usr.bin/truss/makesyscallsconf.sh
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/usr.bin/truss/makesyscallsconf.sh Tue Oct 13 18:23:51 2015 (r289239)
@@ -0,0 +1,21 @@
+#! /bin/sh
+# $FreeBSD$
+
+ABI="$1"
+CONF="$2"
+
+header="${ABI}_syscalls.h"
+
+cat > "${CONF}" << EOF
+sysnames="${header}.tmp"
+sysproto="/dev/null"
+sysproto_h="/dev/null"
+syshdr="/dev/null"
+sysmk="/dev/null"
+syssw="/dev/null"
+syshide="/dev/null"
+syscallprefix="SYS_"
+switchname="sysent"
+namesname="syscallnames"
+systrace="/dev/null"
+EOF
Copied and modified: head/usr.bin/truss/mips-freebsd.c (from r289057, head/usr.bin/truss/mips-fbsd.c)
==============================================================================
--- head/usr.bin/truss/mips-fbsd.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/mips-freebsd.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#include "syscalls.h"
+#include "freebsd_syscalls.h"
static int
mips_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -126,7 +126,7 @@ mips_fetch_retval(struct trussinfo *trus
}
-static struct procabi mips_fbsd = {
+static struct procabi mips_freebsd = {
#ifdef __mips_n64
"FreeBSD ELF64",
#else
@@ -138,4 +138,4 @@ static struct procabi mips_fbsd = {
mips_fetch_retval
};
-PROCABI(mips_fbsd);
+PROCABI(mips_freebsd);
Copied and modified: head/usr.bin/truss/powerpc-freebsd.c (from r289057, head/usr.bin/truss/powerpc-fbsd.c)
==============================================================================
--- head/usr.bin/truss/powerpc-fbsd.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/powerpc-freebsd.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -40,12 +40,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#ifdef __powerpc64__ /* 32-bit compatibility */
-#include "freebsd32_syscalls.h"
-#define syscallnames freebsd32_syscallnames
-#else /* native 32-bit */
-#include "syscalls.h"
-#endif
+#include "freebsd_syscalls.h"
static int
powerpc_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -82,34 +77,16 @@ powerpc_fetch_args(struct trussinfo *tru
}
for (i = 0; i < narg && reg < NARGREG; i++, reg++) {
-#ifdef __powerpc64__
- cs->args[i] = regs.fixreg[FIRSTARG + reg] & 0xffffffff;
-#else
cs->args[i] = regs.fixreg[FIRSTARG + reg];
-#endif
}
if (narg > i) {
-#ifdef __powerpc64__
- uint32_t args32[narg - i];
- u_int j;
-
-#endif
iorequest.piod_op = PIOD_READ_D;
iorequest.piod_offs = (void *)(regs.fixreg[1] + 8);
-#ifdef __powerpc64__
- iorequest.piod_addr = args32;
- iorequest.piod_len = sizeof(args32);
-#else
iorequest.piod_addr = &cs->args[i];
iorequest.piod_len = (narg - i) * sizeof(cs->args[0]);
-#endif
ptrace(PT_IO, tid, (caddr_t)&iorequest, 0);
if (iorequest.piod_len == 0)
return (-1);
-#ifdef __powerpc64__
- for (j = 0; j < narg - i; j++)
- cs->args[i + j] = args32[j];
-#endif
}
return (0);
@@ -128,18 +105,13 @@ powerpc_fetch_retval(struct trussinfo *t
}
/* XXX: Does not have fixup for __syscall(). */
-#ifdef __powerpc64__
- retval[0] = regs.fixreg[3] & 0xffffffff;
- retval[1] = regs.fixreg[4] & 0xffffffff;
-#else
retval[0] = regs.fixreg[3];
retval[1] = regs.fixreg[4];
-#endif
*errorp = !!(regs.cr & 0x10000000);
return (0);
}
-static struct procabi powerpc_fbsd = {
+static struct procabi powerpc_freebsd = {
"FreeBSD ELF32",
syscallnames,
nitems(syscallnames),
@@ -147,4 +119,4 @@ static struct procabi powerpc_fbsd = {
powerpc_fetch_retval
};
-PROCABI(powerpc_fbsd);
+PROCABI(powerpc_freebsd);
Copied and modified: head/usr.bin/truss/powerpc64-freebsd.c (from r289057, head/usr.bin/truss/powerpc64-fbsd.c)
==============================================================================
--- head/usr.bin/truss/powerpc64-fbsd.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/powerpc64-freebsd.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -40,7 +40,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#include "syscalls.h"
+#include "freebsd_syscalls.h"
static int
powerpc64_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -107,7 +107,7 @@ powerpc64_fetch_retval(struct trussinfo
return (0);
}
-static struct procabi powerpc64_fbsd = {
+static struct procabi powerpc64_freebsd = {
"FreeBSD ELF64",
syscallnames,
nitems(syscallnames),
@@ -115,4 +115,4 @@ static struct procabi powerpc64_fbsd = {
powerpc64_fetch_retval
};
-PROCABI(powerpc64_fbsd);
+PROCABI(powerpc64_freebsd);
Copied and modified: head/usr.bin/truss/powerpc64-freebsd32.c (from r289057, head/usr.bin/truss/powerpc-fbsd.c)
==============================================================================
--- head/usr.bin/truss/powerpc-fbsd.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/powerpc64-freebsd32.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-/* FreeBSD/powerpc-specific system call handling. */
+/* FreeBSD/powerpc64-freebsd32-specific system call handling. */
#include <sys/ptrace.h>
#include <sys/syscall.h>
@@ -40,15 +40,10 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#ifdef __powerpc64__ /* 32-bit compatibility */
#include "freebsd32_syscalls.h"
-#define syscallnames freebsd32_syscallnames
-#else /* native 32-bit */
-#include "syscalls.h"
-#endif
static int
-powerpc_fetch_args(struct trussinfo *trussinfo, u_int narg)
+powerpc64_freebsd32_fetch_args(struct trussinfo *trussinfo, u_int narg)
{
struct ptrace_io_desc iorequest;
struct reg regs;
@@ -82,41 +77,28 @@ powerpc_fetch_args(struct trussinfo *tru
}
for (i = 0; i < narg && reg < NARGREG; i++, reg++) {
-#ifdef __powerpc64__
cs->args[i] = regs.fixreg[FIRSTARG + reg] & 0xffffffff;
-#else
- cs->args[i] = regs.fixreg[FIRSTARG + reg];
-#endif
}
if (narg > i) {
-#ifdef __powerpc64__
uint32_t args32[narg - i];
u_int j;
-#endif
iorequest.piod_op = PIOD_READ_D;
iorequest.piod_offs = (void *)(regs.fixreg[1] + 8);
-#ifdef __powerpc64__
iorequest.piod_addr = args32;
iorequest.piod_len = sizeof(args32);
-#else
- iorequest.piod_addr = &cs->args[i];
- iorequest.piod_len = (narg - i) * sizeof(cs->args[0]);
-#endif
ptrace(PT_IO, tid, (caddr_t)&iorequest, 0);
if (iorequest.piod_len == 0)
return (-1);
-#ifdef __powerpc64__
for (j = 0; j < narg - i; j++)
cs->args[i + j] = args32[j];
-#endif
}
return (0);
}
static int
-powerpc_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp)
+powerpc64_freebsd32_fetch_retval(struct trussinfo *trussinfo, long *retval, int *errorp)
{
struct reg regs;
lwpid_t tid;
@@ -128,23 +110,18 @@ powerpc_fetch_retval(struct trussinfo *t
}
/* XXX: Does not have fixup for __syscall(). */
-#ifdef __powerpc64__
retval[0] = regs.fixreg[3] & 0xffffffff;
retval[1] = regs.fixreg[4] & 0xffffffff;
-#else
- retval[0] = regs.fixreg[3];
- retval[1] = regs.fixreg[4];
-#endif
*errorp = !!(regs.cr & 0x10000000);
return (0);
}
-static struct procabi powerpc_fbsd = {
+static struct procabi powerpc64_freebsd32 = {
"FreeBSD ELF32",
syscallnames,
nitems(syscallnames),
- powerpc_fetch_args,
- powerpc_fetch_retval
+ powerpc64_freebsd32_fetch_args,
+ powerpc64_freebsd32_fetch_retval
};
-PROCABI(powerpc_fbsd);
+PROCABI(powerpc64_freebsd32);
Copied and modified: head/usr.bin/truss/sparc64-freebsd.c (from r289057, head/usr.bin/truss/sparc64-fbsd.c)
==============================================================================
--- head/usr.bin/truss/sparc64-fbsd.c Thu Oct 8 21:52:20 2015 (r289057, copy source)
+++ head/usr.bin/truss/sparc64-freebsd.c Tue Oct 13 18:23:51 2015 (r289239)
@@ -46,7 +46,7 @@ __FBSDID("$FreeBSD$");
#include "truss.h"
-#include "syscalls.h"
+#include "freebsd_syscalls.h"
static int
sparc64_fetch_args(struct trussinfo *trussinfo, u_int narg)
@@ -114,7 +114,7 @@ sparc64_fetch_retval(struct trussinfo *t
return (0);
}
-static struct procabi sparc64_fbsd = {
+static struct procabi sparc64_freebsd = {
"FreeBSD ELF64",
syscallnames,
nitems(syscallnames),
@@ -122,4 +122,4 @@ static struct procabi sparc64_fbsd = {
sparc64_fetch_retval
};
-PROCABI(sparc64_fbsd);
+PROCABI(sparc64_freebsd);
More information about the svn-src-all
mailing list