From owner-freebsd-dtrace@FreeBSD.ORG  Thu May 30 04:07:13 2013
Return-Path: <owner-freebsd-dtrace@FreeBSD.ORG>
Delivered-To: freebsd-dtrace@freebsd.org
Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115])
 by hub.freebsd.org (Postfix) with ESMTP id 03B0960F;
 Thu, 30 May 2013 04:07:13 +0000 (UTC)
 (envelope-from markjdb@gmail.com)
Received: from mail-ie0-x22e.google.com (mail-ie0-x22e.google.com
 [IPv6:2607:f8b0:4001:c03::22e])
 by mx1.freebsd.org (Postfix) with ESMTP id C44E6AEA;
 Thu, 30 May 2013 04:07:12 +0000 (UTC)
Received: by mail-ie0-f174.google.com with SMTP id aq17so3927930iec.33
 for <multiple recipients>; Wed, 29 May 2013 21:07:12 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
 h=sender:date:from:to:cc:subject:message-id:mime-version:content-type
 :content-disposition:user-agent;
 bh=9LH1wZtmY1Kl08CW1nUP4FYivd5qqLSf6dle700N9n8=;
 b=j9Llvfc80ZUYmTZEdIKTL6Lhjarz6aF6BiJyJmmAJqOq5SdSjSi65h2+2aJKSBPplP
 5rXf7/Um0PExnml3QePfuf11KJrYtcjA6DZKywGlwL5DcF4iLW6z36oruDpax1+mszEH
 HYZvV9LWx4ejOL/rE5AFqF2mfgapLqQEOssdO4Cg0DK5uctdVbgYlIavStaL1SK+JDS9
 5DbCtmrkN+Yerw/FKqyrwQte83iMt21CCg94G65DxzPKxOT/EVNTTJr4ifelirZ9Qc3q
 jOvj5Y3qvIq13Plv4GOje1gflVv9bqTleIT/AMKeH68R2NzogcqSY1iB86HaYQSHNJBJ
 367g==
X-Received: by 10.50.108.70 with SMTP id hi6mr10964614igb.21.1369886832557;
 Wed, 29 May 2013 21:07:12 -0700 (PDT)
Received: from gloom (198-84-184-218.cpe.teksavvy.com. [198.84.184.218])
 by mx.google.com with ESMTPSA id ji5sm29888752igb.0.2013.05.29.21.07.10
 for <multiple recipients>
 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
 Wed, 29 May 2013 21:07:11 -0700 (PDT)
Sender: Mark Johnston <markjdb@gmail.com>
Date: Thu, 30 May 2013 00:07:05 -0400
From: Mark Johnston <markj@freebsd.org>
To: freebsd-dtrace@freebsd.org
Subject: adding SDT probe functions with 6+ DTrace arguments
Message-ID: <20130530040705.GA40320@gloom>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
User-Agent: Mutt/1.5.21 (2010-09-15)
Cc: rstone@freebsd.org
X-BeenThere: freebsd-dtrace@freebsd.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: "A discussion list for developers working on DTrace in FreeBSD."
 <freebsd-dtrace.freebsd.org>
List-Unsubscribe: <https://lists.freebsd.org/mailman/options/freebsd-dtrace>, 
 <mailto:freebsd-dtrace-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/freebsd-dtrace>
List-Post: <mailto:freebsd-dtrace@freebsd.org>
List-Help: <mailto:freebsd-dtrace-request@freebsd.org?subject=help>
List-Subscribe: <https://lists.freebsd.org/mailman/listinfo/freebsd-dtrace>,
 <mailto:freebsd-dtrace-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Thu, 30 May 2013 04:07:13 -0000

Hello,

Does anyone have objections or comments on the patch below? It simply
makes it possible to use the SDT_* macros to implement DTrace probes
with more than 5 arguments. dtrace_probe() only takes 5 arguments, so
some ugly casting is needed, but it works properly in my testing on
amd64. In fact, there are a couple of bugs in the way that DTrace
fetches the 6th argument (or the 7th, and so on) from the probe site,
but I'll be fixing that soon as well, along with the test case that's
supposed to detect this problem in the first place.

I don't know of any existing SDT providers in FreeBSD that would use
these macros, but the ip, iscsi and tcp providers will - hence my
interest in making sure that this functionality works properly.

