1235368Sgnn#!/usr/sbin/dtrace -Zs 2235368Sgnn/* 3235368Sgnn * rb_funccalls.d - count Ruby function (method) calls using DTrace. 4235368Sgnn * Written for the Ruby DTrace provider. 5235368Sgnn * 6235368Sgnn * $Id: rb_funccalls.d 20 2007-09-12 09:28:22Z brendan $ 7235368Sgnn * 8235368Sgnn * This traces activity from all Ruby programs on the system that are 9235368Sgnn * running with Ruby provider support. 10235368Sgnn * 11235368Sgnn * USAGE: rb_funccalls.d # hit Ctrl-C to end 12235368Sgnn * 13235368Sgnn * FIELDS: 14235368Sgnn * FILE Filename of the Ruby program 15235368Sgnn * METHOD Method name 16235368Sgnn * COUNT Number of calls during sample 17235368Sgnn * 18235368Sgnn * Filename and method names are printed if available. 19235368Sgnn * 20235368Sgnn * COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 21235368Sgnn * 22235368Sgnn * CDDL HEADER START 23235368Sgnn * 24235368Sgnn * The contents of this file are subject to the terms of the 25235368Sgnn * Common Development and Distribution License, Version 1.0 only 26235368Sgnn * (the "License"). You may not use this file except in compliance 27235368Sgnn * with the License. 28235368Sgnn * 29235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 30235368Sgnn * or http://www.opensolaris.org/os/licensing. 31235368Sgnn * See the License for the specific language governing permissions 32235368Sgnn * and limitations under the License. 33235368Sgnn * 34235368Sgnn * CDDL HEADER END 35235368Sgnn * 36235368Sgnn * 09-Sep-2007 Brendan Gregg Created this. 37235368Sgnn */ 38235368Sgnn 39235368Sgnn#pragma D option quiet 40235368Sgnn 41235368Sgnndtrace:::BEGIN 42235368Sgnn{ 43235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 44235368Sgnn} 45235368Sgnn 46235368Sgnnruby*:::function-entry 47235368Sgnn{ 48235368Sgnn @funcs[basename(copyinstr(arg2)), copyinstr(arg0), copyinstr(arg1)] = 49235368Sgnn count(); 50235368Sgnn} 51235368Sgnn 52235368Sgnndtrace:::END 53235368Sgnn{ 54235368Sgnn printf(" %-32.32s %-16s %-16s %8s\n", "FILE", "CLASS", "METHOD", 55235368Sgnn "CALLS"); 56235368Sgnn printa(" %-32.32s %-16s %-16s %@8d\n", @funcs); 57235368Sgnn} 58