add DTrace systrace support for linux32 and freebsd32 on amd64 syscalls
Add systrace_linux32 and systrace_freebsd32 modules which provide support for tracing compat system calls in addition to native system call tracing provided by systrace module. Provided that all the systrace modules are loaded now you can select what syscalls to trace in the following manner: syscall::xxx:yyy - work on all system calls that match the specification syscall:freebsd:xxx:yyy - only native system calls syscall:linux32:xxx:yyy - linux32 compat system calls syscall:freebsd32:xxx:yyy - freebsd32 compat system calls on amd64 PR: kern/152822 Submitted by: Artem Belevich <fbsdlist@src.cx> Reviewed by: jhb (earlier version) MFC after: 3 weeks
This commit is contained in:
parent
d549ef5638
commit
308bce2a0e
@ -59,17 +59,38 @@
|
||||
#include <sys/dtrace.h>
|
||||
|
||||
#ifdef LINUX_SYSTRACE
|
||||
#include <linux.h>
|
||||
#include <linux_syscall.h>
|
||||
#include <linux_proto.h>
|
||||
#include <linux_syscallnames.c>
|
||||
#include <linux_systrace.c>
|
||||
#if defined(__amd64__)
|
||||
#include <amd64/linux32/linux.h>
|
||||
#include <amd64/linux32/linux32_proto.h>
|
||||
#include <amd64/linux32/linux32_syscalls.c>
|
||||
#include <amd64/linux32/linux32_systrace_args.c>
|
||||
#elif defined(__i386__)
|
||||
#include <i386/linux/linux.h>
|
||||
#include <i386/linux/linux_proto.h>
|
||||
#include <i386/linux/linux_syscalls.c>
|
||||
#include <i386/linux/linux_systrace_args.c>
|
||||
#else
|
||||
#error Only i386 and amd64 are supported.
|
||||
#endif
|
||||
extern struct sysent linux_sysent[];
|
||||
#define DEVNAME "dtrace/linsystrace"
|
||||
#define PROVNAME "linsyscall"
|
||||
#define MODNAME "linux32"
|
||||
#define MAXSYSCALL LINUX_SYS_MAXSYSCALL
|
||||
#define SYSCALLNAMES linux_syscallnames
|
||||
#define SYSENT linux_sysent
|
||||
#elif defined(FREEBSD32_SYSTRACE)
|
||||
/*
|
||||
* The syscall arguments are processed into a DTrace argument array
|
||||
* using a generated function. See sys/kern/makesyscalls.sh.
|
||||
*/
|
||||
#include <compat/freebsd32/freebsd32_proto.h>
|
||||
#include <compat/freebsd32/freebsd32_util.h>
|
||||
#include <compat/freebsd32/freebsd32_syscall.h>
|
||||
#include <compat/freebsd32/freebsd32_systrace_args.c>
|
||||
extern const char *freebsd32_syscallnames[];
|
||||
#define MODNAME "freebsd32"
|
||||
#define MAXSYSCALL FREEBSD32_SYS_MAXSYSCALL
|
||||
#define SYSCALLNAMES freebsd32_syscallnames
|
||||
#define SYSENT freebsd32_sysent
|
||||
#else
|
||||
/*
|
||||
* The syscall arguments are processed into a DTrace argument array
|
||||
@ -77,13 +98,15 @@ extern struct sysent linux_sysent[];
|
||||
*/
|
||||
#include <sys/syscall.h>
|
||||
#include <kern/systrace_args.c>
|
||||
#define DEVNAME "dtrace/systrace"
|
||||
#define PROVNAME "syscall"
|
||||
#define MODNAME "freebsd"
|
||||
#define MAXSYSCALL SYS_MAXSYSCALL
|
||||
#define SYSCALLNAMES syscallnames
|
||||
#define SYSENT sysent
|
||||
#endif
|
||||
|
||||
#define PROVNAME "syscall"
|
||||
#define DEVNAME "dtrace/systrace/" MODNAME
|
||||
|
||||
#define SYSTRACE_ARTIFICIAL_FRAMES 1
|
||||
|
||||
#define SYSTRACE_SHIFT 16
|
||||
@ -214,14 +237,14 @@ systrace_provide(void *arg, dtrace_probedesc_t *desc)
|
||||
return;
|
||||
|
||||
for (i = 0; i < MAXSYSCALL; i++) {
|
||||
if (dtrace_probe_lookup(systrace_id, NULL,
|
||||
if (dtrace_probe_lookup(systrace_id, MODNAME,
|
||||
uglyhack.pp_syscallnames[i], "entry") != 0)
|
||||
continue;
|
||||
|
||||
(void) dtrace_probe_create(systrace_id, NULL, uglyhack.pp_syscallnames[i],
|
||||
(void) dtrace_probe_create(systrace_id, MODNAME, uglyhack.pp_syscallnames[i],
|
||||
"entry", SYSTRACE_ARTIFICIAL_FRAMES,
|
||||
(void *)((uintptr_t)SYSTRACE_ENTRY(i)));
|
||||
(void) dtrace_probe_create(systrace_id, NULL, uglyhack.pp_syscallnames[i],
|
||||
(void) dtrace_probe_create(systrace_id, MODNAME, uglyhack.pp_syscallnames[i],
|
||||
"return", SYSTRACE_ARTIFICIAL_FRAMES,
|
||||
(void *)((uintptr_t)SYSTRACE_RETURN(i)));
|
||||
}
|
||||
@ -335,12 +358,16 @@ SYSINIT(systrace_load, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_load, NULL
|
||||
SYSUNINIT(systrace_unload, SI_SUB_DTRACE_PROVIDER, SI_ORDER_ANY, systrace_unload, NULL);
|
||||
|
||||
#ifdef LINUX_SYSTRACE
|
||||
DEV_MODULE(linsystrace, systrace_modevent, NULL);
|
||||
MODULE_VERSION(linsystrace, 1);
|
||||
MODULE_DEPEND(linsystrace, linux, 1, 1, 1);
|
||||
MODULE_DEPEND(linsystrace, systrace, 1, 1, 1);
|
||||
MODULE_DEPEND(linsystrace, dtrace, 1, 1, 1);
|
||||
MODULE_DEPEND(linsystrace, opensolaris, 1, 1, 1);
|
||||
DEV_MODULE(systrace_linux32, systrace_modevent, NULL);
|
||||
MODULE_VERSION(systrace_linux32, 1);
|
||||
MODULE_DEPEND(systrace_linux32, linux, 1, 1, 1);
|
||||
MODULE_DEPEND(systrace_linux32, dtrace, 1, 1, 1);
|
||||
MODULE_DEPEND(systrace_linux32, opensolaris, 1, 1, 1);
|
||||
#elif defined(FREEBSD32_SYSTRACE)
|
||||
DEV_MODULE(systrace_freebsd32, systrace_modevent, NULL);
|
||||
MODULE_VERSION(systrace_freebsd32, 1);
|
||||
MODULE_DEPEND(systrace_freebsd32, dtrace, 1, 1, 1);
|
||||
MODULE_DEPEND(systrace_freebsd32, opensolaris, 1, 1, 1);
|
||||
#else
|
||||
DEV_MODULE(systrace, systrace_modevent, NULL);
|
||||
MODULE_VERSION(systrace, 1);
|
||||
|
@ -15,7 +15,10 @@ SUBDIR= dtmalloc \
|
||||
systrace
|
||||
|
||||
.if ${MACHINE_CPUARCH} == "amd64" || ${MACHINE_CPUARCH} == "i386"
|
||||
SUBDIR+= fasttrap fbt
|
||||
SUBDIR+= fasttrap fbt systrace_linux32
|
||||
.endif
|
||||
.if ${MACHINE_CPUARCH} == "amd64"
|
||||
SUBDIR+= systrace_freebsd32
|
||||
.endif
|
||||
|
||||
.include <bsd.subdir.mk>
|
||||
|
@ -1,8 +1,15 @@
|
||||
# $FreeBSD$
|
||||
|
||||
KMOD= dtraceall
|
||||
SRCS= dtraceall.c
|
||||
SRCS= dtraceall.c opt_compat.h
|
||||
|
||||
CFLAGS+= -I${.CURDIR}/../../..
|
||||
|
||||
.if !defined(KERNBUILDDIR)
|
||||
opt_compat.h:
|
||||
.if ${MACHINE_ARCH} == "amd64"
|
||||
echo "#define COMPAT_FREEBSD32 1" >> ${.TARGET}
|
||||
.endif
|
||||
.endif
|
||||
|
||||
.include <bsd.kmod.mk>
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/errno.h>
|
||||
#include "opt_compat.h"
|
||||
|
||||
static int
|
||||
dtraceall_modevent(module_t mod __unused, int type, void *data __unused)
|
||||
@ -73,4 +74,7 @@ MODULE_DEPEND(dtraceall, fasttrap, 1, 1, 1);
|
||||
MODULE_DEPEND(dtraceall, lockstat, 1, 1, 1);
|
||||
MODULE_DEPEND(dtraceall, sdt, 1, 1, 1);
|
||||
MODULE_DEPEND(dtraceall, systrace, 1, 1, 1);
|
||||
#if defined(COMPAT_FREEBSD32)
|
||||
MODULE_DEPEND(dtraceall, systrace_freebsd32, 1, 1, 1);
|
||||
#endif
|
||||
MODULE_DEPEND(dtraceall, profile, 1, 1, 1);
|
||||
|
13
sys/modules/dtrace/systrace_freebsd32/Makefile
Normal file
13
sys/modules/dtrace/systrace_freebsd32/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../../cddl/dev/systrace
|
||||
|
||||
KMOD= systrace_freebsd32
|
||||
SRCS= systrace.c
|
||||
SRCS+= vnode_if.h
|
||||
|
||||
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \
|
||||
-I${.CURDIR}/../../../cddl/contrib/opensolaris/uts/common \
|
||||
-I${.CURDIR}/../../.. -DFREEBSD32_SYSTRACE
|
||||
|
||||
.include <bsd.kmod.mk>
|
13
sys/modules/dtrace/systrace_linux32/Makefile
Normal file
13
sys/modules/dtrace/systrace_linux32/Makefile
Normal file
@ -0,0 +1,13 @@
|
||||
# $FreeBSD$
|
||||
|
||||
.PATH: ${.CURDIR}/../../../cddl/dev/systrace
|
||||
|
||||
KMOD= systrace_linux32
|
||||
SRCS= systrace.c
|
||||
SRCS+= vnode_if.h
|
||||
|
||||
CFLAGS+= -I${.CURDIR}/../../../cddl/compat/opensolaris \
|
||||
-I${.CURDIR}/../../../cddl/contrib/opensolaris/uts/common \
|
||||
-I${.CURDIR}/../../.. -DLINUX_SYSTRACE
|
||||
|
||||
.include <bsd.kmod.mk>
|
Loading…
Reference in New Issue
Block a user