Skip to content

Commit 0b665d3

Browse files
committed
Update FileEntry of MethodEntry in setInRange
If the MethodEntry was added by traversing the DeclaredMethods of a Class its fileEntry will point to the original source file, thus it will be wrong for substituted methods. As a result when setting a MethodEntry as isInRange we also make sure that its fileEntry reflects the file info associated with the corresponding Range.
1 parent e633b09 commit 0b665d3

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/ClassEntry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ public MethodEntry ensureMethodEntryForDebugRangeInfo(DebugRangeInfo debugRangeI
357357
MethodEntry methodEntry = methodIterator.next();
358358
int comparisonResult = methodEntry.compareTo(methodName, paramSignature, returnTypeName);
359359
if (comparisonResult == 0) {
360-
methodEntry.setInRange();
360+
methodEntry.setInRange(debugInfoBase, debugRangeInfo);
361361
return methodEntry;
362362
} else if (comparisonResult > 0) {
363363
methodIterator.previous();

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry/MethodEntry.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626

2727
package com.oracle.objectfile.debugentry;
2828

29+
import com.oracle.objectfile.debuginfo.DebugInfoProvider.DebugRangeInfo;
30+
31+
import java.nio.file.Path;
32+
2933
public class MethodEntry extends MemberEntry implements Comparable<MethodEntry> {
3034
final TypeEntry[] paramTypes;
3135
final String[] paramNames;
@@ -89,7 +93,21 @@ public boolean isInRange() {
8993
return isInRange;
9094
}
9195

92-
public void setInRange() {
96+
public void setInRange(DebugInfoBase debugInfoBase, DebugRangeInfo debugRangeInfo) {
97+
if (isInRange) {
98+
assert fileEntry == debugInfoBase.ensureFileEntry(debugRangeInfo.fileName(), debugRangeInfo.filePath(), debugRangeInfo.cachePath());
99+
return;
100+
}
101+
/*
102+
* If the MethodEntry was added by traversing the DeclaredMethods of a Class its fileEntry
103+
* will point to the original source file, thus it will be wrong for substituted methods. As
104+
* a result when setting a MethodEntry as isInRange we also make sure that its fileEntry
105+
* reflects the file info associated with the corresponding Range.
106+
*/
107+
String fileName = debugRangeInfo.fileName();
108+
Path filePath = debugRangeInfo.filePath();
109+
Path cachePath = debugRangeInfo.cachePath();
110+
fileEntry = debugInfoBase.ensureFileEntry(fileName, filePath, cachePath);
93111
isInRange = true;
94112
}
95113

0 commit comments

Comments
 (0)