Date: Wed, 1 Jun 2011 06:07:57 +0000 (UTC) From: Artem Belevich <art@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r222557 - in stable/8/sys: cddl/dev/systrace modules/dtrace modules/dtrace/dtraceall modules/dtrace/systrace_freebsd32 modules/dtrace/systrace_linux32 Message-ID: <201106010607.p5167vLi056935@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: art Date: Wed Jun 1 06:07:57 2011 New Revision: 222557 URL: http://svn.freebsd.org/changeset/base/222557 Log: MFC r219561, r220437: 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:linux:xxx:yyy - linux compat system calls (linux32 on amd64) syscall:freebsd32:xxx:yyy - freebsd32 compat system calls on amd64 PR: kern/152822 Reviewed by: jhb (earlier version) Approved by: avg (mentor) Added: stable/8/sys/modules/dtrace/systrace_freebsd32/ - copied from r219561, head/sys/modules/dtrace/systrace_freebsd32/ stable/8/sys/modules/dtrace/systrace_linux32/ - copied from r219561, head/sys/modules/dtrace/systrace_linux32/ Modified: stable/8/sys/cddl/dev/systrace/systrace.c stable/8/sys/modules/dtrace/Makefile stable/8/sys/modules/dtrace/dtraceall/Makefile stable/8/sys/modules/dtrace/dtraceall/dtraceall.c stable/8/sys/modules/dtrace/systrace_linux32/Makefile Directory Properties: stable/8/sys/ (props changed) Modified: stable/8/sys/cddl/dev/systrace/systrace.c ============================================================================== --- stable/8/sys/cddl/dev/systrace/systrace.c Wed Jun 1 06:01:17 2011 (r222556) +++ stable/8/sys/cddl/dev/systrace/systrace.c Wed Jun 1 06:07:57 2011 (r222557) @@ -59,17 +59,39 @@ #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> +#define MODNAME "linux32" +#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> +#define MODNAME "linux" +#else +#error Only i386 and amd64 are supported. +#endif extern struct sysent linux_sysent[]; -#define DEVNAME "dtrace/linsystrace" -#define PROVNAME "linsyscall" #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 +99,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 @@ -109,7 +133,7 @@ static struct cdevsw systrace_cdevsw = { .d_version = D_VERSION, .d_open = systrace_open, #ifdef LINUX_SYSTRACE - .d_name = "linsystrace", + .d_name = "systrace_" MODNAME, #else .d_name = "systrace", #endif @@ -214,14 +238,14 @@ systrace_provide(void *arg, dtrace_probe 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 +359,16 @@ SYSINIT(systrace_load, SI_SUB_DTRACE_PRO 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); Modified: stable/8/sys/modules/dtrace/Makefile ============================================================================== --- stable/8/sys/modules/dtrace/Makefile Wed Jun 1 06:01:17 2011 (r222556) +++ stable/8/sys/modules/dtrace/Makefile Wed Jun 1 06:07:57 2011 (r222557) @@ -15,7 +15,10 @@ SUBDIR= dtmalloc \ systrace .if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386" -SUBDIR+= fasttrap fbt +SUBDIR+= fasttrap fbt systrace_linux32 +.endif +.if ${MACHINE_ARCH} == "amd64" +SUBDIR+= systrace_freebsd32 .endif .include <bsd.subdir.mk> Modified: stable/8/sys/modules/dtrace/dtraceall/Makefile ============================================================================== --- stable/8/sys/modules/dtrace/dtraceall/Makefile Wed Jun 1 06:01:17 2011 (r222556) +++ stable/8/sys/modules/dtrace/dtraceall/Makefile Wed Jun 1 06:07:57 2011 (r222557) @@ -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> Modified: stable/8/sys/modules/dtrace/dtraceall/dtraceall.c ============================================================================== --- stable/8/sys/modules/dtrace/dtraceall/dtraceall.c Wed Jun 1 06:01:17 2011 (r222556) +++ stable/8/sys/modules/dtrace/dtraceall/dtraceall.c Wed Jun 1 06:07:57 2011 (r222557) @@ -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, 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); Modified: stable/8/sys/modules/dtrace/systrace_linux32/Makefile ============================================================================== --- head/sys/modules/dtrace/systrace_linux32/Makefile Sat Mar 12 09:09:25 2011 (r219561) +++ stable/8/sys/modules/dtrace/systrace_linux32/Makefile Wed Jun 1 06:07:57 2011 (r222557) @@ -2,7 +2,12 @@ .PATH: ${.CURDIR}/../../../cddl/dev/systrace +.if ${MACHINE} == "amd64" KMOD= systrace_linux32 +.else +KMOD= systrace_linux +.endif + SRCS= systrace.c SRCS+= vnode_if.h
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201106010607.p5167vLi056935>