summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/dtracetoolkit/JavaScript
diff options
context:
space:
mode:
authorgnn <gnn@FreeBSD.org>2012-05-12 21:25:48 +0000
committergnn <gnn@FreeBSD.org>2012-05-12 21:25:48 +0000
commit2325662608ef525d2b16f218c7f92205ae571d5c (patch)
tree349c87edcb2d1f2a1040b9630b1fddf85a3484a0 /cddl/contrib/dtracetoolkit/JavaScript
parent0778d9c814eb131045e6c28e219184601f3c9e19 (diff)
parent4297c1b2d07fec7f50b70e26e3adb4d062b19e15 (diff)
downloadFreeBSD-src-2325662608ef525d2b16f218c7f92205ae571d5c.zip
FreeBSD-src-2325662608ef525d2b16f218c7f92205ae571d5c.tar.gz
Import dtracetoolkit into cddl/contrib
Diffstat (limited to 'cddl/contrib/dtracetoolkit/JavaScript')
-rw-r--r--cddl/contrib/dtracetoolkit/JavaScript/Readme54
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_calldist.d101
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_calls.d76
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_calltime.d115
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_cpudist.d101
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_cputime.d115
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_execs.d51
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_flow.d69
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_flowinfo.d86
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_flowtime.d84
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_objcpu.d61
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_objgc.d89
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_objnew.d55
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_stat.d120
-rwxr-xr-xcddl/contrib/dtracetoolkit/JavaScript/js_who.d56
15 files changed, 1233 insertions, 0 deletions
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/Readme b/cddl/contrib/dtracetoolkit/JavaScript/Readme
new file mode 100644
index 0000000..a9bebf8
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/Readme
@@ -0,0 +1,54 @@
+JavaScript - DTracing JavaScript
+
+ There scripts trace the JavaScript programming language, and require a
+ browser to be built with the DTrace JavaScript provider.
+
+ The DTrace JavaScript provider was originally written by Brendan Gregg,
+ and later developed as part of a Mozilla DTrace provider suite by
+ engineers from both Sun and Mozilla. It currently exists as patches
+ to the Mozilla source tree and requires building from source to get
+ working; it may be integrated into Solaris builds by default in the
+ future. To download the current patches and instructions, visit,
+
+ http://www.opensolaris.org/os/project/mozilla-dtrace/
+
+ A rough guide for the process is,
+
+ 1. Download the Mozilla source
+ http://developer.mozilla.org/en/docs/Mozilla_Source_Code_Via_CVS
+ 2. Download the Mozilla DTrace framework patch, and apply
+ https://bugzilla.mozilla.org/show_bug.cgi?id=370906
+ 3. Download the JavaScript DTrace provider patch, and apply
+ https://bugzilla.mozilla.org/show_bug.cgi?id=388564
+ 4. Create a .mozconfig file (needed for compilation).
+ 5. Setup various compilation environment vars (CC/CFLAGS/CXX/...)
+ 6. autoconf
+ 7. ./configure --enable-dtrace
+ 8. gmake
+
+ See John Rice's instructions linked from the OpenSolaris page above
+ for details on steps 4-8.
+
+ Since the DTrace JavaScript provider may be developed further, there is a
+ chance that it has changed slightly by the time you are reading this,
+ causing these scripts to either break or behave oddly. Firstly, check for
+ newer versions of the DTraceToolkit; if it hasn't been updated and you need
+ to use these scripts immediately, then updating them shouldn't take
+ too long. The following was the state of the provider when these scripts
+ were written - check for changes and update the scripts accordingly,
+
+ provider javascript {
+ probe function-entry(file, class, func)
+ probe function-info(file, class, func, lineno, runfile, runlineno)
+ probe function-args(file, class, func, argc, argv, argv0, argv1,
+ argv2, argv3, argv4)
+ probe function-rval(file, class, func, lineno, rval, rval0)
+ probe function-return(file, class, func)
+ probe object-create-start(file, class)
+ probe object-create(file, class, *object, rlineno)
+ probe object-create-done(file, class)
+ probe object-finalize(NULL, class, *object)
+ probe execute-start(file, lineno)
+ probe execute-done(file, lineno)
+ };
+
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_calldist.d b/cddl/contrib/dtracetoolkit/JavaScript/js_calldist.d
new file mode 100755
index 0000000..2c4923a
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_calldist.d
@@ -0,0 +1,101 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_calldist.d - measure JavaScript elapsed times for types of operation.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_calldist.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces JavaScript activity from all browsers running on the system with
+ * JavaScript provider support.
+ *
+ * USAGE: js_calldist.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * 1 Filename of the JavaScript program
+ * 2 Type of call (func/obj-new)
+ * 3 Name of call
+ *
+ * Filename and function names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::function-entry
+{
+ self->depth++;
+ self->exclude[self->depth] = 0;
+ self->function[self->depth] = timestamp;
+}
+
+javascript*:::function-return
+/self->function[self->depth]/
+{
+ this->elapsed_incl = timestamp - self->function[self->depth];
+ this->elapsed_excl = this->elapsed_incl - self->exclude[self->depth];
+ self->function[self->depth] = 0;
+ self->exclude[self->depth] = 0;
+ this->file = basename(copyinstr(arg0));
+ this->name = copyinstr(arg2);
+
+ @types_incl[this->file, "func", this->name] =
+ quantize(this->elapsed_incl / 1000);
+ @types_excl[this->file, "func", this->name] =
+ quantize(this->elapsed_excl / 1000);
+
+ self->depth--;
+ self->exclude[self->depth] += this->elapsed_incl;
+}
+
+javascript*:::object-create-start
+{
+ self->object = timestamp;
+}
+
+javascript*:::object-create-done
+/self->object/
+{
+ this->elapsed = timestamp - self->object;
+ self->object = 0;
+ this->file = basename(copyinstr(arg0));
+ this->name = copyinstr(arg1);
+
+ @types[this->file, "obj-new", this->name] =
+ quantize(this->elapsed / 1000);
+
+ self->exclude[self->depth] += this->elapsed;
+}
+
+dtrace:::END
+{
+ printf("\nElapsed times (us),\n");
+ printa(" %s, %s, %s %@d\n", @types);
+
+ printf("\nExclusive function elapsed times (us),\n");
+ printa(" %s, %s, %s %@d\n", @types_excl);
+
+ printf("\nInclusive function elapsed times (us),\n");
+ printa(" %s, %s, %s %@d\n", @types_incl);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_calls.d b/cddl/contrib/dtracetoolkit/JavaScript/js_calls.d
new file mode 100755
index 0000000..98f1a83
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_calls.d
@@ -0,0 +1,76 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_calls.d - count JavaScript calls using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_calls.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces activity from all browsers on the system that are
+ * running with JavaScript provider support.
+ *
+ * USAGE: js_calls.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * FILE Filename of the JavaScript program
+ * TYPE Type of call (func/obj-new/...)
+ * NAME Descriptive name of call
+ * COUNT Number of calls during sample
+ *
+ * Filename and function names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::function-entry
+{
+ this->name = copyinstr(arg2);
+ @calls[basename(copyinstr(arg0)), "func", this->name] = count();
+}
+
+javascript*:::execute-start
+{
+ this->filename = basename(copyinstr(arg0));
+ @calls[this->filename, "exec", "."] = count();
+}
+
+javascript*:::object-create-start
+{
+ this->name = copyinstr(arg1);
+ this->filename = basename(copyinstr(arg0));
+ @calls[this->filename, "obj-new", this->name] = count();
+}
+
+javascript*:::object-finalize
+{
+ this->name = copyinstr(arg1);
+ @calls["<null>", "obj-free", this->name] = count();
+}
+
+dtrace:::END
+{
+ printf(" %-24s %-10s %-30s %8s\n", "FILE", "TYPE", "NAME", "CALLS");
+ printa(" %-24s %-10s %-30s %@8d\n", @calls);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_calltime.d b/cddl/contrib/dtracetoolkit/JavaScript/js_calltime.d
new file mode 100755
index 0000000..dce150e
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_calltime.d
@@ -0,0 +1,115 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_calltime.d - measure JavaScript elapsed times for types of operation.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_calltime.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces JavaScript activity from all browsers running on the system with
+ * JavaScript provider support.
+ *
+ * USAGE: js_calltime.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * FILE Filename of the JavaScript program
+ * TYPE Type of call (func/obj-new/gc/total)
+ * NAME Name of call
+ * TOTAL Total elapsed time for calls (us)
+ *
+ * Filename and function names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::function-entry
+{
+ self->depth++;
+ self->exclude[self->depth] = 0;
+ self->function[self->depth] = timestamp;
+}
+
+javascript*:::function-return
+/self->function[self->depth]/
+{
+ this->elapsed_incl = timestamp - self->function[self->depth];
+ this->elapsed_excl = this->elapsed_incl - self->exclude[self->depth];
+ self->function[self->depth] = 0;
+ self->exclude[self->depth] = 0;
+ this->file = basename(copyinstr(arg0));
+ this->name = copyinstr(arg2);
+
+ @num[this->file, "func", this->name] = count();
+ @num["-", "total", "-"] = count();
+ @types_incl[this->file, "func", this->name] = sum(this->elapsed_incl);
+ @types_excl[this->file, "func", this->name] = sum(this->elapsed_excl);
+ @types_excl["-", "total", "-"] = sum(this->elapsed_excl);
+
+ self->depth--;
+ self->exclude[self->depth] += this->elapsed_incl;
+}
+
+javascript*:::object-create-start
+{
+ self->object = timestamp;
+}
+
+javascript*:::object-create-done
+/self->object/
+{
+ this->elapsed = timestamp - self->object;
+ self->object = 0;
+ this->file = basename(copyinstr(arg0));
+ this->name = copyinstr(arg1);
+
+ @num[this->file, "obj-new", this->name] = count();
+ @num["-", "total", "-"] = count();
+ @types[this->file, "obj-new", this->name] = sum(this->elapsed);
+ @types["-", "total", "-"] = sum(this->elapsed);
+
+ self->exclude[self->depth] += this->elapsed;
+}
+
+dtrace:::END
+{
+ printf("\nCount,\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "COUNT");
+ printa(" %-20.20s %-10s %-32s %@8d\n", @num);
+
+ normalize(@types, 1000);
+ printf("\nElapsed times (us),\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "TOTAL");
+ printa(" %-20.20s %-10s %-32s %@8d\n", @types);
+
+ normalize(@types_excl, 1000);
+ printf("\nExclusive function elapsed times (us),\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "TOTAL");
+ printa(" %-20.20s %-10s %-32s %@8d\n", @types_excl);
+
+ normalize(@types_incl, 1000);
+ printf("\nInclusive function elapsed times (us),\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "TOTAL");
+ printa(" %-20.20s %-10s %-32s %@8d\n", @types_incl);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_cpudist.d b/cddl/contrib/dtracetoolkit/JavaScript/js_cpudist.d
new file mode 100755
index 0000000..cbe168d
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_cpudist.d
@@ -0,0 +1,101 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_cpudist.d - measure JavaScript on-CPU times for types of operation.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_cpudist.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces JavaScript activity from all browsers running on the system with
+ * JavaScript provider support.
+ *
+ * USAGE: js_cpudist.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * 1 Filename of the JavaScript program
+ * 2 Type of call (func/obj-new)
+ * 3 Name of call
+ *
+ * Filename and function names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::function-entry
+{
+ self->depth++;
+ self->exclude[self->depth] = 0;
+ self->function[self->depth] = vtimestamp;
+}
+
+javascript*:::function-return
+/self->function[self->depth]/
+{
+ this->oncpu_incl = vtimestamp - self->function[self->depth];
+ this->oncpu_excl = this->oncpu_incl - self->exclude[self->depth];
+ self->function[self->depth] = 0;
+ self->exclude[self->depth] = 0;
+ this->file = basename(copyinstr(arg0));
+ this->name = copyinstr(arg2);
+
+ @types_incl[this->file, "func", this->name] =
+ quantize(this->oncpu_incl / 1000);
+ @types_excl[this->file, "func", this->name] =
+ quantize(this->oncpu_excl / 1000);
+
+ self->depth--;
+ self->exclude[self->depth] += this->oncpu_incl;
+}
+
+javascript*:::object-create-start
+{
+ self->object = vtimestamp;
+}
+
+javascript*:::object-create-done
+/self->object/
+{
+ this->oncpu = vtimestamp - self->object;
+ self->object = 0;
+ this->file = basename(copyinstr(arg0));
+ this->name = copyinstr(arg1);
+
+ @types[this->file, "obj-new", this->name] =
+ quantize(this->oncpu / 1000);
+
+ self->exclude[self->depth] += this->oncpu;
+}
+
+dtrace:::END
+{
+ printf("\nElapsed times (us),\n");
+ printa(" %s, %s, %s %@d\n", @types);
+
+ printf("\nExclusive function on-CPU times (us),\n");
+ printa(" %s, %s, %s %@d\n", @types_excl);
+
+ printf("\nInclusive function on-CPU times (us),\n");
+ printa(" %s, %s, %s %@d\n", @types_incl);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_cputime.d b/cddl/contrib/dtracetoolkit/JavaScript/js_cputime.d
new file mode 100755
index 0000000..bee77ab
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_cputime.d
@@ -0,0 +1,115 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_cputime.d - measure JavaScript on-CPU times for types of operation.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_cputime.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces JavaScript activity from all browsers running on the system with
+ * JavaScript provider support.
+ *
+ * USAGE: js_cputime.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * FILE Filename of the JavaScript program
+ * TYPE Type of call (func/obj-new/gc/total)
+ * NAME Name of call
+ * TOTAL Total on-CPU time for calls (us)
+ *
+ * Filename and function names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::function-entry
+{
+ self->depth++;
+ self->exclude[self->depth] = 0;
+ self->function[self->depth] = vtimestamp;
+}
+
+javascript*:::function-return
+/self->function[self->depth]/
+{
+ this->oncpu_incl = vtimestamp - self->function[self->depth];
+ this->oncpu_excl = this->oncpu_incl - self->exclude[self->depth];
+ self->function[self->depth] = 0;
+ self->exclude[self->depth] = 0;
+ this->file = basename(copyinstr(arg0));
+ this->name = copyinstr(arg2);
+
+ @num[this->file, "func", this->name] = count();
+ @num["-", "total", "-"] = count();
+ @types_incl[this->file, "func", this->name] = sum(this->oncpu_incl);
+ @types_excl[this->file, "func", this->name] = sum(this->oncpu_excl);
+ @types_excl["-", "total", "-"] = sum(this->oncpu_excl);
+
+ self->depth--;
+ self->exclude[self->depth] += this->oncpu_incl;
+}
+
+javascript*:::object-create-start
+{
+ self->object = vtimestamp;
+}
+
+javascript*:::object-create-done
+/self->object/
+{
+ this->oncpu = vtimestamp - self->object;
+ self->object = 0;
+ this->file = basename(copyinstr(arg0));
+ this->name = copyinstr(arg1);
+
+ @num[this->file, "obj-new", this->name] = count();
+ @num["-", "total", "-"] = count();
+ @types[this->file, "obj-new", this->name] = sum(this->oncpu);
+ @types["-", "total", "-"] = sum(this->oncpu);
+
+ self->exclude[self->depth] += this->oncpu;
+}
+
+dtrace:::END
+{
+ printf("\nCount,\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "COUNT");
+ printa(" %-20.20s %-10s %-32s %@8d\n", @num);
+
+ normalize(@types, 1000);
+ printf("\nElapsed times (us),\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "TOTAL");
+ printa(" %-20.20s %-10s %-32s %@8d\n", @types);
+
+ normalize(@types_excl, 1000);
+ printf("\nExclusive function on-CPU times (us),\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "TOTAL");
+ printa(" %-20.20s %-10s %-32s %@8d\n", @types_excl);
+
+ normalize(@types_incl, 1000);
+ printf("\nInclusive function on-CPU times (us),\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "TOTAL");
+ printa(" %-20.20s %-10s %-32s %@8d\n", @types_incl);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_execs.d b/cddl/contrib/dtracetoolkit/JavaScript/js_execs.d
new file mode 100755
index 0000000..fb0ca91
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_execs.d
@@ -0,0 +1,51 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_execs.d - JavaScript execute snoop using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_execs.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces activity from all browsers on the system that are
+ * running with JavaScript provider support.
+ *
+ * USAGE: js_execs.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * TIME Time of event
+ * FILE Filename of the JavaScript program
+ * LINENO Line number in filename
+ *
+ * Filename and function names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=10
+
+dtrace:::BEGIN
+{
+ printf("%-20s %32s:%s\n", "TIME", "FILE", "LINENO");
+}
+
+javascript*:::execute-start
+{
+ printf("%-20Y %32s:%d\n", walltimestamp, basename(copyinstr(arg0)),
+ arg1);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_flow.d b/cddl/contrib/dtracetoolkit/JavaScript/js_flow.d
new file mode 100755
index 0000000..450cc69
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_flow.d
@@ -0,0 +1,69 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_flow.d - snoop JavaScript execution showing function flow using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_flow.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces activity from all browsers on the system that are running
+ * with JavaScript provider support.
+ *
+ * USAGE: js_flow.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * C CPU-id
+ * TIME(us) Time since boot, us
+ * FILE Filename that this function belongs to
+ * FUNC Function name
+ *
+ * LEGEND:
+ * -> function entry
+ * <- function return
+ *
+ * Filename and function names are printed if available.
+ *
+ * WARNING: Watch the first column carefully, it prints the CPU-id. If it
+ * changes, then it is very likely that the output has been shuffled.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=10
+
+self int depth;
+
+dtrace:::BEGIN
+{
+ printf("%3s %-16s %-22s -- %s\n", "C", "TIME(us)", "FILE", "FUNC");
+}
+
+javascript*:::function-entry
+{
+ printf("%3d %-16d %-22s %*s-> %s\n", cpu, timestamp / 1000,
+ basename(copyinstr(arg0)), self->depth * 2, "", copyinstr(arg2));
+ self->depth++;
+}
+
+javascript*:::function-return
+{
+ self->depth -= self->depth > 0 ? 1 : 0;
+ printf("%3d %-16d %-22s %*s<- %s\n", cpu, timestamp / 1000,
+ basename(copyinstr(arg0)), self->depth * 2, "", copyinstr(arg2));
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_flowinfo.d b/cddl/contrib/dtracetoolkit/JavaScript/js_flowinfo.d
new file mode 100755
index 0000000..b4b7d5c
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_flowinfo.d
@@ -0,0 +1,86 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_flowinfo.d - JavaScript function flow with info using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_flowinfo.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces activity from all browsers on the system that are running
+ * with JavaScript provider support.
+ *
+ * USAGE: js_flowinfo.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * C CPU-id
+ * PID Process ID
+ * DELTA(us) Elapsed time from previous line to this line
+ * FILE Filename of the JavScript program
+ * LINE Line number of filename
+ * TYPE Type of call (func)
+ * FUNC Function name
+ *
+ * LEGEND:
+ * -> function entry
+ * <- function return
+ *
+ * Filename and function names are printed if available.
+ *
+ * WARNING: Watch the first column carefully, it prints the CPU-id. If it
+ * changes, then it is very likely that the output has been shuffled.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=10
+
+self int depth;
+
+dtrace:::BEGIN
+{
+ printf("%3s %6s %10s %16s:%-4s %-8s -- %s\n", "C", "PID", "DELTA(us)",
+ "FILE", "LINE", "TYPE", "FUNC");
+}
+
+javascript*:::function-info,
+javascript*:::function-return
+/self->last == 0/
+{
+ self->last = timestamp;
+}
+
+javascript*:::function-info
+{
+ this->delta = (timestamp - self->last) / 1000;
+ printf("%3d %6d %10d %16s:%-4d %-8s %*s-> %s\n", cpu, pid,
+ this->delta, basename(copyinstr(arg4)), arg5, "func",
+ self->depth * 2, "", copyinstr(arg2));
+ self->depth++;
+ self->last = timestamp;
+}
+
+javascript*:::function-return
+{
+ this->delta = (timestamp - self->last) / 1000;
+ self->depth -= self->depth > 0 ? 1 : 0;
+ printf("%3d %6d %10d %16s:- %-8s %*s<- %s\n", cpu, pid,
+ this->delta, basename(copyinstr(arg0)), "func", self->depth * 2,
+ "", copyinstr(arg2));
+ self->last = timestamp;
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_flowtime.d b/cddl/contrib/dtracetoolkit/JavaScript/js_flowtime.d
new file mode 100755
index 0000000..9545274
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_flowtime.d
@@ -0,0 +1,84 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_flowtime.d - JavaScript function flow with delta times using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_flowtime.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces activity from all browsers on the system that are running
+ * with JavaScript provider support.
+ *
+ * USAGE: js_flowtime.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * C CPU-id
+ * TIME(us) Time since boot, us
+ * FILE Filename that this function belongs to
+ * DELTA(us) Elapsed time from previous line to this line
+ * FUNC Function name
+ *
+ * LEGEND:
+ * -> function entry
+ * <- function return
+ *
+ * Filename and function names are printed if available.
+ *
+ * WARNING: Watch the first column carefully, it prints the CPU-id. If it
+ * changes, then it is very likely that the output has been shuffled.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+#pragma D option switchrate=10
+
+self int depth;
+
+dtrace:::BEGIN
+{
+ printf("%3s %-16s %-18s %9s -- %s\n", "C", "TIME(us)", "FILE",
+ "DELTA(us)", "FUNC");
+}
+
+javascript*:::function-entry,
+javascript*:::function-return
+/self->last == 0/
+{
+ self->last = timestamp;
+}
+
+javascript*:::function-entry
+{
+ this->delta = (timestamp - self->last) / 1000;
+ printf("%3d %-16d %-18s %9d %*s-> %s\n", cpu, timestamp / 1000,
+ basename(copyinstr(arg0)), this->delta, self->depth * 2, "",
+ copyinstr(arg2));
+ self->depth++;
+ self->last = timestamp;
+}
+
+javascript*:::function-return
+{
+ this->delta = (timestamp - self->last) / 1000;
+ self->depth -= self->depth > 0 ? 1 : 0;
+ printf("%3d %-16d %-18s %9d %*s<- %s\n", cpu, timestamp / 1000,
+ basename(copyinstr(arg0)), this->delta, self->depth * 2, "",
+ copyinstr(arg2));
+ self->last = timestamp;
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_objcpu.d b/cddl/contrib/dtracetoolkit/JavaScript/js_objcpu.d
new file mode 100755
index 0000000..6611f59
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_objcpu.d
@@ -0,0 +1,61 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_objcpu.d - measure JavaScript object creation on-CPU time using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_objcpu.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces JavaScript activity from all browsers running on the system
+ * with JavaScript provider support.
+ *
+ * USAGE: js_objcpu.d # hit Ctrl-C to end
+ *
+ * Class names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::object-create-start
+{
+ self->vstart = vtimestamp;
+}
+
+javascript*:::object-create-done
+/self->vstart/
+{
+ this->oncpu = vtimestamp - self->vstart;
+ @total = sum(this->oncpu);
+ @dist[copyinstr(arg1)] = quantize(this->oncpu / 1000);
+ self->vstart = 0;
+}
+
+dtrace:::END
+{
+ normalize(@total, 1000000);
+ printa("Total object creation on-CPU time (ms): %@d\n\n", @total);
+ printf("Object creation on-CPU time distributions (us),\n");
+ printa(@dist);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_objgc.d b/cddl/contrib/dtracetoolkit/JavaScript/js_objgc.d
new file mode 100755
index 0000000..575b295
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_objgc.d
@@ -0,0 +1,89 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_objgc.d - trace JavaScript Object GC using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_objgc.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces JavaScript activity from all running browers on the system
+ * which support the JavaScript DTrace provider.
+ *
+ * USAGE: js_objgc.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * FILE Filename that contained the function
+ * CLASS Class to which this new object belongs
+ * TOTAL Object entropy (positive == uncollected)
+ *
+ * This script provides information on which objects are not being garbage
+ * collected, an issue which causes the browser to steadily leak memory.
+ * We trace object creation (+1) and destruction (-1), and provide a
+ * summary each second of the running tally of the object class and
+ * originating filename. If over the period of several minutes an object
+ * type is still steadily increasing, then that would be of interest.
+ * Be patient, depending on the rate of object creation it can take over
+ * ten minutes for garbage collect to kick in.
+ *
+ * NOTES:
+ * - it is possible that you will see negative entropy. That happens
+ * when you begin tracing after some objects have already been created,
+ * and then trace their destruction.
+ * - there are other Things that GC handles, other than Objects; extra
+ * probes can be added to trace them, should the need arise.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+/* if you get dynvardrops, increase this, */
+#pragma D option dynvarsize=32m
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::object-create
+/arg2/
+{
+ this->file = basename(copyinstr(arg0));
+ @objs[this->file, copyinstr(arg1)] = sum(1);
+ filename[arg2] = this->file;
+}
+
+javascript*:::object-finalize
+/filename[arg2] == NULL/
+{
+ @objs["<missed>", copyinstr(arg1)] = sum(-1);
+}
+
+javascript*:::object-finalize
+/filename[arg2] != NULL/
+{
+ @objs[filename[arg2], copyinstr(arg1)] = sum(-1);
+ filename[arg2] = 0;
+}
+
+profile:::tick-1sec,
+dtrace:::END
+{
+ printf("\n %-24s %8s %-20s %23Y\n", "FILE", "TOTAL", "CLASS",
+ walltimestamp);
+ printa(" %-24.24s %@8d %s\n", @objs);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_objnew.d b/cddl/contrib/dtracetoolkit/JavaScript/js_objnew.d
new file mode 100755
index 0000000..f57c7b5
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_objnew.d
@@ -0,0 +1,55 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_objnew.d - count JavaScript object creation using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_objnew.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces JavaScript activity from all browsers running on the system
+ * with JavaScript provider support.
+ *
+ * USAGE: js_objnew.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * FILE Filename of the JavaScript program
+ * CLASS Class of new object
+ * COUNT Number of object creations during tracing
+ *
+ * Filename and class names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::object-create-done
+{
+ @objs[basename(copyinstr(arg0)), copyinstr(arg1)] = count();
+}
+
+dtrace:::END
+{
+ printf(" %-24s %-36s %8s\n", "FILE", "CLASS", "COUNT");
+ printa(" %-24.24s %-36s %@8d\n", @objs);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_stat.d b/cddl/contrib/dtracetoolkit/JavaScript/js_stat.d
new file mode 100755
index 0000000..3237762
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_stat.d
@@ -0,0 +1,120 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_stat.d - JavaScript operation stats using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_stat.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces activity from all browsers on the system that are
+ * running with JavaScript provider support.
+ *
+ * USAGE: js_stat.d [interval [count]]
+ *
+ * FIELDS:
+ * EXEC/s JavaScript programs executed per second
+ * FUNCS/s Functions called, per second
+ * OBJNEW/s Objects created, per second
+ * OBJFRE/s Objects freed (finalize), per second
+ *
+ * The numbers are counts for the interval specified. The default interval
+ * is 1 second.
+ *
+ * Filename and function names are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+#pragma D option defaultargs
+
+inline int SCREEN = 21;
+
+dtrace:::BEGIN
+{
+ execs = funcs = objnew = objfree = 0;
+ lines = SCREEN + 1;
+ interval = $1 ? $1 : 1;
+ counts = $2 ? $2 : -1;
+ secs = interval;
+ first = 1;
+}
+
+profile:::tick-1sec
+{
+ secs--;
+}
+
+/*
+ * Print Header
+ */
+dtrace:::BEGIN,
+profile:::tick-1sec
+/first || (secs == 0 && lines > SCREEN)/
+{
+ printf("%-20s %8s %8s %8s %8s\n", "TIME", "EXEC/s", "FUNC/s",
+ "OBJNEW/s", "OBJFRE/s");
+ lines = 0;
+ first = 0;
+}
+
+/*
+ * Tally Data
+ */
+javascript*:::execute-start
+{
+ execs++;
+}
+
+javascript*:::function-entry
+{
+ funcs++;
+}
+
+javascript*:::object-create-start
+{
+ objnew++;
+}
+
+javascript*:::object-finalize
+{
+ objfree++;
+}
+
+/*
+ * Print Output
+ */
+profile:::tick-1sec
+/secs == 0/
+{
+ printf("%-20Y %8d %8d %8d %8d\n", walltimestamp, execs / interval,
+ funcs / interval, objnew / interval, objfree / interval);
+ execs = funcs = objnew = objfree = 0;
+ secs = interval;
+ lines++;
+ counts--;
+}
+
+/*
+ * End
+ */
+profile:::tick-1sec
+/counts == 0/
+{
+ exit(0);
+}
diff --git a/cddl/contrib/dtracetoolkit/JavaScript/js_who.d b/cddl/contrib/dtracetoolkit/JavaScript/js_who.d
new file mode 100755
index 0000000..f320b48
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/JavaScript/js_who.d
@@ -0,0 +1,56 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * js_who.d - trace JavaScript function execution by process using DTrace.
+ * Written for the JavaScript DTrace provider.
+ *
+ * $Id: js_who.d 63 2007-10-04 04:34:38Z brendan $
+ *
+ * This traces JavaScript activity from all browsers on the system that are
+ * running with JavaScript provider support.
+ *
+ * USAGE: js_who.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * PID Process ID of JavaScript
+ * UID User ID of the owner
+ * FUNCS Number of function calls
+ * FILE Pathname of the JavaScript program
+ *
+ * Filenames are printed if available.
+ *
+ * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
+ *
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License, Version 1.0 only
+ * (the "License"). You may not use this file except in compliance
+ * with the License.
+ *
+ * You can obtain a copy of the license at Docs/cddl1.txt
+ * or http://www.opensolaris.org/os/licensing.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ *
+ * CDDL HEADER END
+ *
+ * 09-Sep-2007 Brendan Gregg Created this.
+ */
+
+#pragma D option quiet
+
+dtrace:::BEGIN
+{
+ printf("Tracing... Hit Ctrl-C to end.\n");
+}
+
+javascript*:::function-entry
+{
+ @funcs[pid, uid, copyinstr(arg0)] = count();
+}
+
+dtrace:::END
+{
+ printf(" %6s %6s %6s %s\n", "PID", "UID", "FUNCS", "FILE");
+ printa(" %6d %6d %@6d %s\n", @funcs);
+}
OpenPOWER on IntegriCloud