1#!/usr/sbin/dtrace -Zs 2/* 3 * j_package.d - count Java class loads by package using DTrace. 4 * Written for the Java hotspot DTrace provider. 5 * 6 * $Id: j_package.d 19 2007-09-12 07:47:59Z brendan $ 7 * 8 * This traces activity from all Java processes on the system with hotspot 9 * provider support (1.6.0). 10 * 11 * USAGE: j_package.d # hit Ctrl-C to end 12 * 13 * FIELDS: 14 * PID Process ID 15 * LOADS Class loads during trace 16 * PACKAGE Package name from class 17 * 18 * COPYRIGHT: Copyright (c) 2007 Brendan Gregg. 19 * 20 * CDDL HEADER START 21 * 22 * The contents of this file are subject to the terms of the 23 * Common Development and Distribution License, Version 1.0 only 24 * (the "License"). You may not use this file except in compliance 25 * with the License. 26 * 27 * You can obtain a copy of the license at Docs/cddl1.txt 28 * or http://www.opensolaris.org/os/licensing. 29 * See the License for the specific language governing permissions 30 * and limitations under the License. 31 * 32 * CDDL HEADER END 33 * 34 * 09-Sep-2007 Brendan Gregg Created this. 35 */ 36 37#pragma D option quiet 38 39dtrace:::BEGIN 40{ 41 printf("Tracing... Hit Ctrl-C to end.\n"); 42} 43 44hotspot*:::class-loaded 45{ 46 this->class = (char *)copyin(arg0, arg1 + 1); 47 this->class[arg1] = '\0'; 48 49 @loads[pid, dirname(stringof(this->class))] = count(); 50} 51 52dtrace:::END 53{ 54 printf(" %6s %8s %s\n", "PID", "LOADS", "PACKAGE"); 55 printa(" %6d %@8d %s\n", @loads); 56} 57