3 * rb_syscalls.d - count Ruby calls and syscalls using DTrace.
4 * Written for the Ruby DTrace provider.
6 * $Id: rb_syscalls.d 20 2007-09-12 09:28:22Z brendan $
8 * USAGE: rb_syscalls.d { -p PID | -c cmd } # hit Ctrl-C to end
11 * FILE Filename of the Ruby program
12 * TYPE Type of call (method/syscall)
14 * COUNT Number of calls during sample
16 * Filename and method names are printed if available.
17 * The filename for syscalls may be printed as "ruby", if the program
18 * was invoked using the form "ruby filename" rather than running the
19 * program with an interpreter line.
21 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
25 * The contents of this file are subject to the terms of the
26 * Common Development and Distribution License, Version 1.0 only
27 * (the "License"). You may not use this file except in compliance
30 * You can obtain a copy of the license at Docs/cddl1.txt
31 * or http://www.opensolaris.org/os/licensing.
32 * See the License for the specific language governing permissions
33 * and limitations under the License.
37 * 09-Sep-2007 Brendan Gregg Created this.
40 #pragma D option quiet
46 printf("Tracing... Hit Ctrl-C to end.\n");
49 ruby$target:::function-entry
51 this->name = strjoin(strjoin(copyinstr(arg0), "::"), copyinstr(arg1));
52 @calls[basename(copyinstr(arg2)), "method", this->name] = count();
58 @calls[basename(execname), "syscall", probefunc] = count();
63 printf("\nCalls for PID %d,\n\n", $target);
64 printf(" %-32s %-10s %-22s %8s\n", "FILE", "TYPE", "NAME", "COUNT");
65 printa(" %-32s %-10s %-22s %@8d\n", @calls);