Skip to content

Commit 58d2bd0

Browse files
committed
DebugInfo: Augment Range with originalClassName
Till now Range included className which would return the original class name for substitution methods. E.g. if Foo.m was substituing Bar.n a range corresponding to Foo.m would return Bar as the className. This patch makes originalClassName return Bar and changes className to return Foo. OriginalClassName is used to produce the extended method name, e.g. Bar::m(argA) while the className is used to map classes to FileEntries. This change will essentially allow us to create Compilation Units for Substitution classes as well. Those Compilation Units will contain entries for the substitution methods, while the Compilation Units of the original class will contain the original methods.
1 parent 69de04b commit 58d2bd0

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
132132
Path cachePath = debugCodeInfo.cachePath();
133133
// switch '$' in class names for '.'
134134
String className = debugCodeInfo.className().replaceAll("\\$", ".");
135+
String originalClassName = debugCodeInfo.originalClassName().replaceAll("\\$", ".");
135136
String methodName = debugCodeInfo.methodName();
136137
String paramNames = debugCodeInfo.paramNames();
137138
String returnTypeName = debugCodeInfo.returnTypeName();
@@ -140,14 +141,15 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
140141
int primaryLine = debugCodeInfo.line();
141142
boolean isDeoptTarget = debugCodeInfo.isDeoptTarget();
142143

