1#!/usr/sbin/dtrace -Zs 2/* 3 * tcl_syscalls.d - count Tcl calls and syscalls using DTrace. 4 * Written for the Tcl DTrace provider. 5 * 6 * $Id: tcl_syscalls.d 63 2007-10-04 04:34:38Z brendan $ 7 * 8 * This traces activity from all Tcl processes on the system with DTrace 9 * provider support (tcl8.4.16). 10 * 11 * USAGE: tcl_syscalls.d { -p PID | -c cmd } # hit Ctrl-C to end 12 * 13 * FIELDS: 14 * PID Process ID 15 * TYPE Type of call (method/syscall) 16 * NAME Name of call 17 * COUNT Number of calls during sample 18 * 19 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 20 * 21 * CDDL HEADER START 22 * 23 * The contents of this file are subject to the terms of the 24 * Common Development and Distribution License, Version 1.0 only 25 * (the "License"). You may not use this file except in compliance 26 * with the License. 27 * 28 * You can obtain a copy of the license at Docs/cddl1.txt 29 * or http://www.opensolaris.org/os/licensing. 30 * See the License for the specific language governing permissions 31 * and limitations under the License. 32 * 33 * CDDL HEADER END 34 * 35 * 09-Sep-2007 Brendan Gregg Created this. 36 */ 37 38#pragma D option quiet 39 40dtrace:::BEGIN 41{ 42 printf("Tracing... Hit Ctrl-C to end.\n"); 43} 44 45tcl$target:::proc-entry 46{ 47 @calls[pid, "proc", copyinstr(arg0)] = count(); 48} 49 50tcl$target:::cmd-entry 51{ 52 @calls[pid, "cmd", copyinstr(arg0)] = count(); 53} 54 55syscall:::entry 56/pid == $target/ 57{ 58 @calls[pid, "syscall", probefunc] = count(); 59} 60 61 62dtrace:::END 63{ 64 printf(" %6s %-8s %-52s %8s\n", "PID", "TYPE", "NAME", "COUNT"); 65 printa(" %6d %-8s %-52s %@8d\n", @calls); 66} 67