Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/runtime/linux_sparc/LinuxSPARCJavaThreadPDAccess.java @ 1552:c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
Summary: Change all the Sun copyrights to Oracle copyright
Reviewed-by: ohair
author | trims |
---|---|
date | Thu, 27 May 2010 19:08:38 -0700 |
parents | a61af66fc99e |
children |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
2 * Copyright (c) 2006, 2007, 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.linux_sparc; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.debugger.sparc.*; | |
31 import sun.jvm.hotspot.runtime.*; | |
32 import sun.jvm.hotspot.runtime.sparc.*; | |
33 import sun.jvm.hotspot.types.*; | |
34 import sun.jvm.hotspot.utilities.*; | |
35 | |
36 public class LinuxSPARCJavaThreadPDAccess implements JavaThreadPDAccess { | |
37 private static AddressField baseOfStackPointerField; | |
38 private static AddressField postJavaStateField; | |
39 private static AddressField osThreadField; | |
40 private static int isPC; | |
41 private static int hasFlushed; | |
42 | |
43 // Field from OSThread | |
44 private static CIntegerField osThreadThreadIDField; | |
45 | |
46 static { | |
47 VM.registerVMInitializedObserver(new Observer() { | |
48 public void update(Observable o, Object data) { | |
49 initialize(VM.getVM().getTypeDataBase()); | |
50 } | |
51 }); | |
52 } | |
53 | |
54 private static synchronized void initialize(TypeDataBase db) { | |
55 Type type = db.lookupType("JavaThread"); | |
56 Type anchorType = db.lookupType("JavaFrameAnchor"); | |
57 | |
58 osThreadField = type.getAddressField("_osthread"); | |
59 hasFlushed = db.lookupIntConstant("JavaFrameAnchor::flushed").intValue(); | |
60 | |
61 type = db.lookupType("OSThread"); | |
62 osThreadThreadIDField = type.getCIntegerField("_thread_id"); | |
63 } | |
64 | |
65 public Address getLastJavaFP(Address addr) { | |
66 return null; | |
67 | |
68 } | |
69 | |
70 public Address getLastJavaPC(Address addr) { | |
71 return null; | |
72 } | |
73 | |
74 public Address getBaseOfStackPointer(Address addr) { | |
75 return baseOfStackPointerField.getValue(addr); | |
76 } | |
77 | |
78 public Frame getLastFramePD(JavaThread thread, Address addr) { | |
79 | |
80 // This assert doesn't work in the debugging case for threads | |
81 // which are running Java code and which haven't re-entered the | |
82 // runtime (e.g., through a Method.invoke() or otherwise). They | |
83 // haven't yet "decached" their last Java stack pointer to the | |
84 // thread. | |
85 | |
86 // if (Assert.ASSERTS_ENABLED) { | |
87 // Assert.that(hasLastJavaFrame(), "must have last_Java_sp() when suspended"); | |
88 // // FIXME: add assertion about flushing register windows for runtime system | |
89 // // (not appropriate for debugging system, though, unless at safepoin t) | |
90 // } | |
91 | |
92 // FIXME: I don't think this is necessary, but might be useful | |
93 // while debugging | |
94 if (thread.getLastJavaSP() == null) { | |
95 return null; | |
96 } | |
97 | |
98 // sparc does a lazy window flush. The _flags field of the JavaFrameAnchor | |
99 // encodes whether the windows have flushed. Whenever the windows have flushed | |
100 // there will be a last_Java_pc. | |
101 // In a relective system we'd have to do something to force the thread to flush | |
102 // its windows and give us the pc (or the younger_sp so we can find it ourselves) | |
103 // In a debugger situation (process or core) the flush should have happened and | |
104 // so if we don't have the younger sp we can find it | |
105 // | |
106 if (thread.getLastJavaPC() != null) { | |
107 return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), thread.getLastJavaPC()); | |
108 } else { | |
109 Frame top = getCurrentFrameGuess(thread, addr); | |
110 return new SPARCFrame(SPARCFrame.biasSP(thread.getLastJavaSP()), | |
111 SPARCFrame.biasSP(SPARCFrame.findYoungerSP(top.getSP(), thread.getLastJavaSP())), | |
112 false); | |
113 } | |
114 | |
115 | |
116 } | |
117 | |
118 public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { | |
119 return new SPARCRegisterMap(thread, updateMap); | |
120 } | |
121 | |
122 public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { | |
123 ThreadProxy t = getThreadProxy(addr); | |
124 SPARCThreadContext context = (SPARCThreadContext) t.getContext(); | |
125 // For now, let's see what happens if we do a similar thing to | |
126 // what the runtime code does. I suspect this may cause us to lose | |
127 // the top frame from the stack. | |
128 Address sp = context.getRegisterAsAddress(SPARCThreadContext.R_SP); | |
129 Address pc = context.getRegisterAsAddress(SPARCThreadContext.R_PC); | |
130 | |
131 if ((sp == null) || (pc == null)) { | |
132 // Problems (have not hit this case so far, but would be bad to continue if we did) | |
133 return null; | |
134 } | |
135 | |
136 return new SPARCFrame(sp, pc); | |
137 } | |
138 | |
139 | |
140 public void printThreadIDOn(Address addr, PrintStream tty) { | |
141 tty.print(getThreadProxy(addr)); | |
142 } | |
143 | |
144 public Address getLastSP(Address addr) { | |
145 ThreadProxy t = getThreadProxy(addr); | |
146 SPARCThreadContext context = (SPARCThreadContext) t.getContext(); | |
147 return SPARCFrame.unBiasSP(context.getRegisterAsAddress(SPARCThreadContext.R_SP)); | |
148 } | |
149 | |
150 public void printInfoOn(Address threadAddr, PrintStream tty) { | |
151 } | |
152 | |
153 public ThreadProxy getThreadProxy(Address addr) { | |
154 // Fetch the OSThread (for now and for simplicity, not making a | |
155 // separate "OSThread" class in this package) | |
156 Address osThreadAddr = osThreadField.getValue(addr); | |
157 // Get the address of the thread ID from the OSThread | |
158 Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); | |
159 | |
160 JVMDebugger debugger = VM.getVM().getDebugger(); | |
161 return debugger.getThreadForIdentifierAddress(tidAddr); | |
162 } | |
163 | |
164 | |
165 } |