Thanks!
-Mark

diff --git a/sys/sys/sdt.h b/sys/sys/sdt.h
index 522e1f2..21edd53 100644
--- a/sys/sys/sdt.h
+++ b/sys/sys/sdt.h
@@ -91,6 +91,10 @@
 #define	SDT_PROBE_DEFINE3(prov, mod, func, name, sname, arg0, arg1, arg2)
 #define	SDT_PROBE_DEFINE4(prov, mod, func, name, sname, arg0, arg1, arg2, arg3)
 #define	SDT_PROBE_DEFINE5(prov, mod, func, name, sname, arg0, arg1, arg2, arg3, arg4)
+#define	SDT_PROBE_DEFINE6(prov, mod, func, name, snamp, arg0, arg1, arg2,      \
+    arg3, arg4, arg5)
+#define	SDT_PROBE_DEFINE7(prov, mod, func, name, snamp, arg0, arg1, arg2,      \
+    arg3, arg4, arg5, arg6)
 
 #define	SDT_PROBE0(prov, mod, func, name)
 #define	SDT_PROBE1(prov, mod, func, name, arg0)
@@ -98,6 +102,9 @@
 #define	SDT_PROBE3(prov, mod, func, name, arg0, arg1, arg2)
 #define	SDT_PROBE4(prov, mod, func, name, arg0, arg1, arg2, arg3)
 #define	SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
+#define	SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5)
+#define	SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5,  \
+    arg6)
 
 #else
 
@@ -233,6 +240,27 @@ struct sdt_provider {
 	SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3);		\
 	SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4)
 
+#define	SDT_PROBE_DEFINE6(prov, mod, func, name, sname, arg0, arg1, arg2, arg3,\
+    arg4, arg5) \
+	SDT_PROBE_DEFINE(prov, mod, func, name, sname);			\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5);
+
+#define	SDT_PROBE_DEFINE7(prov, mod, func, name, sname, arg0, arg1, arg2, arg3,\
+    arg4, arg5, arg6) \
+	SDT_PROBE_DEFINE(prov, mod, func, name, sname);			\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 0, arg0);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 1, arg1);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 2, arg2);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 3, arg3);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 4, arg4);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 5, arg5);		\
+	SDT_PROBE_ARGTYPE(prov, mod, func, name, 6, arg6);
+
 #define	SDT_PROBE0(prov, mod, func, name)				\
 	SDT_PROBE(prov, mod, func, name, 0, 0, 0, 0, 0)
 #define	SDT_PROBE1(prov, mod, func, name, arg0)				\
@@ -245,6 +273,27 @@ struct sdt_provider {
 	SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, 0)
 #define	SDT_PROBE5(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4) \
 	SDT_PROBE(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4)
+#define	SDT_PROBE6(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5)  \
+	do {								       \
+		if (sdt_##prov##_##mod##_##func##_##name->id)		       \
+			(*(void (*)(uint32_t, uintptr_t, uintptr_t, uintptr_t, \
+			    uintptr_t, uintptr_t, uintptr_t))sdt_probe_func)(  \
+			    sdt_##prov##_##mod##_##func##_##name->id,	       \
+			    (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \
+			    (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5);\
+	} while (0)
+#define	SDT_PROBE7(prov, mod, func, name, arg0, arg1, arg2, arg3, arg4, arg5,  \
+    arg6)								       \
+	do {								       \
+		if (sdt_##prov##_##mod##_##func##_##name->id)		       \
+			(*(void (*)(uint32_t, uintptr_t, uintptr_t, uintptr_t, \
+			    uintptr_t, uintptr_t, uintptr_t, uintptr_t))       \
+			    sdt_probe_func)(				       \
+			    sdt_##prov##_##mod##_##func##_##name->id,	       \
+			    (uintptr_t)arg0, (uintptr_t)arg1, (uintptr_t)arg2, \
+			    (uintptr_t)arg3, (uintptr_t)arg4, (uintptr_t)arg5, \
+			    (uintptr_t)arg6);				       \
+	} while (0)
 
 typedef int (*sdt_argtype_listall_func_t)(struct sdt_argtype *, void *);
 typedef int (*sdt_probe_listall_func_t)(struct sdt_probe *, void *);