summaryrefslogtreecommitdiffstats
path: root/cddl/contrib/dtracetoolkit/Php
diff options
context:
space:
mode:
Diffstat (limited to 'cddl/contrib/dtracetoolkit/Php')
-rw-r--r--cddl/contrib/dtracetoolkit/Php/Readme39
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_calldist.d83
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_calltime.d90
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_cpudist.d83
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_cputime.d90
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_flow.d72
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_flowinfo.d88
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_flowtime.d91
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_funccalls.d56
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_malloc.d82
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_syscalls.d75
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_syscolors.d116
-rwxr-xr-xcddl/contrib/dtracetoolkit/Php/php_who.d56
13 files changed, 1021 insertions, 0 deletions
diff --git a/cddl/contrib/dtracetoolkit/Php/Readme b/cddl/contrib/dtracetoolkit/Php/Readme
new file mode 100644
index 0000000..5c9101f
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/Readme
@@ -0,0 +1,39 @@
+Php - DTracing PHP
+
+ These scripts trace the PHP programming language, and require the PHP
+ DTrace extension module to be installed and enabled.
+
+ The PHP DTrace provider was written by Wes Furlong, and is available
+ for download both as source and in binary form. The easiest instructions
+ are currently at,
+
+ http://blogs.sun.com/shanti/entry/dtrace_support_for_php
+
+ which were written for Solaris and the coolstack distribution of PHP.
+ The steps are roughly,
+
+ 1. Download the extension library from the URL above
+ 2. Copy the library to your php/extensions/* directory
+ 3. Edit your php.ini and add,
+ extension="dtrace.so"
+
+ The website with the PHP DTrace provider source is,
+
+ http://pecl.php.net/package/DTrace
+
+ Here you can fetch the source to build the library yourself, especially
+ if Solaris binaries from the previous URL aren't going to work for you.
+
+ Since the DTrace PHP 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 php {
+ probe function-entry(function, file, lineno)
+ probe function-return(function, file, lineno)
+ };
+
diff --git a/cddl/contrib/dtracetoolkit/Php/php_calldist.d b/cddl/contrib/dtracetoolkit/Php/php_calldist.d
new file mode 100755
index 0000000..7a1b19e
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_calldist.d
@@ -0,0 +1,83 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_calldist.d - measure PHP elapsed times for functions.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_calldist.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This traces PHP activity from all programs running on the system with
+ * PHP provider support.
+ *
+ * USAGE: php_calldist.d # hit Ctrl-C to end
+ *
+ * This script prints distribution plots of elapsed time for PHP
+ * operations. Use php_calltime.d for summary reports.
+ *
+ * FIELDS:
+ * 1 Filename of the PHP program
+ * 2 Type of call (func)
+ * 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");
+}
+
+php*:::function-entry
+/arg0/
+{
+ self->depth++;
+ self->exclude[self->depth] = 0;
+ self->function[self->depth] = timestamp;
+}
+
+php*:::function-return
+/arg0 && 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(arg1));
+ this->name = copyinstr(arg0);
+
+ @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;
+}
+
+dtrace:::END
+{
+ 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/Php/php_calltime.d b/cddl/contrib/dtracetoolkit/Php/php_calltime.d
new file mode 100755
index 0000000..dcb708c
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_calltime.d
@@ -0,0 +1,90 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_calltime.d - measure PHP elapsed times for functions.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_calltime.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This traces PHP activity from all programs running on the system with
+ * PHP provider support.
+ *
+ * USAGE: php_calltime.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * FILE Filename of the PHP program
+ * TYPE Type of call (func/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");
+}
+
+php*:::function-entry
+/arg0/
+{
+ self->depth++;
+ self->exclude[self->depth] = 0;
+ self->function[self->depth] = timestamp;
+}
+
+php*:::function-return
+/arg0 && 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(arg1));
+ this->name = copyinstr(arg0);
+
+ @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;
+}
+
+dtrace:::END
+{
+ printf("\nCount,\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "COUNT");
+ printa(" %-20s %-10s %-32s %@8d\n", @num);
+
+ normalize(@types_excl, 1000);
+ printf("\nExclusive function elapsed times (us),\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "TOTAL");
+ printa(" %-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(" %-20s %-10s %-32s %@8d\n", @types_incl);
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_cpudist.d b/cddl/contrib/dtracetoolkit/Php/php_cpudist.d
new file mode 100755
index 0000000..e10566c7
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_cpudist.d
@@ -0,0 +1,83 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_cpudist.d - measure PHP on-CPU times for functions.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_cpudist.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This traces PHP activity from all programs running on the system with
+ * PHP provider support.
+ *
+ * USAGE: php_cpudist.d # hit Ctrl-C to end
+ *
+ * This script prints distribution plots of elapsed time for PHP
+ * operations. Use php_cputime.d for summary reports.
+ *
+ * FIELDS:
+ * 1 Filename of the PHP program
+ * 2 Type of call (func)
+ * 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");
+}
+
+php*:::function-entry
+/arg0/
+{
+ self->depth++;
+ self->exclude[self->depth] = 0;
+ self->function[self->depth] = vtimestamp;
+}
+
+php*:::function-return
+/arg0 && 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(arg1));
+ this->name = copyinstr(arg0);
+
+ @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;
+}
+
+dtrace:::END
+{
+ 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/Php/php_cputime.d b/cddl/contrib/dtracetoolkit/Php/php_cputime.d
new file mode 100755
index 0000000..856d551
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_cputime.d
@@ -0,0 +1,90 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_cputime.d - measure PHP on-CPU times for functions.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_cputime.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This traces PHP activity from all programs running on the system with
+ * PHP provider support.
+ *
+ * USAGE: php_cputime.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * FILE Filename of the PHP program
+ * TYPE Type of call (func/total)
+ * NAME Name of call (function name)
+ * 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");
+}
+
+php*:::function-entry
+/arg0/
+{
+ self->depth++;
+ self->exclude[self->depth] = 0;
+ self->function[self->depth] = vtimestamp;
+}
+
+php*:::function-return
+/arg0 && 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(arg1));
+ this->name = copyinstr(arg0);
+
+ @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;
+}
+
+dtrace:::END
+{
+ printf("\nCount,\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "COUNT");
+ printa(" %-20s %-10s %-32s %@8d\n", @num);
+
+ normalize(@types_excl, 1000);
+ printf("\nExclusive function on-CPU times (us),\n");
+ printf(" %-20s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "TOTAL");
+ printa(" %-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(" %-20s %-10s %-32s %@8d\n", @types_incl);
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_flow.d b/cddl/contrib/dtracetoolkit/Php/php_flow.d
new file mode 100755
index 0000000..49472ea
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_flow.d
@@ -0,0 +1,72 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_flow.d - snoop PHP execution showing function flow.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_flow.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This traces PHP activity from all PHP programs on the system
+ * running with PHP provider support.
+ *
+ * USAGE: php_flow.d # hit Ctrl-C to end
+ *
+ * This watches PHP function entries and returns, and indents child
+ * function calls.
+ *
+ * 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
+ *
+ * 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 %-16s -- %s\n", "C", "TIME(us)", "FILE", "FUNC");
+}
+
+php*:::function-entry
+/arg0/
+{
+ printf("%3d %-16d %-16s %*s-> %s\n", cpu, timestamp / 1000,
+ basename(copyinstr(arg1)), self->depth * 2, "", copyinstr(arg0));
+ self->depth++;
+}
+
+php*:::function-return
+/arg0/
+{
+ self->depth -= self->depth > 0 ? 1 : 0;
+ printf("%3d %-16d %-16s %*s<- %s\n", cpu, timestamp / 1000,
+ basename(copyinstr(arg1)), self->depth * 2, "", copyinstr(arg0));
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_flowinfo.d b/cddl/contrib/dtracetoolkit/Php/php_flowinfo.d
new file mode 100755
index 0000000..e537574
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_flowinfo.d
@@ -0,0 +1,88 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_flowinfo.d - snoop PHP function flow with info using DTrace.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_flowinfo.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This traces activity from all PHP programs on the system that are
+ * running with PHP provider support.
+ *
+ * USAGE: php_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 PHP program
+ * LINE Line number of filename
+ * TYPE Type of call (func)
+ * FUNC PHP function
+ *
+ * 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("%s %6s/%-4s %10s %16s:%-4s %-8s -- %s\n", "C", "PID", "TID",
+ "DELTA(us)", "FILE", "LINE", "TYPE", "FUNC");
+}
+
+php*:::function-entry,
+php*:::function-return
+/self->last == 0/
+{
+ self->last = timestamp;
+}
+
+php*:::function-entry
+/arg0/
+{
+ this->delta = (timestamp - self->last) / 1000;
+ printf("%d %6d/%-4d %10d %16s:%-4d %-8s %*s-> %s\n", cpu, pid, tid,
+ this->delta, basename(copyinstr(arg1)), arg2, "func",
+ self->depth * 2, "", copyinstr(arg0));
+ self->depth++;
+ self->last = timestamp;
+}
+
+php*:::function-return
+/arg0/
+{
+ this->delta = (timestamp - self->last) / 1000;
+ self->depth -= self->depth > 0 ? 1 : 0;
+ printf("%d %6d/%-4d %10d %16s:%-4d %-8s %*s<- %s\n", cpu, pid, tid,
+ this->delta, basename(copyinstr(arg1)), arg2, "func",
+ self->depth * 2, "", copyinstr(arg0));
+ self->last = timestamp;
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_flowtime.d b/cddl/contrib/dtracetoolkit/Php/php_flowtime.d
new file mode 100755
index 0000000..cadb66a
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_flowtime.d
@@ -0,0 +1,91 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_flowtime.d - snoop PHP functions with flow and delta times.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_flowtime.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This traces shell activity from PHP programs on the system that are
+ * running with PHP provider support.
+ *
+ * USAGE: php_flowtime.d # hit Ctrl-C to end
+ *
+ * This watches PHP function entries and returns, and indents child
+ * function calls.
+ *
+ * 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 PHP 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;
+
+self int last;
+
+dtrace:::BEGIN
+{
+ printf("%3s %-16s %-16s %9s -- %s\n", "C", "TIME(us)", "FILE",
+ "DELTA(us)", "FUNC");
+}
+
+php*:::function-entry,
+php*:::function-return
+/self->last == 0/
+{
+ self->last = timestamp;
+}
+
+php*:::function-entry
+/arg0/
+{
+ this->delta = (timestamp - self->last) / 1000;
+ printf("%3d %-16d %-16s %9d %*s-> %s\n", cpu, timestamp / 1000,
+ basename(copyinstr(arg1)), this->delta, self->depth * 2, "",
+ copyinstr(arg0));
+ self->depth++;
+ self->last = timestamp;
+}
+
+php*:::function-return
+/arg0/
+{
+ this->delta = (timestamp - self->last) / 1000;
+ self->depth -= self->depth > 0 ? 1 : 0;
+ printf("%3d %-16d %-16s %9d %*s<- %s\n", cpu, timestamp / 1000,
+ basename(copyinstr(arg1)), this->delta, self->depth * 2, "",
+ copyinstr(arg0));
+ self->last = timestamp;
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_funccalls.d b/cddl/contrib/dtracetoolkit/Php/php_funccalls.d
new file mode 100755
index 0000000..8a0ddce
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_funccalls.d
@@ -0,0 +1,56 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_funccalls.d - measure PHP function calls using DTrace.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_funccalls.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This traces PHP activity from all running programs on the system
+ * which support the PHP DTrace provider.
+ *
+ * USAGE: php_funccalls.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * FILE Filename that contained the function
+ * FUNC PHP function name
+ * CALLS Function calls during this 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");
+}
+
+php*:::function-entry
+/arg0/
+{
+ @funcs[basename(copyinstr(arg1)), copyinstr(arg0)] = count();
+}
+
+dtrace:::END
+{
+ printf(" %-32s %-32s %8s\n", "FILE", "FUNC", "CALLS");
+ printa(" %-32s %-32s %@8d\n", @funcs);
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_malloc.d b/cddl/contrib/dtracetoolkit/Php/php_malloc.d
new file mode 100755
index 0000000..1ebab26
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_malloc.d
@@ -0,0 +1,82 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_malloc.d - PHP libc malloc analysis.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_malloc.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * This is an expiremental script to identify who is calling malloc() for
+ * memory allocation, and to print distribution plots of the requested bytes.
+ * If a malloc() occured while in a PHP function, then that function is
+ * identified as responsible; else the caller of malloc() is identified as
+ * responsible - which will be a function from the PHP engine.
+ *
+ * USAGE: php_malloc.d { -p PID | -c cmd } # hit Ctrl-C to end
+ *
+ * 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");
+}
+
+php$target:::function-entry
+/arg0/
+{
+ self->file = basename(copyinstr(arg1));
+ self->name = copyinstr(arg0);
+}
+
+php$target:::function-return
+{
+ self->file = 0;
+ self->name = 0;
+}
+
+pid$target:libc:malloc:entry
+/self->file != NULL/
+{
+ @malloc_func_size[self->file, self->name] = sum(arg1);
+ @malloc_func_dist[self->file, self->name] = quantize(arg1);
+}
+
+pid$target:libc:malloc:entry
+/self->name == NULL/
+{
+ @malloc_lib_size[usym(ucaller)] = sum(arg1);
+ @malloc_lib_dist[usym(ucaller)] = quantize(arg1);
+}
+
+
+dtrace:::END
+{
+ printf("\nPHP malloc byte distributions by engine caller,\n\n");
+ printa(" %A, total bytes = %@d %@d\n", @malloc_lib_size,
+ @malloc_lib_dist);
+
+ printf("\nPHP malloc byte distributions by PHP file and ");
+ printf("function,\n\n");
+ printa(" %s, %s, bytes total = %@d %@d\n", @malloc_func_size,
+ @malloc_func_dist);
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_syscalls.d b/cddl/contrib/dtracetoolkit/Php/php_syscalls.d
new file mode 100755
index 0000000..7917c24
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_syscalls.d
@@ -0,0 +1,75 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_syscalls.d - count PHP function calls and syscalls using DTrace.
+ * Written for the PHP DTrace provider.
+ *
+ * This traces syscalls that occured during a PHP function call.
+ *
+ * $Id: php_syscalls.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * USAGE: php_syscalls.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * PID Process ID
+ * FILE Filename of the PHP program
+ * TYPE Type of call (func/syscall)
+ * NAME Name of call
+ * COUNT Number of calls during sample
+ *
+ * Filename and function names are printed if available.
+ * The filename for syscalls may be printed as "php", if the program
+ * was invoked using the form "php filename" rather than running the
+ * program with an interpreter line.
+ *
+ * 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");
+}
+
+php*:::function-entry
+/arg0/
+{
+ @calls[pid, basename(copyinstr(arg1)), "func", copyinstr(arg0)] =
+ count();
+ self->php++;
+}
+
+php*:::function-return
+/arg0/
+{
+ self->php -= self->php == 0 ? 0 : 1;
+}
+
+syscall:::entry
+/self->php > 0/
+{
+ @calls[pid, basename(execname), "syscall", probefunc] = count();
+}
+
+dtrace:::END
+{
+ printf(" %-6s %-26s %-10s %-22s %8s\n", "PID", "FILE", "TYPE", "NAME",
+ "COUNT");
+ printa(" %-6d %-26s %-10s %-22s %@8d\n", @calls);
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_syscolors.d b/cddl/contrib/dtracetoolkit/Php/php_syscolors.d
new file mode 100755
index 0000000..ff5e9c9
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_syscolors.d
@@ -0,0 +1,116 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_syscolors.d - trace PHP function flow plus syscalls, in color.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_syscolors.d 53 2007-09-24 04:58:38Z brendan $
+ *
+ * USAGE: php_syscolors.d # hit Ctrl-C to end
+ *
+ * This watches PHP function entries and returns, and indents child
+ * function calls.
+ *
+ * FIELDS:
+ * C CPU-id
+ * PID Process ID
+ * DELTA(us) Elapsed time from previous line to this line
+ * FILE Filename of the PHP program
+ * LINE Line number of filename
+ * TYPE Type of call (func/syscall)
+ * NAME PHP function or syscall name
+ *
+ * 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
+{
+ color_php = "\033[2;35m"; /* violet, faint */
+ color_syscall = "\033[2;32m"; /* green, faint */
+ color_off = "\033[0m"; /* default */
+
+ self->depth = 0;
+ printf("%s %6s/%-4s %10s %16s:%-4s %-8s -- %s\n", "C", "PID", "TID",
+ "DELTA(us)", "FILE", "LINE", "TYPE", "NAME");
+}
+
+php*:::function-entry,
+php*:::function-return
+/self->last == 0/
+{
+ self->last = timestamp;
+}
+
+php*:::function-entry
+/arg0/
+{
+ this->delta = (timestamp - self->last) / 1000;
+ printf("%s%d %6d/%-4d %10d %16s:%-4d %-8s %*s-> %s%s\n", color_php,
+ cpu, pid, tid, this->delta, basename(copyinstr(arg1)), arg2, "func",
+ self->depth * 2, "", copyinstr(arg0), color_off);
+ self->depth++;
+ self->last = timestamp;
+}
+
+php*:::function-return
+/arg0/
+{
+ this->delta = (timestamp - self->last) / 1000;
+ this->name = strjoin(strjoin(copyinstr(arg1), "::"), copyinstr(arg0));
+ self->depth -= self->depth > 0 ? 1 : 0;
+ printf("%s%d %6d/%-4d %10d %16s:%-4d %-8s %*s<- %s%s\n", color_php,
+ cpu, pid, tid, this->delta, basename(copyinstr(arg1)), arg2, "func",
+ self->depth * 2, "", copyinstr(arg0), color_off);
+ self->last = timestamp;
+}
+
+syscall:::entry
+/self->last/
+{
+ this->delta = (timestamp - self->last) / 1000;
+ printf("%s%d %6d/%-4d %10d %16s:- %-8s %*s-> %s%s\n", color_syscall,
+ cpu, pid, tid, this->delta, "\"", "syscall", self->depth * 2, "",
+ probefunc, color_off);
+ self->last = timestamp;
+}
+
+syscall:::return
+/self->last/
+{
+ this->delta = (timestamp - self->last) / 1000;
+ printf("%s%d %6d/%-4d %10d %16s:- %-8s %*s<- %s%s\n", color_syscall,
+ cpu, pid, tid, this->delta, "\"", "syscall", self->depth * 2, "",
+ probefunc, color_off);
+ self->last = timestamp;
+}
+
+proc:::exit
+/pid == $target/
+{
+ exit(0);
+}
diff --git a/cddl/contrib/dtracetoolkit/Php/php_who.d b/cddl/contrib/dtracetoolkit/Php/php_who.d
new file mode 100755
index 0000000..2ebb4b4
--- /dev/null
+++ b/cddl/contrib/dtracetoolkit/Php/php_who.d
@@ -0,0 +1,56 @@
+#!/usr/sbin/dtrace -Zs
+/*
+ * php_who.d - trace PHP function execution by process using DTrace.
+ * Written for the PHP DTrace provider.
+ *
+ * $Id: php_who.d 51 2007-09-24 00:55:23Z brendan $
+ *
+ * This traces PHP activity from all PHP programs on the system that are
+ * running with PHP provider support.
+ *
+ * USAGE: php_who.d # hit Ctrl-C to end
+ *
+ * FIELDS:
+ * PID Process ID of PHP
+ * UID User ID of the owner
+ * FUNCS Number of function calls
+ * FILE Pathname of the PHP 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");
+}
+
+php*:::function-entry
+{
+ @lines[pid, uid, copyinstr(arg1)] = count();
+}
+
+dtrace:::END
+{
+ printf(" %6s %6s %6s %s\n", "PID", "UID", "FUNCS", "FILE");
+ printa(" %6d %6d %@6d %s\n", @lines);
+}
OpenPOWER on IntegriCloud