annotate agent/src/share/classes/sun/jvm/hotspot/tools/PStack.java @ 12932:7fe6ef09d242

8025638: jmap returns 0 instead of 1 when it fails. Summary: Re-factored some code handling return values and fails/errors during tool execution. Reviewed-by: sla, kevinw Contributed-by: fredrik.arvidsson@oracle.com
author farvidsson
date Wed, 16 Oct 2013 09:20:23 +0200
parents 38ea2efa32a7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8103
diff changeset
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 218
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 218
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: 218
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 package sun.jvm.hotspot.tools;
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27 import java.io.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
28 import java.util.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
29 import sun.jvm.hotspot.code.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
30 import sun.jvm.hotspot.interpreter.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
31 import sun.jvm.hotspot.debugger.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
32 import sun.jvm.hotspot.debugger.cdbg.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 import sun.jvm.hotspot.oops.*;
a61af66fc99e Initial load
duke
parents:
diff changeset
34 import sun.jvm.hotspot.runtime.*;
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8103
diff changeset
35 import sun.jvm.hotspot.utilities.PlatformInfo;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
36
a61af66fc99e Initial load
duke
parents:
diff changeset
37 public class PStack extends Tool {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6163
diff changeset
38 // in non-verbose mode, Method*s are not printed in java frames
0
a61af66fc99e Initial load
duke
parents:
diff changeset
39 public PStack(boolean v, boolean concurrentLocks) {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 this.verbose = v;
a61af66fc99e Initial load
duke
parents:
diff changeset
41 this.concurrentLocks = concurrentLocks;
a61af66fc99e Initial load
duke
parents:
diff changeset
42 }
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 public PStack() {
a61af66fc99e Initial load
duke
parents:
diff changeset
45 this(true, true);
a61af66fc99e Initial load
duke
parents:
diff changeset
46 }
a61af66fc99e Initial load
duke
parents:
diff changeset
47
11054
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8750
diff changeset
48 public PStack(JVMDebugger d) {
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8750
diff changeset
49 super(d);
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8750
diff changeset
50 }
38ea2efa32a7 8010278: SA: provide mechanism for using an alternative SA debugger back-end.
kevinw
parents: 8750
diff changeset
51
0
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public void run() {
a61af66fc99e Initial load
duke
parents:
diff changeset
53 run(System.out);
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 public void run(PrintStream out) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 Debugger dbg = getAgent().getDebugger();
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
58 run(out, dbg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
59 }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 public void run(PrintStream out, Debugger dbg) {
8750
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8103
diff changeset
62 if (PlatformInfo.getOS().equals("darwin")) {
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8103
diff changeset
63 out.println("Not available on Darwin");
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8103
diff changeset
64 return;
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8103
diff changeset
65 }
39432a1cefdd 8003348: SA can not read core file on OS
minqi
parents: 8103
diff changeset
66
0
a61af66fc99e Initial load
duke
parents:
diff changeset
67 CDebugger cdbg = dbg.getCDebugger();
a61af66fc99e Initial load
duke
parents:
diff changeset
68 if (cdbg != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
69 ConcurrentLocksPrinter concLocksPrinter = null;
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
70 // compute and cache java Vframes.
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
71 initJFrameCache();
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
72 if (concurrentLocks) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
73 concLocksPrinter = new ConcurrentLocksPrinter();
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
74 }
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
75 // print Java level deadlocks
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
76 try {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
77 DeadlockDetector.print(out);
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
78 } catch (Exception exp) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
79 out.println("can't print deadlock information: " + exp.getMessage());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
80 }
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82 List l = cdbg.getThreadList();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 final boolean cdbgCanDemangle = cdbg.canDemangle();
a61af66fc99e Initial load
duke
parents:
diff changeset
84 for (Iterator itr = l.iterator() ; itr.hasNext();) {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 ThreadProxy th = (ThreadProxy) itr.next();
a61af66fc99e Initial load
duke
parents:
diff changeset
86 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 CFrame f = cdbg.topFrameForThread(th);
a61af66fc99e Initial load
duke
parents:
diff changeset
88 out.print("----------------- ");
a61af66fc99e Initial load
duke
parents:
diff changeset
89 out.print(th);
a61af66fc99e Initial load
duke
parents:
diff changeset
90 out.println(" -----------------");
a61af66fc99e Initial load
duke
parents:
diff changeset
91 while (f != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
92 ClosestSymbol sym = f.closestSymbolToPC();
a61af66fc99e Initial load
duke
parents:
diff changeset
93 Address pc = f.pc();
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
94 out.print(pc + "\t");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (sym != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 String name = sym.getName();
a61af66fc99e Initial load
duke
parents:
diff changeset
97 if (cdbgCanDemangle) {
a61af66fc99e Initial load
duke
parents:
diff changeset
98 name = cdbg.demangle(name);
a61af66fc99e Initial load
duke
parents:
diff changeset
99 }
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
100 out.print(name);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
101 long diff = sym.getOffset();
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if (diff != 0L) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 out.print(" + 0x" + Long.toHexString(diff));
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 out.println();
a61af66fc99e Initial load
duke
parents:
diff changeset
106 } else {
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
107 // look for one or more java frames
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
108 String[] names = null;
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
109 // check interpreter frame
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
110 Interpreter interp = VM.getVM().getInterpreter();
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
111 if (interp.contains(pc)) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
112 names = getJavaNames(th, f.localVariableBase());
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
113 // print codelet name if we can't determine method
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
114 if (names == null || names.length == 0) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
115 out.print("<interpreter> ");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
116 InterpreterCodelet ic = interp.getCodeletContaining(pc);
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
117 if (ic != null) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
118 String desc = ic.getDescription();
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
119 if (desc != null) out.print(desc);
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
120 }
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
121 out.println();
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
122 }
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
123 } else {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
124 // look for known code blobs
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
125 CodeCache c = VM.getVM().getCodeCache();
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
126 if (c.contains(pc)) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
127 CodeBlob cb = c.findBlobUnsafe(pc);
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
128 if (cb.isNMethod()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
129 names = getJavaNames(th, f.localVariableBase());
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
130 // just print compiled code, if can't determine method
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
131 if (names == null || names.length == 0) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
132 out.println("<Unknown compiled code>");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
133 }
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
134 } else if (cb.isBufferBlob()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
135 out.println("<StubRoutines>");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
136 } else if (cb.isRuntimeStub()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
137 out.println("<RuntimeStub>");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
138 } else if (cb.isDeoptimizationStub()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
139 out.println("<DeoptimizationStub>");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
140 } else if (cb.isUncommonTrapStub()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
141 out.println("<UncommonTrap>");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
142 } else if (cb.isExceptionStub()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
143 out.println("<ExceptionStub>");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
144 } else if (cb.isSafepointStub()) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
145 out.println("<SafepointStub>");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
146 } else {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
147 out.println("<Unknown code blob>");
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
148 }
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
149 } else {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
150 printUnknown(out);
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
151 }
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
152 }
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
153 // print java frames, if any
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
154 if (names != null && names.length != 0) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
155 // print java frame(s)
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
156 for (int i = 0; i < names.length; i++) {
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
157 out.println(names[i]);
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
158 }
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
159 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
160 }
6163
b87e5a681416 6310967: SA: jstack -m produce failures in output
poonam
parents: 1552
diff changeset
161 f = f.sender(th);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
162 }
a61af66fc99e Initial load
duke
parents:
diff changeset
163 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
164 exp.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
165 // continue, may be we can do a better job for other threads
a61af66fc99e Initial load
duke
parents:
diff changeset
166 }
8103
5ed317b25e23 7165259: Remove BugSpot
sla
parents: 6725
diff changeset
167 if (concurrentLocks) {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
168 JavaThread jthread = (JavaThread) proxyToThread.get(th);
a61af66fc99e Initial load
duke
parents:
diff changeset
169 if (jthread != null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
170 concLocksPrinter.print(jthread, out);
a61af66fc99e Initial load
duke
parents:
diff changeset
171 }
a61af66fc99e Initial load
duke
parents:
diff changeset
172 }
a61af66fc99e Initial load
duke
parents:
diff changeset
173 } // for threads
a61af66fc99e Initial load
duke
parents:
diff changeset
174 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 if (getDebugeeType() == DEBUGEE_REMOTE) {
a61af66fc99e Initial load
duke
parents:
diff changeset
176 out.println("remote configuration is not yet implemented");
a61af66fc99e Initial load
duke
parents:
diff changeset
177 } else {
a61af66fc99e Initial load
duke
parents:
diff changeset
178 out.println("not yet implemented (debugger does not support CDebugger)!");
a61af66fc99e Initial load
duke
parents:
diff changeset
179 }
a61af66fc99e Initial load
duke
parents:
diff changeset
180 }
a61af66fc99e Initial load
duke
parents:
diff changeset
181 }
a61af66fc99e Initial load
duke
parents:
diff changeset
182
a61af66fc99e Initial load
duke
parents:
diff changeset
183 public static void main(String[] args) throws Exception {
a61af66fc99e Initial load
duke
parents:
diff changeset
184 PStack t = new PStack();
12932
7fe6ef09d242 8025638: jmap returns 0 instead of 1 when it fails.
farvidsson
parents: 11054
diff changeset
185 t.execute(args);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
186 }
a61af66fc99e Initial load
duke
parents:
diff changeset
187
a61af66fc99e Initial load
duke
parents:
diff changeset
188 // -- Internals only below this point
a61af66fc99e Initial load
duke
parents:
diff changeset
189 private Map jframeCache; // Map<ThreadProxy, JavaVFrame[]>
a61af66fc99e Initial load
duke
parents:
diff changeset
190 private Map proxyToThread; // Map<ThreadProxy, JavaThread>
a61af66fc99e Initial load
duke
parents:
diff changeset
191 private PrintStream out;
a61af66fc99e Initial load
duke
parents:
diff changeset
192 private boolean verbose;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 private boolean concurrentLocks;
a61af66fc99e Initial load
duke
parents:
diff changeset
194
a61af66fc99e Initial load
duke
parents:
diff changeset
195 private void initJFrameCache() {
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // cache frames for subsequent reference
a61af66fc99e Initial load
duke
parents:
diff changeset
197 jframeCache = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
198 proxyToThread = new HashMap();
a61af66fc99e Initial load
duke
parents:
diff changeset
199 Threads threads = VM.getVM().getThreads();
a61af66fc99e Initial load
duke
parents:
diff changeset
200 for (JavaThread cur = threads.first(); cur != null; cur = cur.next()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 List tmp = new ArrayList(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
202 try {
a61af66fc99e Initial load
duke
parents:
diff changeset
203 for (JavaVFrame vf = cur.getLastJavaVFrameDbg(); vf != null; vf = vf.javaSender()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
204 tmp.add(vf);
a61af66fc99e Initial load
duke
parents:
diff changeset
205 }
a61af66fc99e Initial load
duke
parents:
diff changeset
206 } catch (Exception exp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
207 // may be we may get frames for other threads, continue
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // after printing stack trace.
a61af66fc99e Initial load
duke
parents:
diff changeset
209 exp.printStackTrace();
a61af66fc99e Initial load
duke
parents:
diff changeset
210 }
a61af66fc99e Initial load
duke
parents:
diff changeset
211 JavaVFrame[] jvframes = new JavaVFrame[tmp.size()];
a61af66fc99e Initial load
duke
parents:
diff changeset
212 System.arraycopy(tmp.toArray(), 0, jvframes, 0, jvframes.length);
a61af66fc99e Initial load
duke
parents:
diff changeset
213 jframeCache.put(cur.getThreadProxy(), jvframes);
a61af66fc99e Initial load
duke
parents:
diff changeset
214 proxyToThread.put(cur.getThreadProxy(), cur);
a61af66fc99e Initial load
duke
parents:
diff changeset
215 }
a61af66fc99e Initial load
duke
parents:
diff changeset
216 }
a61af66fc99e Initial load
duke
parents:
diff changeset
217
218
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
218 private void printUnknown(PrintStream out) {
a5838065ab24 6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents: 0
diff changeset
219 out.println("\t????????");
0
a61af66fc99e Initial load
duke
parents:
diff changeset
220 }
a61af66fc99e Initial load
duke
parents:
diff changeset
221
a61af66fc99e Initial load
duke
parents:
diff changeset
222 private String[] getJavaNames(ThreadProxy th, Address fp) {
a61af66fc99e Initial load
duke
parents:
diff changeset
223 if (fp == null) {
a61af66fc99e Initial load
duke
parents:
diff changeset
224 return null;
a61af66fc99e Initial load
duke
parents:
diff changeset
225 }
a61af66fc99e Initial load
duke
parents:
diff changeset
226 JavaVFrame[] jvframes = (JavaVFrame[]) jframeCache.get(th);
a61af66fc99e Initial load
duke
parents:
diff changeset
227 if (jvframes == null) return null; // not a java thread
a61af66fc99e Initial load
duke
parents:
diff changeset
228 List names = new ArrayList(10);
a61af66fc99e Initial load
duke
parents:
diff changeset
229 for (int fCount = 0; fCount < jvframes.length; fCount++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
230 JavaVFrame vf = jvframes[fCount];
a61af66fc99e Initial load
duke
parents:
diff changeset
231 Frame f = vf.getFrame();
a61af66fc99e Initial load
duke
parents:
diff changeset
232 if (fp.equals(f.getFP())) {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 StringBuffer sb = new StringBuffer();
a61af66fc99e Initial load
duke
parents:
diff changeset
234 Method method = vf.getMethod();
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // a special char to identify java frames in output
a61af66fc99e Initial load
duke
parents:
diff changeset
236 sb.append("* ");
a61af66fc99e Initial load
duke
parents:
diff changeset
237 sb.append(method.externalNameAndSignature());
a61af66fc99e Initial load
duke
parents:
diff changeset
238 sb.append(" bci:" + vf.getBCI());
a61af66fc99e Initial load
duke
parents:
diff changeset
239 int lineNumber = method.getLineNumberFromBCI(vf.getBCI());
a61af66fc99e Initial load
duke
parents:
diff changeset
240 if (lineNumber != -1) {
a61af66fc99e Initial load
duke
parents:
diff changeset
241 sb.append(" line:" + lineNumber);
a61af66fc99e Initial load
duke
parents:
diff changeset
242 }
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 if (verbose) {
6725
da91efe96a93 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 6163
diff changeset
245 sb.append(" Method*:" + method.getAddress());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
246 }
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 if (vf.isCompiledFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
249 sb.append(" (Compiled frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
250 if (vf.isDeoptimized()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
251 sb.append(" [deoptimized]");
a61af66fc99e Initial load
duke
parents:
diff changeset
252 }
a61af66fc99e Initial load
duke
parents:
diff changeset
253 } else if (vf.isInterpretedFrame()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
254 sb.append(" (Interpreted frame");
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256 if (vf.mayBeImpreciseDbg()) {
a61af66fc99e Initial load
duke
parents:
diff changeset
257 sb.append("; information may be imprecise");
a61af66fc99e Initial load
duke
parents:
diff changeset
258 }
a61af66fc99e Initial load
duke
parents:
diff changeset
259 sb.append(")");
a61af66fc99e Initial load
duke
parents:
diff changeset
260 names.add(sb.toString());
a61af66fc99e Initial load
duke
parents:
diff changeset
261 }
a61af66fc99e Initial load
duke
parents:
diff changeset
262 }
a61af66fc99e Initial load
duke
parents:
diff changeset
263 String[] res = new String[names.size()];
a61af66fc99e Initial load
duke
parents:
diff changeset
264 System.arraycopy(names.toArray(), 0, res, 0, res.length);
a61af66fc99e Initial load
duke
parents:
diff changeset
265 return res;
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267 }