Mercurial > hg > graal-compiler
annotate agent/src/share/classes/sun/jvm/hotspot/tools/StackTrace.java @ 2426:1d1603768966
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
Summary: Update the copyright to be 2010 on all changed files in OpenJDK
Reviewed-by: ohair
author | trims |
---|---|
date | Tue, 05 Apr 2011 14:12:31 -0700 |
parents | c18cbe5936b8 |
children | da91efe96a93 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2002, 2006, 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 { | |
34 // in non-verbose mode pc, sp and methodOop are not printed | |
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 | |
48 public void run(java.io.PrintStream tty) { | |
49 // Ready to go with the database... | |
50 try { | |
51 // print deadlock information before stack trace | |
52 DeadlockDetector.print(tty); | |
53 } catch (Exception exp) { | |
54 exp.printStackTrace(); | |
55 tty.println("Can't print deadlocks:" + exp.getMessage()); | |
56 } | |
57 | |
58 try { | |
59 ConcurrentLocksPrinter concLocksPrinter = null; | |
60 if (concurrentLocks) { | |
61 concLocksPrinter = new ConcurrentLocksPrinter(); | |
62 } | |
63 Threads threads = VM.getVM().getThreads(); | |
64 int i = 1; | |
65 for (JavaThread cur = threads.first(); cur != null; cur = cur.next(), i++) { | |
66 if (cur.isJavaThread()) { | |
67 Address sp = cur.getLastJavaSP(); | |
68 tty.print("Thread "); | |
69 cur.printThreadIDOn(tty); | |
70 tty.print(": (state = " + cur.getThreadState()); | |
71 if (verbose) { | |
72 tty.println(", current Java SP = " + sp); | |
73 } | |
74 tty.println(')'); | |
75 try { | |
76 for (JavaVFrame vf = cur.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) { | |
77 Method method = vf.getMethod(); | |
78 tty.print(" - " + method.externalNameAndSignature() + | |
79 " @bci=" + vf.getBCI()); | |
80 | |
81 int lineNumber = method.getLineNumberFromBCI(vf.getBCI()); | |
82 if (lineNumber != -1) { | |
83 tty.print(", line=" + lineNumber); | |
84 } | |
85 | |
86 if (verbose) { | |
87 Address pc = vf.getFrame().getPC(); | |
88 if (pc != null) { | |
89 tty.print(", pc=" + pc); | |
90 } | |
91 | |
92 tty.print(", methodOop=" + method.getHandle()); | |
93 } | |
94 | |
95 if (vf.isCompiledFrame()) { | |
96 tty.print(" (Compiled frame"); | |
97 if (vf.isDeoptimized()) { | |
98 tty.print(" [deoptimized]"); | |
99 } | |
100 } | |
101 if (vf.isInterpretedFrame()) { | |
102 tty.print(" (Interpreted frame"); | |
103 } | |
104 if (vf.mayBeImpreciseDbg()) { | |
105 tty.print("; information may be imprecise"); | |
106 } | |
107 | |
108 tty.println(")"); | |
109 } | |
110 } catch (Exception e) { | |
111 tty.println("Error occurred during stack walking:"); | |
112 e.printStackTrace(); | |
113 } | |
114 tty.println(); | |
115 if (concurrentLocks) { | |
116 concLocksPrinter.print(cur, tty); | |
117 } | |
118 tty.println(); | |
119 } | |
120 } | |
121 } | |
122 catch (AddressException e) { | |
123 System.err.println("Error accessing address 0x" + Long.toHexString(e.getAddress())); | |
124 e.printStackTrace(); | |
125 } | |
126 } | |
127 | |
128 public static void main(String[] args) { | |
129 StackTrace st = new StackTrace(); | |
130 st.start(args); | |
131 st.stop(); | |
132 } | |
133 | |
134 private boolean verbose; | |
135 private boolean concurrentLocks; | |
136 } |