summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2014-02-17 14:47:52 +0000
committeravg <avg@FreeBSD.org>2014-02-17 14:47:52 +0000
commitcc43c81b039ea4e8f8aec917d7a7cb781e320310 (patch)
treee4fcd119784fae786e9ddd3c7a0d7efe2942f013
parentad9d45d42725fe3fe3ece1c4b5d217d5fa7f3150 (diff)
downloadFreeBSD-src-cc43c81b039ea4e8f8aec917d7a7cb781e320310.zip
FreeBSD-src-cc43c81b039ea4e8f8aec917d7a7cb781e320310.tar.gz
MFC r258625: sdt: add support for solaris/illumos style DTRACE_PROBE macros
Note: in head KDTRACE_HOOKS is defined in opt_global.h and thus there is no need to explicitly include any header to check that option. In this branch we have to include opt_kdtrace.h and, so, this commit carries additional changes to accomodate for that difference. Sponsored by: HybridCluster
-rw-r--r--sys/cddl/compat/opensolaris/sys/sdt.h15
-rw-r--r--sys/kern/kern_sdt.c2
-rw-r--r--sys/modules/zfs/Makefile6
-rw-r--r--sys/sys/sdt.h55
4 files changed, 66 insertions, 12 deletions
diff --git a/sys/cddl/compat/opensolaris/sys/sdt.h b/sys/cddl/compat/opensolaris/sys/sdt.h
index 46b5b22..f03f6ab 100644
--- a/sys/cddl/compat/opensolaris/sys/sdt.h
+++ b/sys/cddl/compat/opensolaris/sys/sdt.h
@@ -29,20 +29,11 @@
#ifndef _OPENSOLARIS_SYS_SDT_H_
#define _OPENSOLARIS_SYS_SDT_H_
+#ifdef _KERNEL
+#include <opt_kdtrace.h>
+#endif
#include_next <sys/sdt.h>
-#undef DTRACE_PROBE
-#undef DTRACE_PROBE1
-#undef DTRACE_PROBE2
-#undef DTRACE_PROBE3
-#undef DTRACE_PROBE4
-
-#define DTRACE_PROBE(name)
-#define DTRACE_PROBE1(name, type1, arg1)
-#define DTRACE_PROBE2(name, type1, arg1, type2, arg2)
-#define DTRACE_PROBE3(name, type1, arg1, type2, arg2, type3, arg3)
-#define DTRACE_PROBE4(name, type1, arg1, type2, arg2, type3, arg3, type4, arg4)
-
#define SET_ERROR(err) (err)
#endif /* _OPENSOLARIS_SYS_SDT_H_ */
diff --git a/sys/kern/kern_sdt.c b/sys/kern/kern_sdt.c
index c8e1940..048a66c 100644
--- a/sys/kern/kern_sdt.c
+++ b/sys/kern/kern_sdt.c
@@ -31,6 +31,8 @@
#include <sys/systm.h>
#include <sys/sdt.h>
+SDT_PROVIDER_DEFINE(sdt);
+
/*
* Hook for the DTrace probe function. The SDT provider will set this to
* dtrace_probe() when it loads.
diff --git a/sys/modules/zfs/Makefile b/sys/modules/zfs/Makefile
index 63da0ce2..e8f8193 100644
--- a/sys/modules/zfs/Makefile
+++ b/sys/modules/zfs/Makefile
@@ -4,6 +4,12 @@ KMOD= zfs
SRCS= bus_if.h device_if.h vnode_if.h
+.if !defined(KERNBUILDDIR)
+SRCS+= opt_kdtrace.h
+opt_kdtrace.h:
+ echo "" > ${.TARGET}
+.endif
+
SUNW= ${.CURDIR}/../../cddl/contrib/opensolaris
.PATH: ${SUNW}/common/acl
diff --git a/sys/sys/sdt.h b/sys/sys/sdt.h
index 9e39625..ca820f6 100644
--- a/sys/sys/sdt.h
+++ b/sys/sys/sdt.h
@@ -126,6 +126,14 @@
arg1, xarg1, arg2, xarg2, arg3, xarg3, arg4, xarg4, arg5, xarg5, arg6, \
xarg6)
+#define DTRACE_PROBE(name)
+#define DTRACE_PROBE1(name, type0, arg0)
+#define DTRACE_PROBE2(name, type0, arg0, type1, arg1)
+#define DTRACE_PROBE3(name, type0, arg0, type1, arg1, type2, arg2)
+#define DTRACE_PROBE4(name, type0, arg0, type1, arg1, type2, arg2, type3, arg3)
+#define DTRACE_PROBE5(name, type0, arg0, type1, arg1, type2, arg2, type3, arg3,\
+ type4, arg4)
+
#else
SET_DECLARE(sdt_providers_set, struct sdt_provider);
@@ -313,6 +321,51 @@ SET_DECLARE(sdt_argtypes_set, struct sdt_argtype);
(uintptr_t)arg6); \
} while (0)
+#define DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) do { \
+ static SDT_PROBE_DEFINE(sdt, , , name); \
+ SDT_PROBE(sdt, , , name, arg0, arg1, arg2, arg3, arg4);
+#define DTRACE_PROBE_IMPL_END } while (0)
+
+#define DTRACE_PROBE(name) \
+ DTRACE_PROBE_IMPL_START(name, 0, 0, 0, 0, 0) \
+ DTRACE_PROBE_IMPL_END
+
+#define DTRACE_PROBE1(name, type0, arg0) \
+ DTRACE_PROBE_IMPL_START(name, arg0, 0, 0, 0, 0) \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \
+ DTRACE_PROBE_IMPL_END
+
+#define DTRACE_PROBE2(name, type0, arg0, type1, arg1) \
+ DTRACE_PROBE_IMPL_START(name, arg0, arg1, 0, 0, 0) \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 1, #type1, NULL); \
+ DTRACE_PROBE_IMPL_END
+
+#define DTRACE_PROBE3(name, type0, arg0, type1, arg1, type2, arg2) \
+ DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, 0, 0) \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 1, #type1, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 2, #type2, NULL); \
+ DTRACE_PROBE_IMPL_END
+
+#define DTRACE_PROBE4(name, type0, arg0, type1, arg1, type2, arg2, type3, arg3) \
+ DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, 0) \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 1, #type1, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 2, #type2, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 3, #type3, NULL); \
+ DTRACE_PROBE_IMPL_END
+
+#define DTRACE_PROBE5(name, type0, arg0, type1, arg1, type2, arg2, type3, arg3, \
+ type4, arg4) \
+ DTRACE_PROBE_IMPL_START(name, arg0, arg1, arg2, arg3, arg4) \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 0, #type0, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 1, #type1, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 2, #type2, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 3, #type3, NULL); \
+ SDT_PROBE_ARGTYPE(sdt, , , name, 4, #type4, NULL); \
+ DTRACE_PROBE_IMPL_END
+
#endif /* KDTRACE_HOOKS */
/*
@@ -365,6 +418,8 @@ struct sdt_provider {
void sdt_probe_stub(uint32_t, uintptr_t, uintptr_t, uintptr_t, uintptr_t,
uintptr_t);
+SDT_PROVIDER_DECLARE(sdt);
+
#endif /* _KERNEL */
#endif /* _SYS_SDT_H */
OpenPOWER on IntegriCloud