143-
Range primaryRange = new Range(fileName, filePath, cachePath, className, methodName, paramNames, returnTypeName, stringTable, lo, hi, primaryLine, isDeoptTarget);
144+
Range primaryRange = new Range(fileName, filePath, cachePath, className, originalClassName, methodName, paramNames, returnTypeName, stringTable, lo, hi, primaryLine, isDeoptTarget);
144145
debugContext.log(DebugContext.INFO_LEVEL, "PrimaryRange %s.%s %s %s:%d [0x%x, 0x%x]", className, methodName, filePath, fileName, primaryLine, lo, hi);
145146
addRange(primaryRange, debugCodeInfo.getFrameSizeChanges(), debugCodeInfo.getFrameSize());
146147
debugCodeInfo.lineInfoProvider().forEach(debugLineInfo -> {
147148
String fileNameAtLine = debugLineInfo.fileName();
148149
Path filePathAtLine = debugLineInfo.filePath();
149150
// Switch '$' in class names for '.'
150151
String classNameAtLine = debugLineInfo.className().replaceAll("\\$", ".");
152+
String originalClassNameAtLine = debugLineInfo.originalClassName().replaceAll("\\$", ".");
151153
String methodNameAtLine = debugLineInfo.methodName();
152154
int loAtLine = lo + debugLineInfo.addressLo();
153155
int hiAtLine = lo + debugLineInfo.addressHi();
@@ -157,7 +159,8 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
157159
* Record all subranges even if they have no line or file so we at least get a
158160
* symbol for them.
159161
*/
160-
Range subRange = new Range(fileNameAtLine, filePathAtLine, cachePathAtLine, classNameAtLine, methodNameAtLine, "", "", stringTable, loAtLine, hiAtLine, line, primaryRange);
162+
Range subRange = new Range(fileNameAtLine, filePathAtLine, cachePathAtLine, classNameAtLine, originalClassNameAtLine, methodNameAtLine, "", "", stringTable, loAtLine, hiAtLine, line,
163+
primaryRange);
161164
addSubRange(primaryRange, subRange);
162165
try (DebugContext.Scope s = debugContext.scope("Subranges")) {
163166
debugContext.log(DebugContext.VERBOSE_LEVEL, "SubRange %s.%s %s %s:%d 0x%x, 0x%x]", classNameAtLine, methodNameAtLine, filePathAtLine, fileNameAtLine, line, loAtLine, hiAtLine);

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public class Range {
4040
private String fileName;
4141
private Path filePath;
4242
private String className;
43+
private String originalClassName;
4344
private String methodName;
4445
private String paramNames;
4546
private String returnTypeName;
@@ -56,24 +57,24 @@ public class Range {
5657
/*
5758
* Create a primary range.
5859
*/
59-
public Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String paramNames, String returnTypeName, StringTable stringTable, int lo, int hi, int line,
60-
boolean isDeoptTarget) {
61-
this(fileName, filePath, cachePath, className, methodName, paramNames, returnTypeName, stringTable, lo, hi, line, isDeoptTarget, null);
60+
public Range(String fileName, Path filePath, Path cachePath, String className, String originalClassName, String methodName, String paramNames, String returnTypeName, StringTable stringTable,
61+
int lo, int hi, int line, boolean isDeoptTarget) {
62+
this(fileName, filePath, cachePath, className, originalClassName, methodName, paramNames, returnTypeName, stringTable, lo, hi, line, isDeoptTarget, null);
6263
}
6364

6465
/*
6566
* Create a secondary range.
6667
*/
67-
public Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String paramNames, String returnTypeName, StringTable stringTable, int lo, int hi, int line,
68-
Range primary) {
69-
this(fileName, filePath, cachePath, className, methodName, paramNames, returnTypeName, stringTable, lo, hi, line, false, primary);
68+
public Range(String fileName, Path filePath, Path cachePath, String className, String originalClassName, String methodName, String paramNames, String returnTypeName, StringTable stringTable,
69+
int lo, int hi, int line, Range primary) {
70+
this(fileName, filePath, cachePath, className, originalClassName, methodName, paramNames, returnTypeName, stringTable, lo, hi, line, false, primary);
7071
}
7172

7273
/*
7374
* Create a primary or secondary range.
7475
*/
75-
private Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String paramNames, String returnTypeName, StringTable stringTable, int lo, int hi, int line,
76-
boolean isDeoptTarget, Range primary) {
76+
private Range(String fileName, Path filePath, Path cachePath, String className, String originalClassName, String methodName, String paramNames, String returnTypeName, StringTable stringTable,
77+
int lo, int hi, int line, boolean isDeoptTarget, Range primary) {
7778
/*
7879
* Currently file name and full method name need to go into the debug_str section other
7980
* strings just need to be deduplicated to save space.
@@ -82,6 +83,7 @@ private Range(String fileName, Path filePath, Path cachePath, String className,
8283
this.filePath = filePath;
8384
this.cachePath = (cachePath == null ? "" : stringTable.uniqueDebugString(cachePath.toString()));
8485
this.className = stringTable.uniqueString(className);
86+
this.originalClassName = stringTable.uniqueString(originalClassName);
8587
this.methodName = stringTable.uniqueString(methodName);
8688
this.paramNames = stringTable.uniqueString(paramNames);
8789
this.returnTypeName = stringTable.uniqueString(returnTypeName);
@@ -157,8 +159,8 @@ private String getExtendedMethodName(boolean includeParams, boolean includeRetur
157159
builder.append(returnTypeName);
158160
builder.append(' ');
159161
}
160-
if (className != null) {
161-
builder.append(className);
162+
if (originalClassName != null) {
163+
builder.append(originalClassName);
162164
builder.append("::");
163165
}
164166
builder.append(methodName);

substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debuginfo/DebugInfoProvider.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ interface DebugCodeInfo {
7272
*/
7373
String className();
7474

75+
/**
76+
* @return the fully qualified name of the original class owning the compiled method. For
77+
* code segments not originating from substituted methods this should be identical
78+
* to {@link DebugCodeInfo#className()}.
79+
*/
80+
String originalClassName();
81+
7582
/**
7683
* @return the name of the compiled method including signature.
7784
*/
@@ -160,6 +167,13 @@ interface DebugLineInfo {
160167
*/
161168
String className();
162169

170+
/**
171+
* @return the fully qualified name of the original class owning the compiled method. For
172+
* code segments not originating from substituted methods this should be identical
173+
* to {@link DebugLineInfo#className()}.
174+
*/
175+
String originalClassName();
176+
163177
/**
164178
* @return the name of the outer or inlined method including signature.
165179
*/

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ public Path cachePath() {
152152

153153
@Override
154154
public String className() {
155+
return getDeclaringClass(method).getName();
156+
}
157+
158+
@Override
159+
public String originalClassName() {
155160
return javaType.toClassName();
156161
}
157162

@@ -281,6 +286,11 @@ public Path cachePath() {
281286

282287
@Override
283288
public String className() {
289+
return getDeclaringClass(method).getName();
290+
}
291+
292+
@Override
293+
public String originalClassName() {
284294
return method.format("%H");
285295
}
286296

0 commit comments

Comments
 (0)