sh_lines.d revision 1
2N/A#!/usr/sbin/dtrace -Zs
2N/A/*
2N/A * sh_lines.d - trace Bourne shell line execution using DTrace.
2N/A * Written for the sh DTrace provider.
2N/A *
2N/A * $Id: sh_lines.d 25 2007-09-12 09:51:58Z brendan $
2N/A *
2N/A * This traces shell activity from all Bourne shells on the system that are
2N/A * running with sh provider support.
2N/A *
2N/A * USAGE: sh_lines.d # hit Ctrl-C to end
2N/A *
2N/A * FIELDS:
2N/A * FILE Filename of the shell or shellscript
2N/A * LINE Line number
2N/A * COUNT Number of times a line was executed
2N/A *
2N/A * Filenames are printed if available.
2N/A *
2N/A * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
2N/A *
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at Docs/cddl1.txt
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * CDDL HEADER END
2N/A *
2N/A * 09-Sep-2007 Brendan Gregg Created this.
2N/A */
2N/A
2N/A#pragma D option quiet
2N/A
2N/Adtrace:::BEGIN
2N/A{
2N/A printf("Tracing... Hit Ctrl-C to end.\n");
2N/A}
2N/A
2N/Ash*:::line
2N/A{
2N/A @calls[basename(copyinstr(arg0)), arg1] = count();
2N/A}
2N/A
2N/Adtrace:::END
2N/A{
2N/A printf(" %32s:%-6s %10s\n", "FILE", "LINE", "COUNT");
2N/A printa(" %32s:%-6d %@10d\n", @calls);
2N/A}
2N/A