Permalink
Browse files

Capture the dtrace scripts from Dustin Sallings

Change-Id: I6ecd29edb4d310edebda717b5793ff0ea0ae11ea
Reviewed-on: http://review.couchbase.org/9563
Tested-by: Steve Yen <steve.yen@gmail.com>
Reviewed-by: Steve Yen <steve.yen@gmail.com>
  • Loading branch information...
1 parent 0f3a435 commit 6a04074740ddc937893d8e3d490fa04f47f1b835 @steveyen steveyen committed Sep 13, 2011
Showing with 50 additions and 0 deletions.
  1. +21 −0 scripts/dtrace-profile.d
  2. +29 −0 scripts/dtrace-syscalls.d
View
@@ -0,0 +1,21 @@
+/* Count function invocations.
+ *
+ * usage:
+ * sudo dtrace -q -s dtrace-profile.d PID
+ */
+
+pid$1:::entry
+{
+ self->t[probefunc] = timestamp;
+}
+
+pid$1:::return
+/ self->t[probefunc] != 0 /
+{
+ @counts[probemod, probefunc] = sum(timestamp - self->t[probefunc]);
+}
+
+tick-5s
+{
+ printa(@counts);
+}
View
@@ -0,0 +1,29 @@
+/* Trace all the syscalls invoked during a given C function.
+ *
+ * usage:
+ * sudo dtrace -q -s dtrace-syscalls.d PID PROBEFUNC
+ *
+ * example:
+ * sudo dtrace -q -s dtrace-syscalls.d 6666 try_read_command
+ */
+
+pid$1::$2:entry
+{
+ printf("starting %s\n", probefunc);
+ self->in_function = 1;
+ ustack();
+}
+
+pid$1::$2:return
+{
+ printf("ending %s\n", probefunc);
+ self->in_function = 0;
+}
+
+syscall:::
+/ self->in_function != 0 /
+{
+ printf("%s %s %s\n", execname, probefunc, probename);
+}
+
+

0 comments on commit 6a04074

Please sign in to comment.