3 * sh_calls.d - count Bourne calls (func/builtin/cmd/subsh) using DTrace.
4 * Written for the sh DTrace provider.
6 * $Id: sh_calls.d 52 2007-09-24 04:28:01Z brendan $
8 * This traces shell activity from all Bourne shells on the system that are
9 * running with sh provider support.
11 * USAGE: sh_calls.d # hit Ctrl-C to end
14 * FILE Filename of the shell or shellscript
15 * TYPE Type of call (func/builtin/cmd/subsh)
17 * COUNT Number of calls during sample
19 * Filename and function names are printed if available.
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
44 printf("Tracing... Hit Ctrl-C to end.\n");
49 @calls[basename(copyinstr(arg0)), "func", copyinstr(arg1)] = count();
54 @calls[basename(copyinstr(arg0)), "builtin", copyinstr(arg1)] = count();
59 @calls[basename(copyinstr(arg0)), "cmd", copyinstr(arg1)] = count();
65 @calls[basename(copyinstr(arg0)), "subsh", "-"] = count();
70 printf(" %-22s %-10s %-32s %8s\n", "FILE", "TYPE", "NAME", "COUNT");
71 printa(" %-22s %-10s %-32s %@8d\n", @calls);