Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java @ 17587:561045d22599 jdk8u11-b07
Added tag jdk8u11-b06 for changeset b73ee2b9027c
author | katleman |
---|---|
date | Tue, 29 Apr 2014 12:51:45 -0700 |
parents | 55fb97c4c58d |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
0 | 1 /* |
17467
55fb97c4c58d
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
12932
diff
changeset
|
2 * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 package sun.jvm.hotspot.tools; | |
26 | |
27 import sun.jvm.hotspot.debugger.*; | |
28 import sun.jvm.hotspot.runtime.*; | |
29 import sun.jvm.hotspot.oops.*; | |
30 | |
31 /** Traverses and prints the stack traces for all Java threads in the | |
32 * remote VM */ | |
33 public class StackTrace extends Tool { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
34 // in non-verbose mode pc, sp and Method* are not printed |
0 | 35 public StackTrace(boolean v, boolean concurrentLocks) { |
36 this.verbose = v; | |
37 this.concurrentLocks = concurrentLocks; | |
38 } | |
39 | |
40 public StackTrace() { | |
41 this(true, true); | |
42 } | |
43 | |
44 public void run() { | |
45 run(System.out); | |
46 } | |
47 | |
11054
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
48 public StackTrace(JVMDebugger d) { |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
49 super(d); |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
50 } |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
51 |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
52 public StackTrace(JVMDebugger d, boolean v, boolean concurrentLocks) { |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
53 super(d); |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
54 this.verbose = v; |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
55 this.concurrentLocks = concurrentLocks; |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
56 } |
38ea2efa32a7
8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents:
6725
diff
changeset
|
57 |
0 | 58 public void run(java.io.PrintStream tty) { |
59 // Ready to go with the database... | |
60 try { | |
61 // print deadlock information before stack trace | |
62 DeadlockDetector.print(tty); | |
63 } catch (Exception exp) { | |
64 exp.printStackTrace(); | |
65 tty.println("Can't print deadlocks:" + exp.getMessage()); | |
66 } | |
67 | |
68 try { | |
69 ConcurrentLocksPrinter concLocksPrinter = null; | |
70 if (concurrentLocks) { | |
71 concLocksPrinter = new ConcurrentLocksPrinter(); | |
72 } | |
73 Threads threads = VM.getVM().getThreads(); | |
74 int i = 1; | |
75 for (JavaThread cur = threads.first(); cur != null; cur = cur.next(), i++) { | |
76 if (cur.isJavaThread()) { | |
77 Address sp = cur.getLastJavaSP(); | |
78 tty.print("Thread "); | |
79 cur.printThreadIDOn(tty); | |
80 tty.print(": (state = " + cur.getThreadState()); | |
81 if (verbose) { | |
82 tty.println(", current Java SP = " + sp); | |
83 } | |
84 tty.println(')'); | |
85 try { | |
86 for (JavaVFrame vf = cur.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) { | |
87 Method method = vf.getMethod(); | |
88 tty.print(" - " + method.externalNameAndSignature() + | |
89 " @bci=" + vf.getBCI()); | |
90 | |
91 int lineNumber = method.getLineNumberFromBCI(vf.getBCI()); | |
92 if (lineNumber != -1) { | |
93 tty.print(", line=" + lineNumber); | |
94 } | |
95 | |
96 if (verbose) { | |
97 Address pc = vf.getFrame().getPC(); | |
98 if (pc != null) { | |
99 tty.print(", pc=" + pc); | |
100 } | |
101 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1552
diff
changeset
|
102 tty.print(", Method*=" + method.getAddress()); |
0 | 103 } |
104 | |
105 if (vf.isCompiledFrame()) { | |
106 tty.print(" (Compiled frame"); | |
107 if (vf.isDeoptimized()) { | |
108 tty.print(" [deoptimized]"); | |
109 } | |
110 } | |
111 if (vf.isInterpretedFrame()) { | |
112 tty.print(" (Interpreted frame"); | |
113 } | |
114 if (vf.mayBeImpreciseDbg()) { | |
115 tty.print("; information may be imprecise"); | |
116 } | |
117 | |
118 tty.println(")"); | |
119 } | |
120 } catch (Exception e) { | |
121 tty.println("Error occurred during stack walking:"); | |
122 e.printStackTrace(); | |
123 } | |
124 tty.println(); | |
125 if (concurrentLocks) { | |
126 concLocksPrinter.print(cur, tty); | |
127 } | |
128 tty.println(); | |
129 } | |
130 } | |
131 } | |
132 catch (AddressException e) { | |
133 System.err.println("Error accessing address 0x" + Long.toHexString(e.getAddress())); | |
134 e.printStackTrace(); | |
135 } | |
136 } | |
137 | |
138 public static void main(String[] args) { | |
139 StackTrace st = new StackTrace(); | |
12932
7fe6ef09d242
8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents:
11054
diff
changeset
|
140 st.execute(args); |
0 | 141 } |
142 | |
143 private boolean verbose; | |
144 private boolean concurrentLocks; | |
145 } |