]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Java/j_objnew.d
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Java / j_objnew.d
1 #!/usr/sbin/dtrace -Zs
2 /*
3  * j_objnew.d - report Java object allocation using DTrace.
4  *              Written for the Java hotspot DTrace provider.
5  *
6  * $Id: j_objnew.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) and the flag "+ExtendedDTraceProbes". eg,
10  * java -XX:+ExtendedDTraceProbes classfile
11  *
12  * USAGE: j_objnew.d            # hit Ctrl-C to end
13  *
14  * FIELDS:
15  *              PID             Process ID
16  *              OBJS            Number of objects created
17  *              CLASS.METHOD    Java class and method name
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
40 dtrace:::BEGIN
41 {
42         printf("Tracing... Hit Ctrl-C to end.\n");
43 }
44
45 hotspot*:::object-alloc
46 {
47         this->class = (char *)copyin(arg1, arg2 + 1);
48         this->class[arg2] = '\0';
49         @objs[pid, stringof(this->class)] = count();
50         @dist[pid, stringof(this->class)] = quantize(arg3);
51 }
52
53 dtrace:::END
54 {
55         printf("Java object allocation byte distributions by pid and class,\n");
56         printa(@dist);
57
58         printf("Java object allocation count by pid and class,\n\n");
59         printf(" %6s %8s %s\n", "PID", "OBJS", "CLASS");
60         printa(" %6d %8@d %s\n", @objs);
61 }