1235368Sgnn#!/usr/sbin/dtrace -ZCs 2235368Sgnn/* 3235368Sgnn * tcl_ins.d - count Tcl instructions using DTrace. 4235368Sgnn * Written for the Tcl DTrace provider. 5235368Sgnn * 6235368Sgnn * $Id: tcl_ins.d 64 2007-10-04 08:35:29Z claire $ 7235368Sgnn * 8235368Sgnn * This traces activity from all Tcl processes on the system with DTrace 9235368Sgnn * provider support (tcl8.4.16). 10235368Sgnn * 11235368Sgnn * USAGE: tcl_calls.d # hit Ctrl-C to end 12235368Sgnn * 13235368Sgnn * FIELDS: 14235368Sgnn * PID Process ID 15235368Sgnn * TYPE Type of call (see below) 16235368Sgnn * NAME Name of call 17235368Sgnn * COUNT Number of calls during sample 18235368Sgnn * 19235368Sgnn * TYPEs: 20235368Sgnn * inst instruction 21235368Sgnn * 22235368Sgnn * COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 23235368Sgnn * 24235368Sgnn * CDDL HEADER START 25235368Sgnn * 26235368Sgnn * The contents of this file are subject to the terms of the 27235368Sgnn * Common Development and Distribution License, Version 1.0 only 28235368Sgnn * (the "License"). You may not use this file except in compliance 29235368Sgnn * with the License. 30235368Sgnn * 31235368Sgnn * You can obtain a copy of the license at Docs/cddl1.txt 32235368Sgnn * or http://www.opensolaris.org/os/licensing. 33235368Sgnn * See the License for the specific language governing permissions 34235368Sgnn * and limitations under the License. 35235368Sgnn * 36235368Sgnn * CDDL HEADER END 37235368Sgnn * 38235368Sgnn * 09-Sep-2007 Brendan Gregg Created this. 39235368Sgnn */ 40235368Sgnn 41235368Sgnn#pragma D option quiet 42235368Sgnn 43235368Sgnndtrace:::BEGIN 44235368Sgnn{ 45235368Sgnn printf("Tracing... Hit Ctrl-C to end.\n"); 46235368Sgnn} 47235368Sgnn 48235368Sgnntcl*:::inst-start 49235368Sgnn{ 50235368Sgnn @calls[pid, "inst", copyinstr(arg0)] = count(); 51235368Sgnn} 52235368Sgnn 53235368Sgnndtrace:::END 54235368Sgnn{ 55235368Sgnn printf(" %6s %-8s %-52s %8s\n", "PID", "TYPE", "NAME", "COUNT"); 56235368Sgnn printa(" %6d %-8s %-52s %@8d\n", @calls); 57235368Sgnn} 58