Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 2 Jun 2013 00:33:36 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r251237 - in head: cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt sys/cddl/dev/dtrace sys/modules/dtrace/dtrace_test
Message-ID:  <201306020033.r520Xa8a051568@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Sun Jun  2 00:33:36 2013
New Revision: 251237
URL: http://svnweb.freebsd.org/changeset/base/251237

Log:
  Port the SDT test now that it's possible to create SDT probes that take
  seven arguments.
  
  The original test uses Solaris' uadmin system call to trigger the test
  probe; this change adds a sysctl to the dtrace_test module and gets the test
  program to trigger the test probe via the sysctl handler.
  
  The test is currently failing on amd64 because of some bugs in the way that
  probe arguments beyond the first five are obtained - these bugs will be
  fixed in a separate change.

Modified:
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c
  head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d
  head/sys/cddl/dev/dtrace/dtrace_test.c
  head/sys/modules/dtrace/dtrace_test/Makefile

Modified: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c	Sat Jun  1 23:58:44 2013	(r251236)
+++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.c	Sun Jun  2 00:33:36 2013	(r251237)
@@ -26,26 +26,24 @@
 
 #pragma ident	"%Z%%M%	%I%	%E% SMI"
 
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <err.h>
 #include <unistd.h>
-#ifndef __FreeBSD__
-#include <sys/uadmin.h>
-#endif
 
 int
 main(int argc, char **argv)
 {
-#ifdef __FreeBSD__
-	return (1);
-#else
+	int val = 1;
+
 	while (1) {
-		if (uadmin(A_SDTTEST, 0, 0) < 0) {
-			perror("uadmin");
-			return (1);
-		}
+		if (sysctlbyname("debug.dtracetest.sdttest", NULL, NULL, &val,
+		    sizeof(val)))
+			err(1, "sysctlbyname");
 
 		sleep(1);
 	}
 
 	return (0);
-#endif
 }

Modified: head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d	Sat Jun  1 23:58:44 2013	(r251236)
+++ head/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/sdt/tst.sdtargs.d	Sun Jun  2 00:33:36 2013	(r251237)
@@ -43,7 +43,7 @@ ERROR
 	exit(1);
 }
 
-sdt:::test
+test:::sdttest
 /arg0 != 1 || arg1 != 2 || arg2 != 3 || arg3 != 4 || arg4 != 5 || arg5 != 6 ||
     arg6 != 7/
 {
@@ -54,7 +54,7 @@ sdt:::test
 	exit(1);
 }
 
-sdt:::test
+test:::sdttest
 {
 	exit(0);
 }

Modified: head/sys/cddl/dev/dtrace/dtrace_test.c
==============================================================================
--- head/sys/cddl/dev/dtrace/dtrace_test.c	Sat Jun  1 23:58:44 2013	(r251236)
+++ head/sys/cddl/dev/dtrace/dtrace_test.c	Sun Jun  2 00:33:36 2013	(r251237)
@@ -25,15 +25,25 @@
  * $FreeBSD$
  *
  */
+#include "opt_kdtrace.h"
 
 #include <sys/cdefs.h>
 #include <sys/types.h>
 #include <sys/param.h>
+#include <sys/systm.h>
+
 #include <sys/conf.h>
 #include <sys/kernel.h>
 #include <sys/module.h>
+#include <sys/sdt.h>
+#include <sys/sysctl.h>
 #include <sys/vnode.h>
 
+SDT_PROVIDER_DEFINE(test);
+
+SDT_PROBE_DEFINE7(test, , , sdttest, sdttest, "int", "int", "int", "int", "int",
+    "int", "int");
+
 /*
  * These are variables that the DTrace test suite references in the
  * Solaris kernel. We define them here so that the tests function 
@@ -45,6 +55,33 @@ typedef struct vnode vnode_t;
 vnode_t dummy;
 vnode_t *rootvp = &dummy;
 
+/*
+ * Test SDT probes with more than 5 arguments. On amd64, such probes require
+ * special handling since only the first 5 arguments will be passed to
+ * dtrace_probe() in registers; the rest must be fetched off the stack.
+ */
+static int
+dtrace_test_sdttest(SYSCTL_HANDLER_ARGS)
+{
+	int val, error;
+
+	val = 0;
+	error = sysctl_handle_int(oidp, &val, 0, req);
+	if (error || req->newptr == NULL)
+		return (error);
+	else if (val == 0)
+		return (0);
+
+	SDT_PROBE7(test, , , sdttest, 1, 2, 3, 4, 5, 6, 7);
+
+	return (error);
+}
+
+static SYSCTL_NODE(_debug, OID_AUTO, dtracetest, CTLFLAG_RD, 0, "");
+
+SYSCTL_PROC(_debug_dtracetest, OID_AUTO, sdttest, CTLTYPE_INT | CTLFLAG_RW,
+    NULL, 0, dtrace_test_sdttest, "I", "Trigger the SDT test probe");
+
 static int
 dtrace_test_modevent(module_t mod, int type, void *data)
 {

Modified: head/sys/modules/dtrace/dtrace_test/Makefile
==============================================================================
--- head/sys/modules/dtrace/dtrace_test/Makefile	Sat Jun  1 23:58:44 2013	(r251236)
+++ head/sys/modules/dtrace/dtrace_test/Makefile	Sun Jun  2 00:33:36 2013	(r251237)
@@ -5,8 +5,9 @@
 KMOD=		dtrace_test
 SRCS=		dtrace_test.c
 
+SRCS+=		opt_kdtrace.h
 SRCS+=		vnode_if.h
-		
+
 CFLAGS+=	-I${.CURDIR}/../../..
 
 CFLAGS+=	-D_KERNEL



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