]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Shell/sh_lines.d
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Shell / sh_lines.d
1 #!/usr/sbin/dtrace -Zs
2 /*
3  * sh_lines.d - trace Bourne shell line execution using DTrace.
4  *              Written for the sh DTrace provider.
5  *
6  * $Id: sh_lines.d 25 2007-09-12 09:51:58Z brendan $
7  *
8  * This traces shell activity from all Bourne shells on the system that are
9  * running with sh provider support.
10  *
11  * USAGE: sh_lines.d    # hit Ctrl-C to end
12  *
13  * FIELDS:
14  *              FILE            Filename of the shell or shellscript
15  *              LINE            Line number
16  *              COUNT           Number of times a line was executed
17  *
18  * Filenames are printed if available.
19  *
20  * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
21  *
22  * CDDL HEADER START
23  *
24  *  The contents of this file are subject to the terms of the
25  *  Common Development and Distribution License, Version 1.0 only
26  *  (the "License").  You may not use this file except in compliance
27  *  with the License.
28  *
29  *  You can obtain a copy of the license at Docs/cddl1.txt
30  *  or http://www.opensolaris.org/os/licensing.
31  *  See the License for the specific language governing permissions
32  *  and limitations under the License.
33  *
34  * CDDL HEADER END
35  *
36  * 09-Sep-2007  Brendan Gregg   Created this.
37  */
38
39 #pragma D option quiet
40
41 dtrace:::BEGIN
42 {
43         printf("Tracing... Hit Ctrl-C to end.\n");
44 }
45
46 sh*:::line
47 {
48         @calls[basename(copyinstr(arg0)), arg1] = count();
49 }
50
51 dtrace:::END
52 {
53         printf(" %32s:%-6s %10s\n", "FILE", "LINE", "COUNT");
54         printa(" %32s:%-6d %@10d\n", @calls);
55 }