rb_who.d revision 235380
1178476Sjb#!/usr/sbin/dtrace -Zs
2178476Sjb/*
3178476Sjb * rb_who.d - trace Ruby line execution by process using DTrace.
4178476Sjb *            Written for the Ruby DTrace provider.
5178476Sjb *
6178476Sjb * $Id: rb_who.d 49 2007-09-17 12:03:20Z brendan $
7178476Sjb *
8178476Sjb * This traces Ruby activity from all Ruby programs on the system that are
9178476Sjb * running with Ruby provider support.
10178476Sjb *
11178476Sjb * USAGE: rb_who.d 		# hit Ctrl-C to end
12178476Sjb *
13178476Sjb * FIELDS:
14178476Sjb *		PID		Process ID of Ruby
15178476Sjb *		UID		User ID of the owner
16178476Sjb *		LINES		Number of times a line was executed
17178476Sjb *		FILE		Pathname of the Ruby program
18178476Sjb *
19178476Sjb * Filenames are printed if available.
20178476Sjb *
21178476Sjb * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
22178476Sjb *
23178476Sjb * CDDL HEADER START
24178476Sjb *
25178476Sjb *  The contents of this file are subject to the terms of the
26178476Sjb *  Common Development and Distribution License, Version 1.0 only
27178476Sjb *  (the "License").  You may not use this file except in compliance
28178476Sjb *  with the License.
29178476Sjb *
30178476Sjb *  You can obtain a copy of the license at Docs/cddl1.txt
31178476Sjb *  or http://www.opensolaris.org/os/licensing.
32178476Sjb *  See the License for the specific language governing permissions
33178476Sjb *  and limitations under the License.
34178476Sjb *
35178476Sjb * CDDL HEADER END
36178476Sjb *
37178476Sjb * 09-Sep-2007	Brendan Gregg	Created this.
38178476Sjb */
39178476Sjb
40178476Sjb#pragma D option quiet
41178476Sjb
42178476Sjbdtrace:::BEGIN
43178476Sjb{
44178476Sjb	printf("Tracing... Hit Ctrl-C to end.\n");
45178476Sjb}
46178476Sjb
47178476Sjbruby*:::line
48178476Sjb{
49	@lines[pid, uid, copyinstr(arg0)] = count();
50}
51
52dtrace:::END
53{
54	printf("   %6s %6s %10s %s\n", "PID", "UID", "LINES", "FILE");
55	printa("   %6d %6d %@10d %s\n", @lines);
56}
57