Mercurial > hg > truffle
comparison agent/src/share/classes/sun/jvm/hotspot/runtime/solaris_amd64/SolarisAMD64JavaThreadPDAccess.java @ 0:a61af66fc99e jdk7-b24
Initial load
author | duke |
---|---|
date | Sat, 01 Dec 2007 00:00:00 +0000 |
parents | |
children | c18cbe5936b8 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a61af66fc99e |
---|---|
1 /* | |
2 * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved. | |
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 * | |
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
20 * CA 95054 USA or visit www.sun.com if you need additional information or | |
21 * have any questions. | |
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.*; | |
33 import sun.jvm.hotspot.types.*; | |
34 import sun.jvm.hotspot.utilities.*; | |
35 | |
36 public class SolarisAMD64JavaThreadPDAccess implements JavaThreadPDAccess { | |
37 private static AddressField lastJavaFPField; | |
38 private static AddressField osThreadField; | |
39 private static AddressField baseOfStackPointerField; | |
40 | |
41 // Field from OSThread | |
42 private static CIntegerField osThreadThreadIDField; | |
43 | |
44 // This is currently unneeded but is being kept in case we change | |
45 // the currentFrameGuess algorithm | |
46 private static final long GUESS_SCAN_RANGE = 128 * 1024; | |
47 | |
48 | |
49 static { | |
50 VM.registerVMInitializedObserver(new Observer() { | |
51 public void update(Observable o, Object data) { | |
52 initialize(VM.getVM().getTypeDataBase()); | |
53 } | |
54 }); | |
55 } | |
56 | |
57 private static synchronized void initialize(TypeDataBase db) { | |
58 Type type = db.lookupType("JavaThread"); | |
59 Type anchorType = db.lookupType("JavaFrameAnchor"); | |
60 | |
61 lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); | |
62 osThreadField = type.getAddressField("_osthread"); | |
63 | |
64 type = db.lookupType("OSThread"); | |
65 osThreadThreadIDField = type.getCIntegerField("_thread_id"); | |
66 } | |
67 | |
68 public Address getLastJavaFP(Address addr) { | |
69 return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); | |
70 } | |
71 | |
72 public Address getLastJavaPC(Address addr) { | |
73 return null; | |
74 } | |
75 | |
76 public Address getBaseOfStackPointer(Address addr) { | |
77 return null; | |
78 } | |
79 | |
80 public Frame getLastFramePD(JavaThread thread, Address addr) { | |
81 Address fp = thread.getLastJavaFP(); | |
82 if (fp == null) { | |
83 return null; // no information | |
84 } | |
85 Address pc = thread.getLastJavaPC(); | |
86 if ( pc != null ) { | |
87 return new AMD64Frame(thread.getLastJavaSP(), fp, pc); | |
88 } else { | |
89 return new AMD64Frame(thread.getLastJavaSP(), fp); | |
90 } | |
91 } | |
92 | |
93 public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { | |
94 return new AMD64RegisterMap(thread, updateMap); | |
95 } | |
96 | |
97 public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { | |
98 ThreadProxy t = getThreadProxy(addr); | |
99 AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); | |
100 AMD64CurrentFrameGuess guesser = new AMD64CurrentFrameGuess(context, thread); | |
101 if (!guesser.run(GUESS_SCAN_RANGE)) { | |
102 return null; | |
103 } | |
104 if (guesser.getPC() == null) { | |
105 return new AMD64Frame(guesser.getSP(), guesser.getFP()); | |
106 } else { | |
107 return new AMD64Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); | |
108 } | |
109 } | |
110 | |
111 | |
112 public void printThreadIDOn(Address addr, PrintStream tty) { | |
113 tty.print(getThreadProxy(addr)); | |
114 } | |
115 | |
116 | |
117 public void printInfoOn(Address threadAddr, PrintStream tty) { | |
118 } | |
119 | |
120 public Address getLastSP(Address addr) { | |
121 ThreadProxy t = getThreadProxy(addr); | |
122 AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); | |
123 return context.getRegisterAsAddress(AMD64ThreadContext.RSP); | |
124 } | |
125 | |
126 public ThreadProxy getThreadProxy(Address addr) { | |
127 // Fetch the OSThread (for now and for simplicity, not making a | |
128 // separate "OSThread" class in this package) | |
129 Address osThreadAddr = osThreadField.getValue(addr); | |
130 // Get the address of the thread ID from the OSThread | |
131 Address tidAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); | |
132 | |
133 JVMDebugger debugger = VM.getVM().getDebugger(); | |
134 return debugger.getThreadForIdentifierAddress(tidAddr); | |
135 } | |
136 | |
137 } |