Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java @ 19646:c5f6a7397eb1
SA fixes: add GraalEnv to VMTypes, remove references to value_value from agent sources
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Fri, 20 Feb 2015 14:24:16 +0100 |
parents | 7588156f5cf9 |
children |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2004, 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.runtime.solaris_amd64; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.debugger.amd64.*; | |
31 import sun.jvm.hotspot.runtime.*; | |
32 import sun.jvm.hotspot.runtime.amd64.*; | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
33 import sun.jvm.hotspot.runtime.x86.*; |
0 | 34 import sun.jvm.hotspot.types.*; |
35 import sun.jvm.hotspot.utilities.*; | |
36 | |
37 public class SolarisAMD64JavaThreadPDAccess implements JavaThreadPDAccess { | |
38 private static AddressField lastJavaFPField; | |
39 private static AddressField osThreadField; | |
40 private static AddressField baseOfStackPointerField; | |
41 | |
42 // Field from OSThread | |
43 private static CIntegerField osThreadThreadIDField; | |
44 | |
45 // This is currently unneeded but is being kept in case we change | |
46 // the currentFrameGuess algorithm | |
47 private static final long GUESS_SCAN_RANGE = 128 * 1024; | |
48 | |
49 | |
50 static { | |
51 VM.registerVMInitializedObserver(new Observer() { | |
52 public void update(Observable o, Object data) { | |
53 initialize(VM.getVM().getTypeDataBase()); | |
54 } | |
55 }); | |
56 } | |
57 | |
58 private static synchronized void initialize(TypeDataBase db) { | |
59 Type type = db.lookupType("JavaThread"); | |
60 Type anchorType = db.lookupType("JavaFrameAnchor"); | |
61 | |
62 lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); | |
63 osThreadField = type.getAddressField("_osthread"); | |
64 | |
65 type = db.lookupType("OSThread"); | |
66 osThreadThreadIDField = type.getCIntegerField("_thread_id"); | |
67 } | |
68 | |
69 public Address getLastJavaFP(Address addr) { | |
70 return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); | |
71 } | |
72 | |
73 public Address getLastJavaPC(Address addr) { | |
74 return null; | |
75 } | |
76 | |
77 public Address getBaseOfStackPointer(Address addr) { | |
78 return null; | |
79 } | |
80 | |
81 public Frame getLastFramePD(JavaThread thread, Address addr) { | |
82 Address fp = thread.getLastJavaFP(); | |
83 if (fp == null) { | |
84 return null; // no information | |
85 } | |
86 Address pc = thread.getLastJavaPC(); | |
87 if ( pc != null ) { | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
88 return new X86Frame(thread.getLastJavaSP(), fp, pc); |
0 | 89 } else { |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
90 return new X86Frame(thread.getLastJavaSP(), fp); |
0 | 91 } |
92 } | |
93 | |
94 public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
95 return new X86RegisterMap(thread, updateMap); |
0 | 96 } |
97 | |
98 public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { | |
99 ThreadProxy t = getThreadProxy(addr); | |
100 AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); | |
101 AMD64CurrentFrameGuess guesser = new AMD64CurrentFrameGuess(context, thread); | |
102 if (!guesser.run(GUESS_SCAN_RANGE)) { | |
103 return null; | |
104 } | |
105 if (guesser.getPC() == null) { | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
106 return new X86Frame(guesser.getSP(), guesser.getFP()); |
0 | 107 } else { |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
108 return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); |
0 | 109 } |
110 } | |
111 | |
112 | |
113 public void printThreadIDOn(Address addr, PrintStream tty) { | |
114 tty.print(getThreadProxy(addr)); | |
115 } | |
116 | |
117 | |
118 public void printInfoOn(Address threadAddr, PrintStream tty) { | |
119 } | |
120 | |
121 public Address getLastSP(Address addr) { | |
122 ThreadProxy t = getThreadProxy(addr); | |
123 AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); | |
124 return context.getRegisterAsAddress(AMD64ThreadContext.RSP); | |
125 } | |
126 | |
127 public ThreadProxy getThreadProxy(Address addr) { | |
128 // Fetch the OSThread (for now and for simplicity, not making a | |
129 // separate "OSThread" class in this package) | |
130 Address osThreadAddr = osThreadField.getValue(addr); | |
131 // Get the address of the thread ID from the OSThread | |
132 Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); | |
133 | |
134 JVMDebugger debugger = VM.getVM().getDebugger(); | |
135 return debugger.getThreadForIdentifierAddress(tidAddr); | |
136 } | |
137 | |
138 } |