1696Spaul#!/usr/sbin/dtrace -Zs 214260Spst/* 3696Spaul * j_methodcalls.d - count Java method calls DTrace. 4696Spaul * Written for the Java hotspot DTrace provider. 5696Spaul * 6696Spaul * $Id: j_methodcalls.d 19 2007-09-12 07:47:59Z brendan $ 7696Spaul * 8696Spaul * This traces activity from all Java processes on the system with hotspot 9696Spaul * provider support (1.6.0) and the flag "+ExtendedDTraceProbes". eg, 10696Spaul * java -XX:+ExtendedDTraceProbes classfile 11696Spaul * 12696Spaul * USAGE: j_methodcalls.d # hit Ctrl-C to end 13696Spaul * 14696Spaul * FIELDS: 15696Spaul * PID Process ID 16696Spaul * COUNT Number of calls during sample 171153Sjkh * CLASS.METHOD Java class and method name 18696Spaul * 19696Spaul * COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 20696Spaul * 21696Spaul * CDDL HEADER START 22696Spaul * 23696Spaul * The contents of this file are subject to the terms of the 24696Spaul * Common Development and Distribution License, Version 1.0 only 25696Spaul * (the "License"). You may not use this file except in compliance 26696Spaul * with the License. 27696Spaul * 28696Spaul * You can obtain a copy of the license at Docs/cddl1.txt 29696Spaul * or http://www.opensolaris.org/os/licensing. 3018597Speter * See the License for the specific language governing permissions 31696Spaul * and limitations under the License. 32696Spaul * 33696Spaul * CDDL HEADER END 34696Spaul * 35696Spaul * 09-Sep-2007 Brendan Gregg Created this. 36696Spaul */ 37696Spaul 38696Spaul#pragma D option quiet 39696Spaul 401741Srichdtrace:::BEGIN 411741Srich{ 4217142Sjkh printf("Tracing... Hit Ctrl-C to end.\n"); 4317142Sjkh} 44696Spaul 45696Spaulhotspot*:::method-entry 46696Spaul{ 47696Spaul this->class = (char *)copyin(arg1, arg2 + 1); 48696Spaul this->class[arg2] = '\0'; 491741Srich this->method = (char *)copyin(arg3, arg4 + 1); 501741Srich this->method[arg4] = '\0'; 51696Spaul this->name = strjoin(strjoin(stringof(this->class), "."), 521741Srich stringof(this->method)); 53696Spaul @calls[pid, this->name] = count(); 5418597Speter} 55696Spaul 5618597Speterdtrace:::END 5718597Speter{ 5818597Speter printf(" %6s %8s %s\n", "PID", "COUNT", "CLASS.METHOD"); 5918597Speter printa(" %6d %@8d %s\n", @calls); 6018597Speter} 61696Spaul