Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/runtime/bsd_amd64/BsdAMD64JavaThreadPDAccess.java @ 17467:55fb97c4c58d hs25-b65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
Summary: Copyright year updated for files modified during 2013
Reviewed-by: twisti, iveresov
author | mikael |
---|---|
date | Tue, 24 Dec 2013 11:48:39 -0800 |
parents | 758935f7c23f |
children | 4ca6dc0799b6 |
rev | line source |
---|---|
3960 | 1 /* |
17467
55fb97c4c58d
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
8023
diff
changeset
|
2 * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
3960 | 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 package sun.jvm.hotspot.runtime.bsd_amd64; | |
26 | |
27 import java.io.*; | |
28 import java.util.*; | |
29 import sun.jvm.hotspot.debugger.*; | |
30 import sun.jvm.hotspot.debugger.amd64.*; | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
31 import sun.jvm.hotspot.debugger.bsd.BsdDebugger; |
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
32 import sun.jvm.hotspot.debugger.bsd.BsdDebuggerLocal; |
3960 | 33 import sun.jvm.hotspot.runtime.*; |
34 import sun.jvm.hotspot.runtime.amd64.*; | |
35 import sun.jvm.hotspot.runtime.x86.*; | |
36 import sun.jvm.hotspot.types.*; | |
37 import sun.jvm.hotspot.utilities.*; | |
38 | |
39 public class BsdAMD64JavaThreadPDAccess implements JavaThreadPDAccess { | |
40 private static AddressField lastJavaFPField; | |
41 private static AddressField osThreadField; | |
42 | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
43 // Fields from OSThread |
3960 | 44 private static CIntegerField osThreadThreadIDField; |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
45 private static CIntegerField osThreadUniqueThreadIDField; |
3960 | 46 |
47 // This is currently unneeded but is being kept in case we change | |
48 // the currentFrameGuess algorithm | |
49 private static final long GUESS_SCAN_RANGE = 128 * 1024; | |
50 | |
51 static { | |
52 VM.registerVMInitializedObserver(new Observer() { | |
53 public void update(Observable o, Object data) { | |
54 initialize(VM.getVM().getTypeDataBase()); | |
55 } | |
56 }); | |
57 } | |
58 | |
59 private static synchronized void initialize(TypeDataBase db) { | |
60 Type type = db.lookupType("JavaThread"); | |
61 osThreadField = type.getAddressField("_osthread"); | |
62 | |
63 Type anchorType = db.lookupType("JavaFrameAnchor"); | |
64 lastJavaFPField = anchorType.getAddressField("_last_Java_fp"); | |
65 | |
66 Type osThreadType = db.lookupType("OSThread"); | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
67 osThreadThreadIDField = osThreadType.getCIntegerField("_thread_id"); |
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
68 osThreadUniqueThreadIDField = osThreadType.getCIntegerField("_unique_thread_id"); |
3960 | 69 } |
70 | |
71 public Address getLastJavaFP(Address addr) { | |
72 return lastJavaFPField.getValue(addr.addOffsetTo(sun.jvm.hotspot.runtime.JavaThread.getAnchorField().getOffset())); | |
73 } | |
74 | |
75 public Address getLastJavaPC(Address addr) { | |
76 return null; | |
77 } | |
78 | |
79 public Address getBaseOfStackPointer(Address addr) { | |
80 return null; | |
81 } | |
82 | |
83 public Frame getLastFramePD(JavaThread thread, Address addr) { | |
84 Address fp = thread.getLastJavaFP(); | |
85 if (fp == null) { | |
86 return null; // no information | |
87 } | |
88 return new X86Frame(thread.getLastJavaSP(), fp); | |
89 } | |
90 | |
91 public RegisterMap newRegisterMap(JavaThread thread, boolean updateMap) { | |
92 return new X86RegisterMap(thread, updateMap); | |
93 } | |
94 | |
95 public Frame getCurrentFrameGuess(JavaThread thread, Address addr) { | |
96 ThreadProxy t = getThreadProxy(addr); | |
97 AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); | |
98 AMD64CurrentFrameGuess guesser = new AMD64CurrentFrameGuess(context, thread); | |
99 if (!guesser.run(GUESS_SCAN_RANGE)) { | |
100 return null; | |
101 } | |
102 if (guesser.getPC() == null) { | |
103 return new X86Frame(guesser.getSP(), guesser.getFP()); | |
104 } else { | |
105 return new X86Frame(guesser.getSP(), guesser.getFP(), guesser.getPC()); | |
106 } | |
107 } | |
108 | |
109 public void printThreadIDOn(Address addr, PrintStream tty) { | |
110 tty.print(getThreadProxy(addr)); | |
111 } | |
112 | |
113 public void printInfoOn(Address threadAddr, PrintStream tty) { | |
114 tty.print("Thread id: "); | |
115 printThreadIDOn(threadAddr, tty); | |
116 // tty.println("\nPostJavaState: " + getPostJavaState(threadAddr)); | |
117 } | |
118 | |
119 public Address getLastSP(Address addr) { | |
120 ThreadProxy t = getThreadProxy(addr); | |
121 AMD64ThreadContext context = (AMD64ThreadContext) t.getContext(); | |
122 return context.getRegisterAsAddress(AMD64ThreadContext.RSP); | |
123 } | |
124 | |
125 public ThreadProxy getThreadProxy(Address addr) { | |
126 // Addr is the address of the JavaThread. | |
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 threadIdAddr = osThreadAddr.addOffsetTo(osThreadThreadIDField.getOffset()); | |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
132 Address uniqueThreadIdAddr = osThreadAddr.addOffsetTo(osThreadUniqueThreadIDField.getOffset()); |
3960 | 133 |
8023
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
134 BsdDebuggerLocal debugger = (BsdDebuggerLocal) VM.getVM().getDebugger(); |
758935f7c23f
8006423: SA: NullPointerException in sun.jvm.hotspot.debugger.bsd.BsdThread.getContext(BsdThread.java:67)
sla
parents:
3960
diff
changeset
|
135 return debugger.getThreadForIdentifierAddress(threadIdAddr, uniqueThreadIdAddr); |
3960 | 136 } |
137 } |