Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/runtime/linux_amd64/LinuxAMD64JavaThreadPDAccess.java @ 10343:6bd680e9ea35
8003421: NPG: Move oops out of InstanceKlass into mirror
Summary: Inject protection_domain, signers, init_lock into java_lang_Class
Reviewed-by: stefank, dholmes, sla
author | coleenp |
---|---|
date | Wed, 22 May 2013 14:37:49 -0400 |
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) 2003, 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_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 LinuxAMD64JavaThreadPDAccess implements JavaThreadPDAccess { | |
38 private static AddressField lastJavaFPField; | |
39 private static AddressField osThreadField; | |
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 static { | |
49 VM.registerVMInitializedObserver(new Observer() { | |
50 public void update(Observable o, Object data) { | |
51 initialize(VM.getVM().getTypeDataBase()); | |
52 } | |
53 }); | |
54 } | |
55 | |
56 private static synchronized void initialize(TypeDataBase db) { | |
57 Type type = db.lookupType("JavaThread"); | |
58 osThreadField = type.getAddressField("_osthread"); | |
59 | |
60 Type anchorType = db.lookupType("JavaFrameAnchor"); | |
61 lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); | |
62 | |
63 Type osThreadType = db.lookupType("OSThread"); | |
64 osThreadThreadIDField = osThreadType.getCIntegerField("_thread_id"); | |
65 } | |
66 | |
67 public Address getLastJavaFP(Address addr) { | |
68 return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); | |
69 } | |
70 | |
71 public Address getLastJavaPC(Address addr) { | |
72 return null; | |
73 } | |
74 | |
75 public Address getBaseOfStackPointer(Address addr) { | |
76 return null; | |
77 } | |
78 | |
79 public Frame getLastFramePD(JavaThread thread, Address addr) { | |
80 Address fp = thread.getLastJavaFP(); | |
81 if (fp == null) { | |
82 return null; // no information | |
83 } | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
84 return new X86Frame(thread.getLastJavaSP(), fp); |
0 | 85 } |
86 | |
87 public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
88 return new X86RegisterMap(thread, updateMap); |
0 | 89 } |
90 | |
91 public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { | |
92 ThreadProxy t = getThreadProxy(addr); | |
93 AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); | |
94 AMD64CurrentFrameGuess guesser = new AMD64CurrentFrameGuess(context, thread); | |
95 if (!guesser.run(GUESS_SCAN_RANGE)) { | |
96 return null; | |
97 } | |
98 if (guesser.getPC() == null) { | |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
99 return new X86Frame(guesser.getSP(), guesser.getFP()); |
0 | 100 } else { |
3908
7588156f5cf9
7051798: SA-JDI: NPE in Frame.addressOfStackSlot(Frame.java:244)
never
parents:
1552
diff
changeset
|
101 return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); |
0 | 102 } |
103 } | |
104 | |
105 public void printThreadIDOn(Address addr, PrintStream tty) { | |
106 tty.print(getThreadProxy(addr)); | |
107 } | |
108 | |
109 public void printInfoOn(Address threadAddr, PrintStream tty) { | |
110 tty.print("Thread id: "); | |
111 printThreadIDOn(threadAddr, tty); | |
112 // tty.println("\nPostJavaState: " + getPostJavaState(threadAddr)); | |
113 } | |
114 | |
115 public Address getLastSP(Address addr) { | |
116 ThreadProxy t = getThreadProxy(addr); | |
117 AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); | |
118 return context.getRegisterAsAddress(AMD64ThreadContext.RSP); | |
119 } | |
120 | |
121 public ThreadProxy getThreadProxy(Address addr) { | |
122 // Addr is the address of the JavaThread. | |
123 // Fetch the OSThread (for now and for simplicity, not making a | |
124 // separate "OSThread" class in this package) | |
125 Address osThreadAddr = osThreadField.getValue(addr); | |
126 // Get the address of the _thread_id from the OSThread | |
127 Address threadIdAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); | |
128 | |
129 JVMDebugger debugger = VM.getVM().getDebugger(); | |
130 return debugger.getThreadForIdentifierAddress(threadIdAddr); | |
131 } | |
132 } |