author | kvn |
Tue, 09 Jun 2009 16:19:10 -0700 | |
changeset 3171 | aa289b22b577 |
parent 1 | 489c9b5090e2 |
child 3600 | 27aa4477d039 |
child 3261 | c7d5aae8d3f7 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
2 |
* Copyright 2000-2005 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.code; |
|
26 |
||
27 |
import java.io.*; |
|
28 |
import java.util.*; |
|
29 |
||
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
30 |
import sun.jvm.hotspot.debugger.*; |
1 | 31 |
import sun.jvm.hotspot.oops.*; |
32 |
import sun.jvm.hotspot.runtime.*; |
|
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
33 |
import sun.jvm.hotspot.utilities.*; |
1 | 34 |
|
35 |
/** ScopeDescs contain the information that makes source-level |
|
36 |
debugging of nmethods possible; each scopeDesc describes a method |
|
37 |
activation */ |
|
38 |
||
39 |
public class ScopeDesc { |
|
40 |
/** NMethod information */ |
|
41 |
private NMethod code; |
|
42 |
private Method method; |
|
43 |
private int bci; |
|
44 |
/** Decoding offsets */ |
|
45 |
private int decodeOffset; |
|
46 |
private int senderDecodeOffset; |
|
47 |
private int localsDecodeOffset; |
|
48 |
private int expressionsDecodeOffset; |
|
49 |
private int monitorsDecodeOffset; |
|
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
50 |
/** Scalar replaced bjects pool */ |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
51 |
private List objects; // ArrayList<ScopeValue> |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
52 |
|
1 | 53 |
|
54 |
public ScopeDesc(NMethod code, int decodeOffset) { |
|
55 |
this.code = code; |
|
56 |
this.decodeOffset = decodeOffset; |
|
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
57 |
this.objects = decodeObjectValues(DebugInformationRecorder.SERIALIZED_NULL); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
58 |
|
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
59 |
// Decode header |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
60 |
DebugInfoReadStream stream = streamAt(decodeOffset); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
61 |
|
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
62 |
senderDecodeOffset = stream.readInt(); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
63 |
method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
64 |
bci = stream.readBCI(); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
65 |
// Decode offsets for body and sender |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
66 |
localsDecodeOffset = stream.readInt(); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
67 |
expressionsDecodeOffset = stream.readInt(); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
68 |
monitorsDecodeOffset = stream.readInt(); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
69 |
} |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
70 |
|
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
71 |
public ScopeDesc(NMethod code, int decodeOffset, int objectDecodeOffset) { |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
72 |
this.code = code; |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
73 |
this.decodeOffset = decodeOffset; |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
74 |
this.objects = decodeObjectValues(objectDecodeOffset); |
1 | 75 |
|
76 |
// Decode header |
|
77 |
DebugInfoReadStream stream = streamAt(decodeOffset); |
|
78 |
||
79 |
senderDecodeOffset = stream.readInt(); |
|
80 |
method = (Method) VM.getVM().getObjectHeap().newOop(stream.readOopHandle()); |
|
81 |
bci = stream.readBCI(); |
|
82 |
// Decode offsets for body and sender |
|
83 |
localsDecodeOffset = stream.readInt(); |
|
84 |
expressionsDecodeOffset = stream.readInt(); |
|
85 |
monitorsDecodeOffset = stream.readInt(); |
|
86 |
} |
|
87 |
||
88 |
public NMethod getNMethod() { return code; } |
|
89 |
public Method getMethod() { return method; } |
|
90 |
public int getBCI() { return bci; } |
|
91 |
||
92 |
/** Returns a List<ScopeValue> */ |
|
93 |
public List getLocals() { |
|
94 |
return decodeScopeValues(localsDecodeOffset); |
|
95 |
} |
|
96 |
||
97 |
/** Returns a List<ScopeValue> */ |
|
98 |
public List getExpressions() { |
|
99 |
return decodeScopeValues(expressionsDecodeOffset); |
|
100 |
} |
|
101 |
||
102 |
/** Returns a List<MonitorValue> */ |
|
103 |
public List getMonitors() { |
|
104 |
return decodeMonitorValues(monitorsDecodeOffset); |
|
105 |
} |
|
106 |
||
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
107 |
/** Returns a List<MonitorValue> */ |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
108 |
public List getObjects() { |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
109 |
return objects; |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
110 |
} |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
111 |
|
1 | 112 |
/** Stack walking. Returns null if this is the outermost scope. */ |
113 |
public ScopeDesc sender() { |
|
114 |
if (isTop()) { |
|
115 |
return null; |
|
116 |
} |
|
117 |
||
118 |
return new ScopeDesc(code, senderDecodeOffset); |
|
119 |
} |
|
120 |
||
121 |
/** Returns where the scope was decoded */ |
|
122 |
public int getDecodeOffset() { |
|
123 |
return decodeOffset; |
|
124 |
} |
|
125 |
||
126 |
/** Tells whether sender() returns null */ |
|
127 |
public boolean isTop() { |
|
128 |
return (senderDecodeOffset == DebugInformationRecorder.SERIALIZED_NULL); |
|
129 |
} |
|
130 |
||
131 |
public boolean equals(Object arg) { |
|
132 |
if (arg == null) { |
|
133 |
return false; |
|
134 |
} |
|
135 |
||
136 |
if (!(arg instanceof ScopeDesc)) { |
|
137 |
return false; |
|
138 |
} |
|
139 |
||
140 |
ScopeDesc sd = (ScopeDesc) arg; |
|
141 |
||
142 |
return (sd.method.equals(method) && (sd.bci == bci)); |
|
143 |
} |
|
144 |
||
145 |
public void printValue() { |
|
146 |
printValueOn(System.out); |
|
147 |
} |
|
148 |
||
149 |
public void printValueOn(PrintStream tty) { |
|
150 |
tty.print("ScopeDesc for "); |
|
151 |
method.printValueOn(tty); |
|
152 |
tty.println(" @bci " + bci); |
|
153 |
} |
|
154 |
||
155 |
// FIXME: add more accessors |
|
156 |
||
157 |
//-------------------------------------------------------------------------------- |
|
158 |
// Internals only below this point |
|
159 |
// |
|
160 |
||
161 |
private DebugInfoReadStream streamAt(int decodeOffset) { |
|
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
162 |
return new DebugInfoReadStream(code, decodeOffset, objects); |
1 | 163 |
} |
164 |
||
165 |
/** Returns a List<ScopeValue> or null if no values were present */ |
|
166 |
private List decodeScopeValues(int decodeOffset) { |
|
167 |
if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { |
|
168 |
return null; |
|
169 |
} |
|
170 |
DebugInfoReadStream stream = streamAt(decodeOffset); |
|
171 |
int length = stream.readInt(); |
|
172 |
List res = new ArrayList(length); |
|
173 |
for (int i = 0; i < length; i++) { |
|
174 |
res.add(ScopeValue.readFrom(stream)); |
|
175 |
} |
|
176 |
return res; |
|
177 |
} |
|
178 |
||
179 |
/** Returns a List<MonitorValue> or null if no values were present */ |
|
180 |
private List decodeMonitorValues(int decodeOffset) { |
|
181 |
if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { |
|
182 |
return null; |
|
183 |
} |
|
184 |
DebugInfoReadStream stream = streamAt(decodeOffset); |
|
185 |
int length = stream.readInt(); |
|
186 |
List res = new ArrayList(length); |
|
187 |
for (int i = 0; i < length; i++) { |
|
188 |
res.add(new MonitorValue(stream)); |
|
189 |
} |
|
190 |
return res; |
|
191 |
} |
|
3171
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
192 |
|
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
193 |
/** Returns a List<ObjectValue> or null if no values were present */ |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
194 |
private List decodeObjectValues(int decodeOffset) { |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
195 |
if (decodeOffset == DebugInformationRecorder.SERIALIZED_NULL) { |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
196 |
return null; |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
197 |
} |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
198 |
List res = new ArrayList(); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
199 |
DebugInfoReadStream stream = new DebugInfoReadStream(code, decodeOffset, res); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
200 |
int length = stream.readInt(); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
201 |
for (int i = 0; i < length; i++) { |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
202 |
// Objects values are pushed to 'res' array during read so that |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
203 |
// object's fields could reference it (OBJECT_ID_CODE). |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
204 |
ScopeValue.readFrom(stream); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
205 |
// res.add(ScopeValue.readFrom(stream)); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
206 |
} |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
207 |
Assert.that(res.size() == length, "inconsistent debug information"); |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
208 |
return res; |
aa289b22b577
6837472: com/sun/jdi/MonitorFrameInfo.java fails with AggressiveOpts in 6u14
kvn
parents:
1
diff
changeset
|
209 |
} |
1 | 210 |
} |