]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Java/j_thread.d
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Java / j_thread.d
1 #!/usr/sbin/dtrace -Zs
2 /*
3  * j_thread.d - snoop Java thread execution using DTrace.
4                 Written for the Java hotspot DTrace provider.
5  *
6  * $Id: j_thread.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_thread.d            # hit Ctrl-C to end
12  *
13  * FIELDS:
14  *              TIME            Time string
15  *              PID             Process ID
16  *              TID             Thread ID
17  *              THREAD          Thread name
18  *
19  * LEGEND:
20  *              =>              thread start
21  *              <=              thread end
22  *
23  * COPYRIGHT: Copyright (c) 2007 Brendan Gregg.
24  *
25  * CDDL HEADER START
26  *
27  *  The contents of this file are subject to the terms of the
28  *  Common Development and Distribution License, Version 1.0 only
29  *  (the "License").  You may not use this file except in compliance
30  *  with the License.
31  *
32  *  You can obtain a copy of the license at Docs/cddl1.txt
33  *  or http://www.opensolaris.org/os/licensing.
34  *  See the License for the specific language governing permissions
35  *  and limitations under the License.
36  *
37  * CDDL HEADER END
38  *
39  * 09-Sep-2007  Brendan Gregg   Created this.
40  */
41
42 #pragma D option quiet
43 #pragma D option switchrate=10
44
45 dtrace:::BEGIN
46 {
47         printf("%-20s  %6s/%-5s -- %s\n", "TIME", "PID", "TID", "THREAD");
48 }
49
50 hotspot*:::thread-start
51 {
52         this->thread = (char *)copyin(arg0, arg1 + 1);
53         this->thread[arg1] = '\0';
54         printf("%-20Y  %6d/%-5d => %s\n", walltimestamp, pid, tid,
55             stringof(this->thread));
56 }
57
58 hotspot*:::thread-stop
59 {
60         this->thread = (char *)copyin(arg0, arg1 + 1);
61         this->thread[arg1] = '\0';
62         printf("%-20Y  %6d/%-5d <= %s\n", walltimestamp, pid, tid,
63             stringof(this->thread));
64 }