3 * rb_flow.d - snoop Ruby execution showing method flow using DTrace.
4 * Written for the Ruby DTrace provider.
6 * $Id: rb_flow.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_flow.d # hit Ctrl-C to end
15 * TIME(us) Time since boot, us
16 * FILE Filename that this method belongs to
17 * CLASS::METHOD Ruby classname and method
23 * Filename and method names are printed if available.
25 * WARNING: Watch the first column carefully, it prints the CPU-id. If it
26 * changes, then it is very likely that the output has been shuffled.
28 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
32 * The contents of this file are subject to the terms of the
33 * Common Development and Distribution License, Version 1.0 only
34 * (the "License"). You may not use this file except in compliance
37 * You can obtain a copy of the license at Docs/cddl1.txt
38 * or http://www.opensolaris.org/os/licensing.
39 * See the License for the specific language governing permissions
40 * and limitations under the License.
44 * 09-Sep-2007 Brendan Gregg Created this.
47 #pragma D option quiet
48 #pragma D option switchrate=10
54 printf("%3s %-16s %-22s -- %s\n", "C", "TIME(us)", "FILE",
58 ruby*:::function-entry
60 printf("%3d %-16d %-22s %*s-> %s::%s\n", cpu, timestamp / 1000,
61 basename(copyinstr(arg2)), self->depth * 2, "", copyinstr(arg0),
66 ruby*:::function-return
68 self->depth -= self->depth > 0 ? 1 : 0;
69 printf("%3d %-16d %-22s %*s<- %s::%s\n", cpu, timestamp / 1000,
70 basename(copyinstr(arg2)), self->depth * 2, "", copyinstr(arg0),