rb_funccalls.d revision 235380
1178476Sjb#!/usr/sbin/dtrace -Zs 2178476Sjb/* 3178476Sjb * rb_funccalls.d - count Ruby function (method) calls using DTrace. 4178476Sjb * Written for the Ruby DTrace provider. 5178476Sjb * 6178476Sjb * $Id: rb_funccalls.d 20 2007-09-12 09:28:22Z brendan $ 7178476Sjb * 8178476Sjb * This traces activity from all Ruby programs on the system that are 9178476Sjb * running with Ruby provider support. 10178476Sjb * 11178476Sjb * USAGE: rb_funccalls.d # hit Ctrl-C to end 12178476Sjb * 13178476Sjb * FIELDS: 14178476Sjb * FILE Filename of the Ruby program 15178476Sjb * METHOD Method name 16178476Sjb * COUNT Number of calls during sample 17178476Sjb * 18178476Sjb * Filename and method names are printed if available. 19178476Sjb * 20178476Sjb * COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 21178476Sjb * 22178476Sjb * CDDL HEADER START 23178476Sjb * 24178476Sjb * The contents of this file are subject to the terms of the 25178476Sjb * Common Development and Distribution License, Version 1.0 only 26178476Sjb * (the "License"). You may not use this file except in compliance 27178476Sjb * with the License. 28178476Sjb * 29178476Sjb * You can obtain a copy of the license at Docs/cddl1.txt 30178476Sjb * or http://www.opensolaris.org/os/licensing. 31178476Sjb * See the License for the specific language governing permissions 32178476Sjb * and limitations under the License. 33178476Sjb * 34178476Sjb * CDDL HEADER END 35178476Sjb * 36178476Sjb * 09-Sep-2007 Brendan Gregg Created this. 37178476Sjb */ 38178476Sjb 39178476Sjb#pragma D option quiet 40178476Sjb 41178476Sjbdtrace:::BEGIN 42{ 43 printf("Tracing... Hit Ctrl-C to end.\n"); 44} 45 46ruby*:::function-entry 47{ 48 @funcs[basename(copyinstr(arg2)), copyinstr(arg0), copyinstr(arg1)] = 49 count(); 50} 51 52dtrace:::END 53{ 54 printf(" %-32.32s %-16s %-16s %8s\n", "FILE", "CLASS", "METHOD", 55 "CALLS"); 56 printa(" %-32.32s %-16s %-16s %@8d\n", @funcs); 57} 58