Mercurial > hg > truffle
annotate agent/src/share/classes/sun/jvm/hotspot/jdi/LocationImpl.java @ 6972:bd7a7ce2e264
6830717: replay of compilations would help with debugging
Summary: When java process crashed in compiler thread, repeat the compilation process will help finding root cause. This is done with using SA dump application class data and replay data from core dump, then use debug version of jvm to recompile the problematic java method.
Reviewed-by: kvn, twisti, sspitsyn
Contributed-by: yumin.qi@oracle.com
author | minqi |
---|---|
date | Mon, 12 Nov 2012 14:03:53 -0800 |
parents | 37be97a58393 |
children |
rev | line source |
---|---|
0 | 1 /* |
2471
37be97a58393
7010849: 5/5 Extraneous javac source/target options when building sa-jdi
andrew
parents:
1552
diff
changeset
|
2 * Copyright (c) 2002, 2011, 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.jdi; | |
26 | |
27 import com.sun.jdi.*; | |
28 | |
29 import java.util.*; | |
30 | |
31 public class LocationImpl extends MirrorImpl implements Location { | |
32 private final ReferenceTypeImpl declaringType; | |
33 private Method method; | |
34 private sun.jvm.hotspot.oops.Method methodRef; | |
35 private long codeIndex; | |
36 private LineInfo baseLineInfo = null; | |
37 private LineInfo otherLineInfo = null; | |
38 | |
39 LocationImpl(VirtualMachine vm, | |
40 Method method, long codeIndex) { | |
41 super(vm); | |
42 | |
43 this.method = method; | |
44 this.codeIndex = method.isNative()? -1 : codeIndex; | |
45 this.declaringType = (ReferenceTypeImpl)method.declaringType(); | |
46 } | |
47 | |
48 /* | |
49 * This constructor allows lazy creation of the method mirror. This | |
50 * can be a performance savings if the method mirror does not yet | |
51 * exist. | |
52 */ | |
53 LocationImpl(VirtualMachine vm, ReferenceType declaringType, | |
54 sun.jvm.hotspot.oops.Method methodRef, long codeIndex) { | |
55 super(vm); | |
56 | |
57 this.method = null; | |
58 this.codeIndex = codeIndex; | |
59 this.declaringType = (ReferenceTypeImpl)declaringType; | |
60 this.methodRef = methodRef; | |
61 } | |
62 | |
63 public boolean equals(Object obj) { | |
64 if ((obj != null) && (obj instanceof Location)) { | |
65 Location other = (Location)obj; | |
66 return (method().equals(other.method())) && | |
67 (codeIndex() == other.codeIndex()) && | |
68 super.equals(obj); | |
69 } else { | |
70 return false; | |
71 } | |
72 } | |
73 | |
74 public int hashCode() { | |
75 /* | |
76 * TO DO: better hash code? | |
77 */ | |
78 return method().hashCode() + (int)codeIndex(); | |
79 } | |
80 | |
2471
37be97a58393
7010849: 5/5 Extraneous javac source/target options when building sa-jdi
andrew
parents:
1552
diff
changeset
|
81 public int compareTo(Location other) { |
0 | 82 int rc = method().compareTo(other.method()); |
83 if (rc == 0) { | |
84 long diff = codeIndex() - other.codeIndex(); | |
85 if (diff < 0) | |
86 return -1; | |
87 else if (diff > 0) | |
88 return 1; | |
89 else | |
90 return 0; | |
91 } | |
92 return rc; | |
93 } | |
94 | |
95 public ReferenceType declaringType() { | |
96 return declaringType; | |
97 } | |
98 | |
99 public Method method() { | |
100 if (method == null) { | |
101 method = declaringType.getMethodMirror(methodRef); | |
102 if (method.isNative()) { | |
103 codeIndex = -1; | |
104 } | |
105 } | |
106 return method; | |
107 } | |
108 | |
109 public long codeIndex() { | |
110 method(); // be sure information is up-to-date | |
111 return codeIndex; | |
112 } | |
113 | |
114 LineInfo getBaseLineInfo(SDE.Stratum stratum) { | |
115 LineInfo lineInfo; | |
116 | |
117 /* check if there is cached info to use */ | |
118 if (baseLineInfo != null) { | |
119 return baseLineInfo; | |
120 } | |
121 | |
122 /* compute the line info */ | |
123 MethodImpl methodImpl = (MethodImpl)method(); | |
124 lineInfo = methodImpl.codeIndexToLineInfo(stratum, | |
125 codeIndex()); | |
126 | |
127 /* cache it */ | |
128 addBaseLineInfo(lineInfo); | |
129 | |
130 return lineInfo; | |
131 } | |
132 | |
133 LineInfo getLineInfo(SDE.Stratum stratum) { | |
134 LineInfo lineInfo; | |
135 | |
136 /* base stratum is done slighly differently */ | |
137 if (stratum.isJava()) { | |
138 return getBaseLineInfo(stratum); | |
139 } | |
140 | |
141 /* check if there is cached info to use */ | |
142 lineInfo = otherLineInfo; // copy because of concurrency | |
143 if (lineInfo != null && | |
144 stratum.id().equals(lineInfo.liStratum())) { | |
145 return lineInfo; | |
146 } | |
147 int baseLineNumber = lineNumber(SDE.BASE_STRATUM_NAME); | |
148 SDE.LineStratum lineStratum = | |
149 stratum.lineStratum(declaringType, baseLineNumber); | |
150 | |
151 if (lineStratum != null && lineStratum.lineNumber() != -1) { | |
152 lineInfo = new StratumLineInfo(stratum.id(), | |
153 lineStratum.lineNumber(), | |
154 lineStratum.sourceName(), | |
155 lineStratum.sourcePath()); | |
156 } else { | |
157 /* find best match */ | |
158 MethodImpl methodImpl = (MethodImpl)method(); | |
159 lineInfo = methodImpl.codeIndexToLineInfo(stratum, | |
160 codeIndex()); | |
161 } | |
162 | |
163 /* cache it */ | |
164 addStratumLineInfo(lineInfo); | |
165 | |
166 return lineInfo; | |
167 } | |
168 | |
169 void addStratumLineInfo(LineInfo lineInfo) { | |
170 otherLineInfo = lineInfo; | |
171 } | |
172 | |
173 void addBaseLineInfo(LineInfo lineInfo) { | |
174 baseLineInfo = lineInfo; | |
175 } | |
176 | |
177 public String sourceName() throws AbsentInformationException { | |
178 return sourceName(vm.getDefaultStratum()); | |
179 } | |
180 | |
181 public String sourceName(String stratumID) | |
182 throws AbsentInformationException { | |
183 return sourceName(declaringType.stratum(stratumID)); | |
184 } | |
185 | |
186 String sourceName(SDE.Stratum stratum) | |
187 throws AbsentInformationException { | |
188 return getLineInfo(stratum).liSourceName(); | |
189 } | |
190 | |
191 public String sourcePath() throws AbsentInformationException { | |
192 return sourcePath(vm.getDefaultStratum()); | |
193 } | |
194 | |
195 public String sourcePath(String stratumID) | |
196 throws AbsentInformationException { | |
197 return sourcePath(declaringType.stratum(stratumID)); | |
198 } | |
199 | |
200 String sourcePath(SDE.Stratum stratum) | |
201 throws AbsentInformationException { | |
202 return getLineInfo(stratum).liSourcePath(); | |
203 } | |
204 | |
205 public int lineNumber() { | |
206 return lineNumber(vm.getDefaultStratum()); | |
207 } | |
208 | |
209 public int lineNumber(String stratumID) { | |
210 return lineNumber(declaringType.stratum(stratumID)); | |
211 } | |
212 | |
213 int lineNumber(SDE.Stratum stratum) { | |
214 return getLineInfo(stratum).liLineNumber(); | |
215 } | |
216 | |
217 public String toString() { | |
218 if (lineNumber() == -1) { | |
219 return method().toString() + "+" + codeIndex(); | |
220 } else { | |
221 return declaringType().name() + ":" + lineNumber(); | |
222 } | |
223 } | |
224 } |