rb_objnew.d revision 235368
1219820Sjeff#!/usr/sbin/dtrace -Zs 2219820Sjeff/* 3219820Sjeff * rb_objnew.d - count Ruby object creation using DTrace. 4219820Sjeff * Written for the Ruby DTrace provider. 5219820Sjeff * 6219820Sjeff * $Id: rb_objnew.d 20 2007-09-12 09:28:22Z brendan $ 7219820Sjeff * 8219820Sjeff * This traces Ruby activity from all programs running on the system with 9219820Sjeff * Ruby provider support. 10219820Sjeff * 11219820Sjeff * USAGE: rb_objnew.d # hit Ctrl-C to end 12219820Sjeff * 13219820Sjeff * FIELDS: 14219820Sjeff * FILE Filename of the Ruby program 15219820Sjeff * CLASS Class of new object 16219820Sjeff * COUNT Number of object creations during tracing 17219820Sjeff * 18219820Sjeff * Filename and class names are printed if available. 19219820Sjeff * 20219820Sjeff * COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 21219820Sjeff * 22219820Sjeff * CDDL HEADER START 23219820Sjeff * 24219820Sjeff * The contents of this file are subject to the terms of the 25219820Sjeff * Common Development and Distribution License, Version 1.0 only 26219820Sjeff * (the "License"). You may not use this file except in compliance 27219820Sjeff * with the License. 28219820Sjeff * 29219820Sjeff * You can obtain a copy of the license at Docs/cddl1.txt 30219820Sjeff * or http://www.opensolaris.org/os/licensing. 31219820Sjeff * See the License for the specific language governing permissions 32219820Sjeff * and limitations under the License. 33219820Sjeff * 34219820Sjeff * CDDL HEADER END 35219820Sjeff * 36219820Sjeff * 09-Sep-2007 Brendan Gregg Created this. 37219820Sjeff */ 38219820Sjeff 39219820Sjeff#pragma D option quiet 40219820Sjeff 41219820Sjeffdtrace:::BEGIN 42219820Sjeff{ 43219820Sjeff printf("Tracing... Hit Ctrl-C to end.\n"); 44219820Sjeff} 45219820Sjeff 46219820Sjeffruby*:::object-create-done 47219820Sjeff{ 48219820Sjeff @objs[basename(copyinstr(arg1)), copyinstr(arg0)] = count(); 49219820Sjeff} 50219820Sjeff 51219820Sjeffdtrace:::END 52219820Sjeff{ 53219820Sjeff printf(" %-24s %-36s %8s\n", "FILE", "CLASS", "COUNT"); 54219820Sjeff printa(" %-24.24s %-36s %@8d\n", @objs); 55219820Sjeff} 56219820Sjeff