Skip to content

Commit d214f52

Browse files
committed
Fix debug info for substituted methods
1 parent 69de04b commit d214f52

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImageDebugInfoProvider.java

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,16 @@
3434
import java.util.function.Consumer;
3535
import java.util.stream.Stream;
3636

37+
import com.oracle.graal.pointsto.infrastructure.WrappedJavaMethod;
3738
import com.oracle.svm.core.SubstrateOptions;
39+
import com.oracle.svm.hosted.substitute.SubstitutionMethod;
3840
import org.graalvm.compiler.code.CompilationResult;
3941
import org.graalvm.compiler.code.SourceMapping;
4042
import org.graalvm.compiler.debug.DebugContext;
4143
import org.graalvm.compiler.graph.NodeSourcePosition;
4244
import org.graalvm.nativeimage.ImageSingletons;
4345

4446
import com.oracle.graal.pointsto.infrastructure.OriginalClassProvider;
45-
import com.oracle.graal.pointsto.meta.AnalysisType;
4647
import com.oracle.objectfile.debuginfo.DebugInfoProvider;
4748
import com.oracle.svm.core.graal.code.SubstrateBackend;
4849
import com.oracle.svm.hosted.image.sources.SourceManager;
@@ -310,22 +311,11 @@ public int line() {
310311

311312
@SuppressWarnings("try")
312313
private void computeFullFilePath() {
313-
ResolvedJavaType declaringClass = method.getDeclaringClass();
314+
ResolvedJavaType declaringClass = getDeclaringClass();
314315
Class<?> clazz = null;
315316
if (declaringClass instanceof OriginalClassProvider) {
316317
clazz = ((OriginalClassProvider) declaringClass).getJavaClass();
317318
}
318-
/*
319-
* HostedType wraps an AnalysisType and both HostedType and AnalysisType punt calls to
320-
* getSourceFilename to the wrapped class so for consistency we need to do the path
321-
* lookup relative to the doubly unwrapped HostedType or singly unwrapped AnalysisType.
322-
*/
323-
if (declaringClass instanceof HostedType) {
324-
declaringClass = ((HostedType) declaringClass).getWrapped();
325-
}
326-
if (declaringClass instanceof AnalysisType) {
327-
declaringClass = ((AnalysisType) declaringClass).getWrapped();
328-
}
329319
SourceManager sourceManager = ImageSingletons.lookup(SourceManager.class);
330320
try (DebugContext.Scope s = debugContext.scope("DebugCodeInfo", declaringClass)) {
331321
fullFilePath = sourceManager.findAndCacheSource(declaringClass, clazz, debugContext);
@@ -334,6 +324,20 @@ private void computeFullFilePath() {
334324
}
335325
}
336326

327+
private ResolvedJavaType getDeclaringClass() {
328+
ResolvedJavaMethod wrappedMethod = method;
329+
while (wrappedMethod instanceof WrappedJavaMethod) {
330+
wrappedMethod = ((WrappedJavaMethod) wrappedMethod).getWrapped();
331+
}
332+
ResolvedJavaType declaringClass;
333+
if (wrappedMethod instanceof SubstitutionMethod) {
334+
declaringClass = ((SubstitutionMethod) wrappedMethod).getAnnotated().getDeclaringClass();
335+
} else {
336+
declaringClass = wrappedMethod.getDeclaringClass();
337+
}
338+
return declaringClass;
339+
}
340+
337341
}
338342

339343
/**

0 commit comments

Comments
 (0)