3 * rb_flowinfo.d - snoop Ruby function (method) flow with info using DTrace.
4 * Written for the Ruby DTrace provider.
6 * $Id: rb_flowinfo.d 41 2007-09-17 02:20:10Z brendan $
8 * This traces activity from all Ruby programs on the system that are
9 * running with Ruby provider support.
11 * USAGE: rb_flowinfo.d # hit Ctrl-C to end
16 * DELTA(us) Elapsed time from previous line to this line
17 * FILE Filename of the Ruby program
18 * LINE Line number of filename
19 * TYPE Type of call (method)
20 * NAME Ruby class and method name
26 * Filename and method names are printed if available.
28 * WARNING: Watch the first column carefully, it prints the CPU-id. If it
29 * changes, then it is very likely that the output has been shuffled.
31 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
35 * The contents of this file are subject to the terms of the
36 * Common Development and Distribution License, Version 1.0 only
37 * (the "License"). You may not use this file except in compliance
40 * You can obtain a copy of the license at Docs/cddl1.txt
41 * or http://www.opensolaris.org/os/licensing.
42 * See the License for the specific language governing permissions
43 * and limitations under the License.
47 * 09-Sep-2007 Brendan Gregg Created this.
50 #pragma D option quiet
51 #pragma D option switchrate=10
57 printf("%s %6s %10s %16s:%-4s %-8s -- %s\n", "C", "PID", "DELTA(us)",
58 "FILE", "LINE", "TYPE", "NAME");
61 ruby*:::function-entry,
62 ruby*:::function-return
65 self->last = timestamp;
68 ruby*:::function-entry
70 this->delta = (timestamp - self->last) / 1000;
71 this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1));
72 printf("%d %6d %10d %16s:%-4d %-8s %*s-> %s\n", cpu, pid, this->delta,
73 basename(copyinstr(arg2)), arg3, "method", self->depth * 2, "",
76 self->last = timestamp;
79 ruby*:::function-return
81 this->delta = (timestamp - self->last) / 1000;
82 self->depth -= self->depth > 0 ? 1 : 0;
83 this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1));
84 printf("%d %6d %10d %16s:%-4d %-8s %*s<- %s\n", cpu, pid, this->delta,
85 basename(copyinstr(arg2)), arg3, "method", self->depth * 2, "",
87 self->last = timestamp;