diff options
Diffstat (limited to 'cddl/contrib/dtracetoolkit/Ruby')
18 files changed, 1569 insertions, 0 deletions
diff --git a/cddl/contrib/dtracetoolkit/Ruby/Readme b/cddl/contrib/dtracetoolkit/Ruby/Readme new file mode 100644 index 0000000..9dc3cc3 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/Readme @@ -0,0 +1,31 @@ +Ruby - DTracing Ruby + + These scripts trace activity of the Ruby programming language, and + require the DTrace Ruby provider written by Joyent. + + Currently, the DTrace Ruby provider is a seperate download either in + patch, source or binary form. Start with the "Ruby DTrace" link on + http://dtrace.joyent.com/, and after getting a version running, the + scripts in this directory should work. + + Since the DTrace Ruby provider is under development, 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 ruby { + probe function-entry(class, method, file, lineno); + probe function-return(class, method, file, lineno); + probe raise(errinfo, file, lineno); + probe rescue(file, lineno); + probe line(file, lineno); + probe gc-begin(); + probe gc-end(); + probe object-create-start(object, file, lineno); + probe object-create-done(object, file, lineno); + probe object-free(object); + }; + diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_calldist.d b/cddl/contrib/dtracetoolkit/Ruby/rb_calldist.d new file mode 100755 index 0000000..e3018ea --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_calldist.d @@ -0,0 +1,120 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_calldist.d - measure Ruby elapsed times for types of operation. + * Written for the Ruby DTrace provider. + * + * $Id: rb_calldist.d 28 2007-09-13 10:49:37Z brendan $ + * + * This traces Ruby activity from all programs running on the system with + * Ruby provider support. + * + * USAGE: rb_calldist.d # hit Ctrl-C to end + * + * This script prints distribution plots of elapsed time for Ruby + * operations. Use rb_calltime.d for summary reports. + * + * FIELDS: + * 1 Filename of the Ruby program + * 2 Type of call (method/obj-new/gc) + * 3 Name of call + * + * Filename and method 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"); +} + +ruby*:::function-entry +{ + self->depth++; + self->exclude[self->depth] = 0; + self->function[self->depth] = timestamp; +} + +ruby*:::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(arg2)); + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + + @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; +} + +ruby*:::object-create-start +{ + self->object = timestamp; +} + +ruby*:::object-create-done +/self->object/ +{ + this->elapsed = timestamp - self->object; + self->object = 0; + this->file = basename(copyinstr(arg1)); + this->file = this->file != NULL ? this->file : "."; + + @types[this->file, "obj-new", copyinstr(arg0)] = + quantize(this->elapsed / 1000); + + self->exclude[self->depth] += this->elapsed; +} + +ruby*:::gc-begin +{ + self->gc = timestamp; +} + +ruby*:::gc-end +/self->gc/ +{ + this->elapsed = timestamp - self->gc; + self->gc = 0; + + @types[".", "gc", "-"] = 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/Ruby/rb_calls.d b/cddl/contrib/dtracetoolkit/Ruby/rb_calls.d new file mode 100755 index 0000000..10e3b5a --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_calls.d @@ -0,0 +1,87 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_calls.d - count Ruby calls using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_calls.d 28 2007-09-13 10:49:37Z brendan $ + * + * This traces activity from all Ruby programs on the system that are + * running with Ruby provider support. + * + * USAGE: rb_calls.d # hit Ctrl-C to end + * + * FIELDS: + * FILE Filename of the Ruby program + * TYPE Type of call (method/obj-new/...) + * NAME Descriptive name of call + * COUNT Number of calls during sample + * + * Filename and method 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"); +} + +ruby*:::function-entry +{ + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + @calls[basename(copyinstr(arg2)), "method", this->name] = count(); +} + +ruby*:::object-create-start +{ + this->name = copyinstr(arg0); + this->filename = basename(copyinstr(arg1)); + this->filename = this->filename != NULL ? this->filename : "."; + @calls[this->filename, "obj-new", this->name] = count(); +} + +ruby*:::object-free +{ + this->name = copyinstr(arg0); + @calls[".", "obj-free", this->name] = count(); +} + +ruby*:::gc-begin +{ + @calls[".", "gc", "begin"] = count(); +} + +ruby*:::raise +{ + this->name = copyinstr(arg0); + @calls[basename(copyinstr(arg1)), "raise", this->name] = count(); +} + +ruby*:::rescue +{ + @calls[basename(copyinstr(arg0)), "rescue", "-"] = 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/Ruby/rb_calltime.d b/cddl/contrib/dtracetoolkit/Ruby/rb_calltime.d new file mode 100755 index 0000000..fac1261 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_calltime.d @@ -0,0 +1,129 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_calltime.d - measure Ruby elapsed times for types of operation. + * Written for the Ruby DTrace provider. + * + * $Id: rb_calltime.d 41 2007-09-17 02:20:10Z brendan $ + * + * This traces Ruby activity from all programs running on the system with + * Ruby provider support. + * + * USAGE: rb_calltime.d # hit Ctrl-C to end + * + * FIELDS: + * FILE Filename of the Ruby program + * TYPE Type of call (method/obj-new/gc/total) + * NAME Name of call + * TOTAL Total elapsed time for calls (us) + * + * Filename and method 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"); +} + +ruby*:::function-entry +{ + self->depth++; + self->exclude[self->depth] = 0; + self->function[self->depth] = timestamp; +} + +ruby*:::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(arg2)); + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + + @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; +} + +ruby*:::object-create-start +{ + self->object = timestamp; +} + +ruby*:::object-create-done +/self->object/ +{ + this->elapsed = timestamp - self->object; + self->object = 0; + this->file = basename(copyinstr(arg1)); + this->file = this->file != NULL ? this->file : "."; + this->name = copyinstr(arg0); + + @num[this->file, "obj-new", this->name] = count(); + @types[this->file, "obj-new", this->name] = sum(this->elapsed); + + self->exclude[self->depth] += this->elapsed; +} + +ruby*:::gc-begin +{ + self->gc = timestamp; +} + +ruby*:::gc-end +/self->gc/ +{ + this->elapsed = timestamp - self->gc; + self->gc = 0; + @num[".", "gc", "-"] = count(); + @types[".", "gc", "-"] = 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(" %-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(" %-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(" %-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/Ruby/rb_cpudist.d b/cddl/contrib/dtracetoolkit/Ruby/rb_cpudist.d new file mode 100755 index 0000000..daa4d1a --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_cpudist.d @@ -0,0 +1,120 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_cpudist.d - measure Ruby on-CPU times for types of operation. + * Written for the Ruby DTrace provider. + * + * $Id: rb_cpudist.d 28 2007-09-13 10:49:37Z brendan $ + * + * This traces Ruby activity from all programs running on the system with + * Ruby provider support. + * + * USAGE: rb_cpudist.d # hit Ctrl-C to end + * + * This script prints distribution plots of elapsed time for Ruby + * operations. Use rb_cputime.d for summary reports. + * + * FIELDS: + * 1 Filename of the Ruby program + * 2 Type of call (method/obj-new/gc) + * 3 Name of call + * + * Filename and method 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"); +} + +ruby*:::function-entry +{ + self->depth++; + self->exclude[self->depth] = 0; + self->function[self->depth] = vtimestamp; +} + +ruby*:::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(arg2)); + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + + @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; +} + +ruby*:::object-create-start +{ + self->object = vtimestamp; +} + +ruby*:::object-create-done +/self->object/ +{ + this->oncpu = vtimestamp - self->object; + self->object = 0; + this->file = basename(copyinstr(arg1)); + this->file = this->file != NULL ? this->file : "."; + + @types[this->file, "obj-new", copyinstr(arg0)] = + quantize(this->oncpu / 1000); + + self->exclude[self->depth] += this->oncpu; +} + +ruby*:::gc-begin +{ + self->gc = vtimestamp; +} + +ruby*:::gc-end +/self->gc/ +{ + this->oncpu = vtimestamp - self->gc; + self->gc = 0; + + @types[".", "gc", "-"] = quantize(this->oncpu / 1000); + + self->exclude[self->depth] += this->oncpu; +} + +dtrace:::END +{ + printf("\nOn-CPU 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/Ruby/rb_cputime.d b/cddl/contrib/dtracetoolkit/Ruby/rb_cputime.d new file mode 100755 index 0000000..d5885c8 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_cputime.d @@ -0,0 +1,129 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_cputime.d - measure Ruby on-CPU times for types of operation. + * Written for the Ruby DTrace provider. + * + * $Id: rb_cputime.d 49 2007-09-17 12:03:20Z brendan $ + * + * This traces Ruby activity from all programs running on the system with + * Ruby provider support. + * + * USAGE: rb_cputime.d # hit Ctrl-C to end + * + * FIELDS: + * FILE Filename of the Ruby program + * TYPE Type of call (method/obj-new/gc/total) + * NAME Name of call + * TOTAL Total on-CPU time for calls (us) + * + * Filename and method 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"); +} + +ruby*:::function-entry +{ + self->depth++; + self->exclude[self->depth] = 0; + self->function[self->depth] = vtimestamp; +} + +ruby*:::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(arg2)); + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + + @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; +} + +ruby*:::object-create-start +{ + self->object = vtimestamp; +} + +ruby*:::object-create-done +/self->object/ +{ + this->oncpu = vtimestamp - self->object; + self->object = 0; + this->file = basename(copyinstr(arg1)); + this->file = this->file != NULL ? this->file : "."; + this->name = copyinstr(arg0); + + @num[this->file, "obj-new", this->name] = count(); + @types[this->file, "obj-new", this->name] = sum(this->oncpu); + + self->exclude[self->depth] += this->oncpu; +} + +ruby*:::gc-begin +{ + self->gc = vtimestamp; +} + +ruby*:::gc-end +/self->gc/ +{ + this->oncpu = vtimestamp - self->gc; + self->gc = 0; + @num[".", "gc", "-"] = count(); + @types[".", "gc", "-"] = 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(" %-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(" %-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(" %-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/Ruby/rb_flow.d b/cddl/contrib/dtracetoolkit/Ruby/rb_flow.d new file mode 100755 index 0000000..e4ff760 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_flow.d @@ -0,0 +1,72 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_flow.d - snoop Ruby execution showing method flow using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_flow.d 41 2007-09-17 02:20:10Z brendan $ + * + * This traces activity from all Ruby programs on the system that are + * running with Ruby provider support. + * + * USAGE: rb_flow.d # hit Ctrl-C to end + * + * FIELDS: + * C CPU-id + * TIME(us) Time since boot, us + * FILE Filename that this method belongs to + * CLASS::METHOD Ruby classname and method + * + * LEGEND: + * -> method entry + * <- method return + * + * Filename and method 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", + "CLASS::METHOD"); +} + +ruby*:::function-entry +{ + printf("%3d %-16d %-22s %*s-> %s::%s\n", cpu, timestamp / 1000, + basename(copyinstr(arg2)), self->depth * 2, "", copyinstr(arg0), + copyinstr(arg1)); + self->depth++; +} + +ruby*:::function-return +{ + self->depth -= self->depth > 0 ? 1 : 0; + printf("%3d %-16d %-22s %*s<- %s::%s\n", cpu, timestamp / 1000, + basename(copyinstr(arg2)), self->depth * 2, "", copyinstr(arg0), + copyinstr(arg1)); +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_flowinfo.d b/cddl/contrib/dtracetoolkit/Ruby/rb_flowinfo.d new file mode 100755 index 0000000..4657263 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_flowinfo.d @@ -0,0 +1,88 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_flowinfo.d - snoop Ruby function (method) flow with info using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_flowinfo.d 41 2007-09-17 02:20:10Z brendan $ + * + * This traces activity from all Ruby programs on the system that are + * running with Ruby provider support. + * + * USAGE: rb_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 Ruby program + * LINE Line number of filename + * TYPE Type of call (method) + * NAME Ruby class and method name + * + * LEGEND: + * -> method entry + * <- method return + * + * Filename and method 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 %10s %16s:%-4s %-8s -- %s\n", "C", "PID", "DELTA(us)", + "FILE", "LINE", "TYPE", "NAME"); +} + +ruby*:::function-entry, +ruby*:::function-return +/self->last == 0/ +{ + self->last = timestamp; +} + +ruby*:::function-entry +{ + this->delta = (timestamp - self->last) / 1000; + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + printf("%d %6d %10d %16s:%-4d %-8s %*s-> %s\n", cpu, pid, this->delta, + basename(copyinstr(arg2)), arg3, "method", self->depth * 2, "", + this->name); + self->depth++; + self->last = timestamp; +} + +ruby*:::function-return +{ + this->delta = (timestamp - self->last) / 1000; + self->depth -= self->depth > 0 ? 1 : 0; + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + printf("%d %6d %10d %16s:%-4d %-8s %*s<- %s\n", cpu, pid, this->delta, + basename(copyinstr(arg2)), arg3, "method", self->depth * 2, "", + this->name); + self->last = timestamp; +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_flowtime.d b/cddl/contrib/dtracetoolkit/Ruby/rb_flowtime.d new file mode 100755 index 0000000..9b1c668 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_flowtime.d @@ -0,0 +1,84 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_flowtime.d - snoop Ruby function (method) flow using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_flowtime.d 41 2007-09-17 02:20:10Z brendan $ + * + * This traces activity from all Ruby programs on the system that are + * running with Ruby provider support. + * + * USAGE: rb_flowtime.d # hit Ctrl-C to end + * + * FIELDS: + * C CPU-id + * TIME(us) Time since boot, us + * FILE Filename that this method belongs to + * DELTA(us) Elapsed time from previous line to this line + * CLASS::METHOD Ruby class and method name + * + * LEGEND: + * -> method entry + * <- method return + * + * Filename and method 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 %-16s %9s -- %s\n", "C", "TIME(us)", "FILE", + "DELTA(us)", "CLASS::METHOD"); +} + +ruby*:::function-entry, +ruby*:::function-return +/self->last == 0/ +{ + self->last = timestamp; +} + +ruby*:::function-entry +{ + this->delta = (timestamp - self->last) / 1000; + printf("%3d %-16d %-16s %9d %*s-> %s::%s\n", cpu, timestamp / 1000, + basename(copyinstr(arg2)), this->delta, self->depth * 2, "", + copyinstr(arg0), copyinstr(arg1)); + self->depth++; + self->last = timestamp; +} + +ruby*:::function-return +{ + this->delta = (timestamp - self->last) / 1000; + self->depth -= self->depth > 0 ? 1 : 0; + printf("%3d %-16d %-16s %9d %*s<- %s::%s\n", cpu, timestamp / 1000, + basename(copyinstr(arg2)), this->delta, self->depth * 2, "", + copyinstr(arg0), copyinstr(arg1)); + self->last = timestamp; +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_funccalls.d b/cddl/contrib/dtracetoolkit/Ruby/rb_funccalls.d new file mode 100755 index 0000000..7621500 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_funccalls.d @@ -0,0 +1,57 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_funccalls.d - count Ruby function (method) calls using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_funccalls.d 20 2007-09-12 09:28:22Z brendan $ + * + * This traces activity from all Ruby programs on the system that are + * running with Ruby provider support. + * + * USAGE: rb_funccalls.d # hit Ctrl-C to end + * + * FIELDS: + * FILE Filename of the Ruby program + * METHOD Method name + * COUNT Number of calls during sample + * + * Filename and method 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"); +} + +ruby*:::function-entry +{ + @funcs[basename(copyinstr(arg2)), copyinstr(arg0), copyinstr(arg1)] = + count(); +} + +dtrace:::END +{ + printf(" %-32.32s %-16s %-16s %8s\n", "FILE", "CLASS", "METHOD", + "CALLS"); + printa(" %-32.32s %-16s %-16s %@8d\n", @funcs); +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_lines.d b/cddl/contrib/dtracetoolkit/Ruby/rb_lines.d new file mode 100755 index 0000000..438f1f1 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_lines.d @@ -0,0 +1,55 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_lines.d - trace Ruby line execution by process using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_lines.d 20 2007-09-12 09:28:22Z brendan $ + * + * This traces Ruby activity from all Ruby programs on the system that are + * running with Ruby provider support. + * + * USAGE: rb_who.d # hit Ctrl-C to end + * + * FIELDS: + * FILE Filename of the Ruby program + * LINE Line number + * COUNT Number of times a line was executed + * + * 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"); +} + +ruby*:::line +{ + @calls[basename(copyinstr(arg0)), arg1] = count(); +} + +dtrace:::END +{ + printf(" %32s:%-6s %10s\n", "FILE", "LINE", "COUNT"); + printa(" %32s:%-6d %@10d\n", @calls); +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_malloc.d b/cddl/contrib/dtracetoolkit/Ruby/rb_malloc.d new file mode 100755 index 0000000..891b840 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_malloc.d @@ -0,0 +1,80 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_malloc.d - Ruby operations and libc malloc statistics. + * Written for the Ruby DTrace provider. + * + * $Id: rb_malloc.d 20 2007-09-12 09:28:22Z brendan $ + * + * WARNING: This script is not 100% accurate; This prints libc malloc() byte + * distributions by "recent" Ruby operation, which we hope will be usually + * relevant. This is an experimental script that may be improved over time. + * + * USAGE: rb_malloc.d { -p PID | -c cmd } # hit Ctrl-C to end + * + * FIELDS: + * 1 Filename of the Ruby program + * 2 Type of operation (method/objnew/startup) + * 3 Name of operation + * + * Filename and method 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 + +self string filename; + +dtrace:::BEGIN +{ + printf("Tracing... Hit Ctrl-C to end.\n"); +} + +ruby$target:::function-entry +{ + self->file = basename(copyinstr(arg2)); + self->type = "method"; + self->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); +} + +ruby$target:::object-create-start +{ + self->file = basename(copyinstr(arg1)); + self->type = "objnew"; + self->name = copyinstr(arg0); +} + +pid$target:libc:malloc:entry +/self->file != NULL/ +{ + @mallocs[self->file, self->type, self->name] = quantize(arg0); +} + +pid$target:libc:malloc:entry +/self->file == NULL/ +{ + @mallocs["ruby", "startup", "-"] = quantize(arg0); +} + + +dtrace:::END +{ + printf("Ruby malloc byte distributions by recent Ruby operation,\n"); + printa(" %s, %s, %s %@d\n", @mallocs); +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_objcpu.d b/cddl/contrib/dtracetoolkit/Ruby/rb_objcpu.d new file mode 100755 index 0000000..23c55e8 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_objcpu.d @@ -0,0 +1,61 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_objcpu.d - measure Ruby object creation on-CPU time using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_objcpu.d 20 2007-09-12 09:28:22Z brendan $ + * + * This traces Ruby activity from all programs running on the system with + * Ruby provider support. + * + * USAGE: rb_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"); +} + +ruby*:::object-create-start +{ + self->vstart = vtimestamp; +} + +ruby*:::object-create-done +/self->vstart/ +{ + this->oncpu = vtimestamp - self->vstart; + @total = sum(this->oncpu); + @dist[copyinstr(arg0)] = 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/Ruby/rb_objnew.d b/cddl/contrib/dtracetoolkit/Ruby/rb_objnew.d new file mode 100755 index 0000000..f6f00f1 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_objnew.d @@ -0,0 +1,55 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_objnew.d - count Ruby object creation using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_objnew.d 20 2007-09-12 09:28:22Z brendan $ + * + * This traces Ruby activity from all programs running on the system with + * Ruby provider support. + * + * USAGE: rb_objnew.d # hit Ctrl-C to end + * + * FIELDS: + * FILE Filename of the Ruby 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"); +} + +ruby*:::object-create-done +{ + @objs[basename(copyinstr(arg1)), copyinstr(arg0)] = count(); +} + +dtrace:::END +{ + printf(" %-24s %-36s %8s\n", "FILE", "CLASS", "COUNT"); + printa(" %-24.24s %-36s %@8d\n", @objs); +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_stat.d b/cddl/contrib/dtracetoolkit/Ruby/rb_stat.d new file mode 100755 index 0000000..6de19f6 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_stat.d @@ -0,0 +1,146 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_stat.d - Ruby operation stats using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_stat.d 20 2007-09-12 09:28:22Z brendan $ + * + * This traces activity from all Ruby programs on the system that are + * running with Ruby provider support. + * + * USAGE: rb_stat.d [interval [count]] + * + * FIELDS: + * EXEC/s Ruby programs executed per second, including + * those without Ruby provider support + * METHOD/s Methods called, per second + * OBJNEW/s Objects created, per second + * OBJFRE/s Objects freed, per second + * RAIS/s Raises, per second + * RESC/s Rescues, per second + * GC/s Garbage collects, per second + * + * The numbers are counts for the interval specified. The default interval + * is 1 second. + * + * If you see a count in "EXECS" but not in the other columns, then your + * Ruby software is probably not running with the DTrace Ruby provider. + * See Ruby/Readme. + * + * Filename and method 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 = methods = objnew = objfree = gc = raised = rescue = 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 %6s %6s %6s\n", "TIME", "EXEC/s", + "METHOD/s", "OBJNEW/s", "OBJFRE/s", "RAIS/s", "RESC/s", "GC/s"); + lines = 0; + first = 0; +} + +/* + * Tally Data + */ +proc:::exec-success +/execname == "ruby"/ +{ + execs++; +} + +ruby*:::function-entry +{ + methods++; +} + +ruby*:::object-create-start +{ + objnew++; +} + +ruby*:::object-free +{ + objfree++; +} + +ruby*:::raise +{ + raised++; +} + +ruby*:::rescue +{ + rescue++; +} + +ruby*:::gc-begin +{ + gc++; +} + +/* + * Print Output + */ +profile:::tick-1sec +/secs == 0/ +{ + printf("%-20Y %8d %8d %8d %8d %6d %6d %6d\n", walltimestamp, + execs / interval, methods / interval, objnew / interval, + objfree / interval, raised / interval, rescue / interval, + gc / interval); + execs = methods = objnew = objfree = gc = raised = rescue = 0; + secs = interval; + lines++; + counts--; +} + +/* + * End + */ +profile:::tick-1sec +/counts == 0/ +{ + exit(0); +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_syscalls.d b/cddl/contrib/dtracetoolkit/Ruby/rb_syscalls.d new file mode 100755 index 0000000..495060b --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_syscalls.d @@ -0,0 +1,66 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_syscalls.d - count Ruby calls and syscalls using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_syscalls.d 20 2007-09-12 09:28:22Z brendan $ + * + * USAGE: rb_syscalls.d { -p PID | -c cmd } # hit Ctrl-C to end + * + * FIELDS: + * FILE Filename of the Ruby program + * TYPE Type of call (method/syscall) + * NAME Name of call + * COUNT Number of calls during sample + * + * Filename and method names are printed if available. + * The filename for syscalls may be printed as "ruby", if the program + * was invoked using the form "ruby 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 + +self string filename; + +dtrace:::BEGIN +{ + printf("Tracing... Hit Ctrl-C to end.\n"); +} + +ruby$target:::function-entry +{ + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + @calls[basename(copyinstr(arg2)), "method", this->name] = count(); +} + +syscall:::entry +/pid == $target/ +{ + @calls[basename(execname), "syscall", probefunc] = count(); +} + +dtrace:::END +{ + printf("\nCalls for PID %d,\n\n", $target); + printf(" %-32s %-10s %-22s %8s\n", "FILE", "TYPE", "NAME", "COUNT"); + printa(" %-32s %-10s %-22s %@8d\n", @calls); +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_syscolors.d b/cddl/contrib/dtracetoolkit/Ruby/rb_syscolors.d new file mode 100755 index 0000000..e14ac08 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_syscolors.d @@ -0,0 +1,133 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_syscolors.d - trace Ruby method flow plus syscalls, in color. + * Written for the Ruby DTrace provider. + * + * $Id: rb_syscolors.d 27 2007-09-13 09:26:01Z brendan $ + * + * USAGE: rb_syscolors.d { -p PID | -c cmd } # hit Ctrl-C to end + * + * This watches Ruby method 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 Ruby program + * LINE Line number of filename + * TYPE Type of call (method/line/syscall) + * NAME Ruby method or syscall name + * + * Filename and method 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 +{ + /* + * The following are terminal color escape sequences. + * Change them to whatever you prefer, eg HTML font tags. + */ + color_ruby = "\033[2;35m"; /* violet, faint */ + color_line = "\033[1;35m"; /* violet, bold */ + color_syscall = "\033[2;32m"; /* green, faint */ + color_off = "\033[0m"; /* default */ + + printf("%s %6s %10s %16s:%-4s %-8s -- %s\n", "C", "PID", "DELTA(us)", + "FILE", "LINE", "TYPE", "NAME"); +} + +ruby$target:::function-entry, +ruby$target:::function-return, +ruby$target:::line, +syscall:::entry, +syscall:::return +/self->last == 0 && pid == $target/ +{ + self->last = timestamp; +} + +ruby$target:::function-entry +{ + this->delta = (timestamp - self->last) / 1000; + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + printf("%s%d %6d %10d %16s:%-4d %-8s %*s-> %s%s\n", color_ruby, + cpu, pid, this->delta, basename(copyinstr(arg2)), arg3, "method", + self->depth * 2, "", this->name, color_off); + self->depth++; + self->last = timestamp; +} + +ruby$target:::function-return +{ + this->delta = (timestamp - self->last) / 1000; + this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1)); + self->depth--; + printf("%s%d %6d %10d %16s:%-4d %-8s %*s<- %s%s\n", color_ruby, + cpu, pid, this->delta, basename(copyinstr(arg2)), arg3, "method", + self->depth * 2, "", this->name, color_off); + self->last = timestamp; +} + +ruby$target:::line +{ + this->delta = (timestamp - self->last) / 1000; + printf("%s%d %6d %10d %16s:%-4d %-8s %*s-- %s\n", color_line, + cpu, pid, this->delta, basename(copyinstr(arg0)), arg1, "line", + self->depth * 2, "", color_off); + self->last = timestamp; +} + +syscall:::entry +/pid == $target/ +{ + this->delta = (timestamp - self->last) / 1000; + printf("%s%d %6d %10d %16s:- %-8s %*s-> %s%s\n", color_syscall, + cpu, pid, this->delta, "\"", "syscall", self->depth * 2, "", + probefunc, color_off); + self->depth++; + self->last = timestamp; +} + +syscall:::return +/pid == $target/ +{ + this->delta = (timestamp - self->last) / 1000; + self->depth--; + printf("%s%d %6d %10d %16s:- %-8s %*s<- %s%s\n", color_syscall, + cpu, pid, this->delta, "\"", "syscall", self->depth * 2, "", + probefunc, color_off); + self->last = timestamp; +} + +proc:::exit +/pid == $target/ +{ + exit(0); +} diff --git a/cddl/contrib/dtracetoolkit/Ruby/rb_who.d b/cddl/contrib/dtracetoolkit/Ruby/rb_who.d new file mode 100755 index 0000000..0119368 --- /dev/null +++ b/cddl/contrib/dtracetoolkit/Ruby/rb_who.d @@ -0,0 +1,56 @@ +#!/usr/sbin/dtrace -Zs +/* + * rb_who.d - trace Ruby line execution by process using DTrace. + * Written for the Ruby DTrace provider. + * + * $Id: rb_who.d 49 2007-09-17 12:03:20Z brendan $ + * + * This traces Ruby activity from all Ruby programs on the system that are + * running with Ruby provider support. + * + * USAGE: rb_who.d # hit Ctrl-C to end + * + * FIELDS: + * PID Process ID of Ruby + * UID User ID of the owner + * LINES Number of times a line was executed + * FILE Pathname of the Ruby 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"); +} + +ruby*:::line +{ + @lines[pid, uid, copyinstr(arg0)] = count(); +} + +dtrace:::END +{ + printf(" %6s %6s %10s %s\n", "PID", "UID", "LINES", "FILE"); + printa(" %6d %6d %@10d %s\n", @lines); +} |