author | poonam |
Tue, 08 Dec 2015 05:50:46 -0800 | |
changeset 34665 | 9fdcc78b5398 |
parent 27475 | 1f22a5d5be00 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
16351 | 2 |
* Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5528
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5528
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
5528
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
25 |
package sun.jvm.hotspot.runtime; |
|
26 |
||
27 |
import java.io.*; |
|
28 |
import java.util.*; |
|
29 |
import sun.jvm.hotspot.debugger.*; |
|
30 |
import sun.jvm.hotspot.oops.*; |
|
31 |
import sun.jvm.hotspot.types.*; |
|
32 |
import sun.jvm.hotspot.utilities.*; |
|
33 |
||
34 |
/** This is an abstract class because there are certain OS- and |
|
35 |
CPU-specific operations (like the setting and getting of the last |
|
36 |
Java frame pointer) which need to be factored out. These |
|
37 |
operations are implemented by, for example, |
|
38 |
SolarisSPARCJavaThread, and the concrete subclasses are |
|
39 |
instantiated by the JavaThreadFactory in the Threads class. */ |
|
40 |
||
41 |
public class JavaThread extends Thread { |
|
42 |
private static final boolean DEBUG = System.getProperty("sun.jvm.hotspot.runtime.JavaThread.DEBUG") != null; |
|
43 |
||
44 |
private static AddressField nextField; |
|
45 |
private static sun.jvm.hotspot.types.OopField threadObjField; |
|
46 |
private static AddressField anchorField; |
|
47 |
private static AddressField lastJavaSPField; |
|
48 |
private static AddressField lastJavaPCField; |
|
49 |
private static CIntegerField threadStateField; |
|
50 |
private static AddressField osThreadField; |
|
2526
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
51 |
private static AddressField stackBaseField; |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
52 |
private static CIntegerField stackSizeField; |
1 | 53 |
|
54 |
private static JavaThreadPDAccess access; |
|
55 |
||
56 |
// JavaThreadStates read from underlying process |
|
57 |
private static int UNINITIALIZED; |
|
58 |
private static int NEW; |
|
59 |
private static int NEW_TRANS; |
|
60 |
private static int IN_NATIVE; |
|
61 |
private static int IN_NATIVE_TRANS; |
|
62 |
private static int IN_VM; |
|
63 |
private static int IN_VM_TRANS; |
|
64 |
private static int IN_JAVA; |
|
65 |
private static int IN_JAVA_TRANS; |
|
66 |
private static int BLOCKED; |
|
67 |
private static int BLOCKED_TRANS; |
|
68 |
||
69 |
static { |
|
70 |
VM.registerVMInitializedObserver(new Observer() { |
|
71 |
public void update(Observable o, Object data) { |
|
72 |
initialize(VM.getVM().getTypeDataBase()); |
|
73 |
} |
|
74 |
}); |
|
75 |
} |
|
76 |
||
77 |
private static synchronized void initialize(TypeDataBase db) { |
|
78 |
Type type = db.lookupType("JavaThread"); |
|
79 |
Type anchorType = db.lookupType("JavaFrameAnchor"); |
|
80 |
||
81 |
nextField = type.getAddressField("_next"); |
|
82 |
threadObjField = type.getOopField("_threadObj"); |
|
83 |
anchorField = type.getAddressField("_anchor"); |
|
84 |
lastJavaSPField = anchorType.getAddressField("_last_Java_sp"); |
|
85 |
lastJavaPCField = anchorType.getAddressField("_last_Java_pc"); |
|
86 |
threadStateField = type.getCIntegerField("_thread_state"); |
|
87 |
osThreadField = type.getAddressField("_osthread"); |
|
2526
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
88 |
stackBaseField = type.getAddressField("_stack_base"); |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
89 |
stackSizeField = type.getCIntegerField("_stack_size"); |
1 | 90 |
|
91 |
UNINITIALIZED = db.lookupIntConstant("_thread_uninitialized").intValue(); |
|
92 |
NEW = db.lookupIntConstant("_thread_new").intValue(); |
|
93 |
NEW_TRANS = db.lookupIntConstant("_thread_new_trans").intValue(); |
|
94 |
IN_NATIVE = db.lookupIntConstant("_thread_in_native").intValue(); |
|
95 |
IN_NATIVE_TRANS = db.lookupIntConstant("_thread_in_native_trans").intValue(); |
|
96 |
IN_VM = db.lookupIntConstant("_thread_in_vm").intValue(); |
|
97 |
IN_VM_TRANS = db.lookupIntConstant("_thread_in_vm_trans").intValue(); |
|
98 |
IN_JAVA = db.lookupIntConstant("_thread_in_Java").intValue(); |
|
99 |
IN_JAVA_TRANS = db.lookupIntConstant("_thread_in_Java_trans").intValue(); |
|
100 |
BLOCKED = db.lookupIntConstant("_thread_blocked").intValue(); |
|
101 |
BLOCKED_TRANS = db.lookupIntConstant("_thread_blocked_trans").intValue(); |
|
102 |
} |
|
103 |
||
104 |
public JavaThread(Address addr) { |
|
105 |
super(addr); |
|
106 |
} |
|
107 |
||
108 |
void setThreadPDAccess(JavaThreadPDAccess access) { |
|
109 |
this.access = access; |
|
110 |
} |
|
111 |
||
112 |
public JavaThread next() { |
|
113 |
Address threadAddr = nextField.getValue(addr); |
|
114 |
if (threadAddr == null) { |
|
115 |
return null; |
|
116 |
} |
|
117 |
||
118 |
return VM.getVM().getThreads().createJavaThreadWrapper(threadAddr); |
|
119 |
} |
|
120 |
||
27475 | 121 |
/** NOTE: for convenience, this differs in definition from the underlying VM. |
122 |
Only "pure" JavaThreads return true; CompilerThreads, the CodeCacheSweeperThread, |
|
123 |
JVMDIDebuggerThreads return false. |
|
124 |
FIXME: |
|
1 | 125 |
consider encapsulating platform-specific functionality in an |
126 |
object instead of using inheritance (which is the primary reason |
|
127 |
we can't traverse CompilerThreads, etc; didn't want to have, for |
|
128 |
example, "SolarisSPARCCompilerThread".) */ |
|
129 |
public boolean isJavaThread() { return true; } |
|
130 |
||
131 |
public static AddressField getAnchorField() { return anchorField; } |
|
132 |
||
133 |
/** Get the last Java stack pointer */ |
|
134 |
public Address getLastJavaSP() { |
|
135 |
Address sp = lastJavaSPField.getValue(addr.addOffsetTo(anchorField.getOffset())); |
|
136 |
return sp; |
|
137 |
} |
|
138 |
||
139 |
public Address getLastJavaPC() { |
|
140 |
Address pc = lastJavaPCField.getValue(addr.addOffsetTo(anchorField.getOffset())); |
|
141 |
return pc; |
|
142 |
} |
|
143 |
||
144 |
/** Abstract accessor to last Java frame pointer, implemented by |
|
145 |
OS/CPU-specific JavaThread implementation. May return null if |
|
146 |
there is no frame pointer or if it is not necessary on this |
|
147 |
platform. */ |
|
148 |
public Address getLastJavaFP(){ |
|
149 |
return access.getLastJavaFP(addr); |
|
150 |
} |
|
151 |
||
152 |
/** Abstract accessor to last Java pc, implemented by |
|
153 |
OS/CPU-specific JavaThread implementation. May return null if |
|
154 |
there is no frame pointer or if it is not necessary on this |
|
155 |
platform. */ |
|
156 |
||
157 |
/* |
|
158 |
public Address getLastJavaPC(){ |
|
159 |
return access.getLastJavaPC(addr); |
|
160 |
} |
|
161 |
*/ |
|
162 |
||
163 |
// FIXME: not yet implementable |
|
164 |
// public abstract void setLastJavaFP(Address fp); |
|
165 |
||
166 |
/** A stack pointer older than any java frame stack pointer. Only |
|
167 |
needed on some platforms; for example, see |
|
168 |
thread_solaris_sparc.hpp. */ |
|
169 |
public Address getBaseOfStackPointer(){ |
|
170 |
return access.getBaseOfStackPointer(addr); |
|
171 |
} |
|
172 |
// FIXME: not yet implementable |
|
173 |
// public abstract void setBaseOfStackPointer(Address fp); |
|
174 |
||
175 |
/** Tells whether the last Java frame is set */ |
|
176 |
public boolean hasLastJavaFrame() { |
|
177 |
return (getLastJavaSP() != null); |
|
178 |
} |
|
179 |
||
180 |
/** Accessing frames */ |
|
181 |
public Frame getLastFrame() { |
|
182 |
// FIXME: would need to implement runtime routine |
|
183 |
// "cacheStatePD(boolean)" for reflective system to be able to |
|
184 |
// flush register windows on SPARC |
|
185 |
return cookLastFrame(getLastFramePD()); |
|
186 |
} |
|
187 |
||
188 |
/** Internal routine implemented by platform-dependent subclasses */ |
|
189 |
protected Frame getLastFramePD(){ |
|
190 |
return access.getLastFramePD(this, addr); |
|
191 |
} |
|
192 |
||
193 |
/** Accessing frames. Returns the last Java VFrame or null if none |
|
194 |
was present. (NOTE that this is mostly unusable in a debugging |
|
195 |
system; see getLastJavaVFrameDbg, below, which provides very |
|
196 |
different functionality.) */ |
|
197 |
public JavaVFrame getLastJavaVFrame(RegisterMap regMap) { |
|
198 |
if (Assert.ASSERTS_ENABLED) { |
|
199 |
Assert.that(regMap != null, "a map must be given"); |
|
200 |
} |
|
201 |
Frame f = getLastFrame(); |
|
202 |
if (f == null) { |
|
203 |
return null; |
|
204 |
} |
|
205 |
for (VFrame vf = VFrame.newVFrame(f, regMap, this); vf != null; vf = vf.sender()) { |
|
206 |
if (vf.isJavaFrame()) { |
|
207 |
return (JavaVFrame) vf; |
|
208 |
} |
|
209 |
} |
|
210 |
return null; |
|
211 |
} |
|
212 |
||
213 |
/** This should only be used by a debugger. Uses the current frame |
|
214 |
guess to attempt to get the topmost JavaVFrame. |
|
215 |
(getLastJavaVFrame, as a port of the VM's routine, assumes the |
|
216 |
VM is at a safepoint.) */ |
|
217 |
public JavaVFrame getLastJavaVFrameDbg() { |
|
218 |
RegisterMap regMap = newRegisterMap(true); |
|
219 |
sun.jvm.hotspot.runtime.Frame f = getCurrentFrameGuess(); |
|
220 |
if (f == null) return null; |
|
221 |
boolean imprecise = true; |
|
222 |
if (f.isInterpretedFrame() && !f.isInterpretedFrameValid()) { |
|
764
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
1
diff
changeset
|
223 |
if (DEBUG) { |
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
1
diff
changeset
|
224 |
System.out.println("Correcting for invalid interpreter frame"); |
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
1
diff
changeset
|
225 |
} |
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
1
diff
changeset
|
226 |
f = f.sender(regMap); |
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
1
diff
changeset
|
227 |
imprecise = false; |
1 | 228 |
} |
229 |
VFrame vf = VFrame.newVFrame(f, regMap, this, true, imprecise); |
|
230 |
if (vf == null) { |
|
231 |
if (DEBUG) { |
|
232 |
System.out.println(" (Unable to create vframe for topmost frame guess)"); |
|
233 |
} |
|
234 |
return null; |
|
235 |
} |
|
764
67578bc37423
6620329: jstack prints double native methods on Solaris/sparc
swamyv
parents:
1
diff
changeset
|
236 |
return vf.isJavaFrame() ? (JavaVFrame)vf : vf.javaSender(); |
1 | 237 |
} |
238 |
||
239 |
/** In this system, a JavaThread is the top-level factory for a |
|
240 |
RegisterMap, since the JavaThread implementation is already |
|
241 |
platform-specific and RegisterMap is also necessarily |
|
242 |
platform-specific. The updateMap argument indicates whether the |
|
243 |
register map needs to be updated, for example during stack |
|
244 |
traversal -- see frame.hpp. */ |
|
245 |
public RegisterMap newRegisterMap(boolean updateMap){ |
|
246 |
return access.newRegisterMap(this, updateMap); |
|
247 |
} |
|
248 |
||
249 |
/** This is only designed to be used by the debugging system. |
|
250 |
Returns a "best guess" of the topmost frame on the stack. This |
|
251 |
guess should be as "raw" as possible. For example, if the |
|
252 |
topmost frame is an interpreter frame (the return PC is in the |
|
253 |
interpreter) but is not a valid frame (i.e., the BCI has not yet |
|
254 |
been set up) this should still return the topmost frame and not |
|
255 |
the sender. Validity checks are done at higher levels. */ |
|
256 |
public Frame getCurrentFrameGuess(){ |
|
257 |
return access.getCurrentFrameGuess(this, addr); |
|
258 |
} |
|
259 |
||
260 |
/** Also only intended for use by the debugging system. Provides the |
|
261 |
same effect of OSThread::print(); that is, prints a value which |
|
262 |
allows the user to intuitively understand which native OS thread |
|
263 |
maps to this Java thread. Does not print a newline or leading or |
|
264 |
trailing spaces. */ |
|
265 |
public void printThreadIDOn(PrintStream tty) { |
|
266 |
access.printThreadIDOn(addr,tty); |
|
267 |
} |
|
268 |
||
269 |
public void printThreadID() { |
|
270 |
printThreadIDOn(System.out); |
|
271 |
} |
|
272 |
||
273 |
public ThreadProxy getThreadProxy() { |
|
274 |
return access.getThreadProxy(addr); |
|
275 |
} |
|
276 |
||
277 |
// |
|
278 |
// Safepoint support |
|
279 |
// |
|
280 |
||
281 |
public JavaThreadState getThreadState() { |
|
282 |
int val = (int) threadStateField.getValue(addr); |
|
283 |
if (val == UNINITIALIZED) { |
|
284 |
return JavaThreadState.UNINITIALIZED; |
|
285 |
} else if (val == NEW) { |
|
286 |
return JavaThreadState.NEW; |
|
287 |
} else if (val == NEW_TRANS) { |
|
288 |
return JavaThreadState.NEW_TRANS; |
|
289 |
} else if (val == IN_NATIVE) { |
|
290 |
return JavaThreadState.IN_NATIVE; |
|
291 |
} else if (val == IN_NATIVE_TRANS) { |
|
292 |
return JavaThreadState.IN_NATIVE_TRANS; |
|
293 |
} else if (val == IN_VM) { |
|
294 |
return JavaThreadState.IN_VM; |
|
295 |
} else if (val == IN_VM_TRANS) { |
|
296 |
return JavaThreadState.IN_VM_TRANS; |
|
297 |
} else if (val == IN_JAVA) { |
|
298 |
return JavaThreadState.IN_JAVA; |
|
299 |
} else if (val == IN_JAVA_TRANS) { |
|
300 |
return JavaThreadState.IN_JAVA_TRANS; |
|
301 |
} else if (val == BLOCKED) { |
|
302 |
return JavaThreadState.BLOCKED; |
|
303 |
} else if (val == BLOCKED_TRANS) { |
|
304 |
return JavaThreadState.BLOCKED_TRANS; |
|
305 |
} else { |
|
306 |
throw new RuntimeException("Illegal thread state " + val); |
|
307 |
} |
|
308 |
} |
|
309 |
// FIXME: not yet implementable |
|
310 |
// public void setThreadState(JavaThreadState s); |
|
311 |
||
312 |
// |
|
313 |
// Miscellaneous operations |
|
314 |
// |
|
315 |
||
316 |
public OSThread getOSThread() { |
|
317 |
return (OSThread) VMObjectFactory.newObject(OSThread.class, osThreadField.getValue(addr)); |
|
318 |
} |
|
319 |
||
2526
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
320 |
public Address getStackBase() { |
2861
073fc25fed0c
6843580: JavaThread.getStackBase throws sun.jvm.hotspot.WrongTypeException invoked by jstack
xlu
parents:
2526
diff
changeset
|
321 |
return stackBaseField.getValue(addr); |
2526
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
322 |
} |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
323 |
|
16351 | 324 |
public long getStackBaseValue() { |
325 |
return VM.getVM().getAddressValue(getStackBase()); |
|
326 |
} |
|
327 |
||
2526
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
328 |
public long getStackSize() { |
2861
073fc25fed0c
6843580: JavaThread.getStackBase throws sun.jvm.hotspot.WrongTypeException invoked by jstack
xlu
parents:
2526
diff
changeset
|
329 |
return stackSizeField.getValue(addr); |
2526
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
330 |
} |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
331 |
|
1 | 332 |
/** Gets the Java-side thread object for this JavaThread */ |
333 |
public Oop getThreadObj() { |
|
5528 | 334 |
Oop obj = null; |
335 |
try { |
|
336 |
obj = VM.getVM().getObjectHeap().newOop(threadObjField.getValue(addr)); |
|
337 |
} catch (Exception e) { |
|
338 |
e.printStackTrace(); |
|
339 |
} |
|
340 |
return obj; |
|
1 | 341 |
} |
342 |
||
343 |
/** Get the Java-side name of this thread */ |
|
344 |
public String getThreadName() { |
|
345 |
Oop threadObj = getThreadObj(); |
|
346 |
if (threadObj == null) { |
|
347 |
return "<null>"; |
|
348 |
} |
|
349 |
return OopUtilities.threadOopGetName(threadObj); |
|
350 |
} |
|
351 |
||
352 |
// |
|
353 |
// Oop traversal |
|
354 |
// |
|
355 |
||
356 |
public void oopsDo(AddressVisitor oopVisitor) { |
|
357 |
super.oopsDo(oopVisitor); |
|
358 |
||
359 |
// FIXME: add in the rest of the routine from the VM |
|
360 |
||
361 |
// Traverse the execution stack |
|
362 |
for(StackFrameStream fst = new StackFrameStream(this); !fst.isDone(); fst.next()) { |
|
363 |
fst.getCurrent().oopsDo(oopVisitor, fst.getRegisterMap()); |
|
364 |
} |
|
365 |
} |
|
366 |
||
367 |
public boolean isInStack(Address a) { |
|
368 |
if (Assert.ASSERTS_ENABLED) { |
|
369 |
Assert.that(VM.getVM().isDebugging(), "Not yet implemented for non-debugging system"); |
|
370 |
} |
|
371 |
Address sp = lastSPDbg(); |
|
2526
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
372 |
Address stackBase = getStackBase(); |
1 | 373 |
// Be robust |
2526
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
374 |
if (sp == null) return false; |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
375 |
return stackBase.greaterThanOrEqual(a) && sp.lessThanOrEqual(a); |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
376 |
} |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
377 |
|
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
378 |
public boolean isLockOwned(Address a) { |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
379 |
Address stackBase = getStackBase(); |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
380 |
Address stackLimit = stackBase.addOffsetTo(-getStackSize()); |
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
381 |
|
39a58a50be35
6699669: Hotspot server leaves synchronized block with monitor in bad state
xlu
parents:
764
diff
changeset
|
382 |
return stackBase.greaterThanOrEqual(a) && stackLimit.lessThanOrEqual(a); |
1 | 383 |
|
384 |
// FIXME: should traverse MonitorArray/MonitorChunks as in VM |
|
385 |
} |
|
386 |
||
387 |
public Oop getCurrentParkBlocker() { |
|
388 |
Oop threadObj = getThreadObj(); |
|
389 |
if (threadObj != null) { |
|
390 |
return OopUtilities.threadOopGetParkBlocker(threadObj); |
|
391 |
} |
|
392 |
return null; |
|
393 |
} |
|
394 |
||
395 |
public void printInfoOn(PrintStream tty) { |
|
396 |
||
397 |
tty.println("State: " + getThreadState().toString()); |
|
398 |
// Attempt to figure out the addresses covered by Java frames. |
|
399 |
// NOTE: we should make this a method and let the Stackwalk panel use the result too. |
|
400 |
// |
|
401 |
sun.jvm.hotspot.runtime.Frame tmpFrame = getCurrentFrameGuess(); |
|
402 |
if (tmpFrame != null ) { |
|
403 |
Address sp = tmpFrame.getSP(); |
|
404 |
Address maxSP = sp; |
|
405 |
Address minSP = sp; |
|
406 |
RegisterMap tmpMap = newRegisterMap(false); |
|
407 |
while ((tmpFrame != null) && (!tmpFrame.isFirstFrame())) { |
|
408 |
tmpFrame = tmpFrame.sender(tmpMap); |
|
409 |
if (tmpFrame != null) { |
|
410 |
sp = tmpFrame.getSP(); |
|
411 |
maxSP = AddressOps.max(maxSP, sp); |
|
412 |
minSP = AddressOps.min(minSP, sp); |
|
413 |
} |
|
414 |
} |
|
415 |
tty.println("Stack in use by Java: " + minSP + " .. " + maxSP); |
|
416 |
} else { |
|
417 |
tty.println("No Java frames present"); |
|
418 |
} |
|
34665
9fdcc78b5398
8140031: SA: Searching for a value in Threads does not work
poonam
parents:
27475
diff
changeset
|
419 |
tty.println("Base of Stack: " + getStackBase()); |
1 | 420 |
tty.println("Last_Java_SP: " + getLastJavaSP()); |
421 |
tty.println("Last_Java_FP: " + getLastJavaFP()); |
|
422 |
tty.println("Last_Java_PC: " + getLastJavaPC()); |
|
423 |
// More stuff like saved_execption_pc, safepoint_state, ... |
|
424 |
access.printInfoOn(addr, tty); |
|
425 |
||
426 |
} |
|
427 |
||
428 |
/////////////////////////////// |
|
429 |
// // |
|
430 |
// FIXME: add more accessors // |
|
431 |
// // |
|
432 |
/////////////////////////////// |
|
433 |
||
434 |
//-------------------------------------------------------------------------------- |
|
435 |
// Internals only below this point |
|
436 |
// |
|
437 |
||
438 |
private Frame cookLastFrame(Frame fr) { |
|
439 |
if (fr == null) { |
|
440 |
return null; |
|
441 |
} |
|
442 |
||
443 |
Address pc = fr.getPC(); |
|
444 |
||
445 |
if (Assert.ASSERTS_ENABLED) { |
|
446 |
if (pc == null) { |
|
447 |
Assert.that(VM.getVM().isDebugging(), "must have PC"); |
|
448 |
} |
|
449 |
} |
|
450 |
return fr; |
|
451 |
} |
|
452 |
||
453 |
private Address lastSPDbg() { |
|
454 |
return access.getLastSP(addr); |
|
455 |
} |
|
456 |
||
457 |
} |