Index: syscalls.conf
===================================================================
RCS file: /cvsroot/src/sys/kern/syscalls.conf,v
retrieving revision 1.19
diff -u -r1.19 syscalls.conf
--- syscalls.conf	3 Aug 2012 12:41:13 -0000	1.19
+++ syscalls.conf	19 Jun 2013 01:40:54 -0000
@@ -8,6 +8,7 @@
 sysalign=1
 rumpcalls="../rump/librump/rumpkern/rump_syscalls.c"
 rumpcallshdr="../rump/include/rump/rump_syscalls.h"
+systrace="systrace_args.c"
 compatopts="compat_43 compat_09 compat_10 compat_11 compat_12 compat_13 compat_14 compat_15 compat_16 compat_20 compat_30 compat_40 compat_50 compat_60"
 libcompatopts=""
 
Index: makesyscalls.sh
===================================================================
RCS file: /cvsroot/src/sys/kern/makesyscalls.sh,v
retrieving revision 1.128
diff -u -r1.128 makesyscalls.sh
--- makesyscalls.sh	7 Mar 2013 19:17:46 -0000	1.128
+++ makesyscalls.sh	19 Jun 2013 01:40:58 -0000
@@ -74,8 +74,9 @@
 sysnamesbottom="sysnames.bottom"
 rumptypes="rumphdr.types"
 rumpprotos="rumphdr.protos"
+systracetmp="systrace"
 
-trap "rm $sysdcl $sysprotos $sysent $sysnamesbottom $rumpsysent $rumptypes $rumpprotos" 0
+trap "rm $sysdcl $sysprotos $sysent $sysnamesbottom $rumpsysent $rumptypes $rumpprotos $systracetmp" 0
 
 # Awk program (must support nawk extensions)
 # Use "awk" at Berkeley, "nawk" or "gawk" elsewhere.
@@ -153,6 +154,8 @@
 	syscompat_pref = \"$syscompat_pref\"
 	sysent = \"$sysent\"
 	sysnamesbottom = \"$sysnamesbottom\"
+	systrace = \"$systrace\"
+	systracetmp = \"$systracetmp\"
 	rumpprotos = \"$rumpprotos\"
 	rumptypes = \"$rumptypes\"
 	sys_nosys = \"$sys_nosys\"
@@ -209,6 +212,10 @@
 	printf "/* %s */\n\n", tag > rumpcallshdr
 	printf "/*\n * System call protos in rump namespace.\n *\n" > rumpcallshdr
 	printf " * DO NOT EDIT-- this file is automatically generated.\n" > rumpcallshdr
+
+	printf "/* %s */\n\n", tag > systrace
+	printf "/*\n * System call argument to DTrace register array conversion.\n *\n" > systrace
+	printf " * DO NOT EDIT-- this file is automatically generated.\n" > systrace
 }
 NR == 1 {
 	sub(/ $/, "")
@@ -335,6 +342,14 @@
 		"\t\t<= %sMAXSYSARGS * sizeof (%s) ? 1 : -1];\n", \
 		constprefix, registertype) >sysarghdr
 
+	printf " * This file is part of the DTrace syscall provider.\n */\n\n" > systrace
+	printf "static void\nsystrace_args(int sysnum, void *params, uint64_t *uarg, int *n_args)\n{\n" > systrace
+	printf "\tint64_t *iarg  = (int64_t *) uarg;\n" > systrace
+	printf "\tswitch (sysnum) {\n" > systrace
+
+	printf "static void\nsystrace_setargdesc(int sysnum, int ndx, char *desc, size_t descsz)\n{\n\tconst char *p = NULL;\n" > systracetmp
+	printf "\tswitch (sysnum) {\n" > systracetmp
+
 	# compat types from syscalls.master.  this is slightly ugly,
 	# but given that we have so few compats from over 17 years,
 	# a more complicated solution is not currently warranted.
@@ -387,6 +402,8 @@
 	print > sysnumhdr
 	print > sysprotos
 	print > sysnamesbottom
+	print > systrace
+	print > systracetmp
 
 	# XXX: technically we do not want to have conditionals in rump,
 	# but it is easier to just let the cpp handle them than try to
@@ -757,6 +774,32 @@
 		printproto(compatwrap_)
 	}
 
+	# output systrace bits
+	printf("\t/* %s */\n\tcase %d: {\n", funcname, syscall) > systrace
+	printf("\t/* %s */\n\tcase %d:\n", funcname, syscall) > systracetmp
+	if (argc > 0) {
+		printf("\t\tswitch(ndx) {\n") > systracetmp
+		printf("\t\tstruct %s *p = params;\n", argalias) > systrace
+		for (i = 1; i <= argc; i++) {
+			printf("\t\tcase %d:\n\t\t\tp = \"%s\";\n\t\t\tbreak;\n", i - 1, argtype[i]) > systracetmp
+			if (index(argtype[i], "*") > 0 || argtype[i] == "caddr_t")
+				printf("\t\tuarg[%d] = (intptr_t) p->%s; /* %s */\n", \
+				     i - 1, \
+				     argname[i], argtype[i]) > systrace
+			else if (substr(argtype[i], 1, 1) == "u" || argtype[i] == "size_t")
+				printf("\t\tuarg[%d] = p->%s; /* %s */\n", \
+				     i - 1, \
+				     argname[i], argtype[i]) > systrace
+			else
+				printf("\t\tiarg[%d] = p->%s; /* %s */\n", \
+				     i - 1, \
+				     argname[i], argtype[i]) > systrace
+		}
+		printf("\t\tdefault:\n\t\t\tbreak;\n\t\t};\n") > systracetmp
+	}
+	printf("\t\t*n_args = %d;\n\t\tbreak;\n\t}\n", argc) > systrace
+	printf("\t\tbreak;\n") > systracetmp
+
 	# output syscall argument structure, if it has arguments
 	if (argc != 0) {
 		printf("\n") > sysarghdr
@@ -982,6 +1025,8 @@
 	printf("#define\t%sMAXSYSCALL\t%d\n", constprefix, maxsyscall) > sysnumhdr
 	if (nsysent)
 		printf("#define\t%sNSYSENT\t%d\n", constprefix, nsysent) > sysnumhdr
+	printf "\tdefault:\n\t\t*n_args = 0;\n\t\tbreak;\n\t};\n}\n" > systrace
+	printf "\tdefault:\n\t\tbreak;\n\t};\n\tif (p != NULL)\n\t\tstrlcpy(desc, p, descsz);\n}\n" > systracetmp
 } '
 
 cat $sysprotos >> $sysarghdr
@@ -997,4 +1042,5 @@
 echo >> $rumpcallshdr
 cat $rumpprotos >> $rumpcallshdr
 
+cat $systracetmp >> $systrace
 #chmod 444 $sysnames $sysnumhdr $syssw
