Skip to content

Commit 210f14d

Browse files
committed
Create subranges for nested inlined callers
1 parent 58a6c99 commit 210f14d

File tree

1 file changed

+37
-1
lines changed
  • substratevm/src/com.oracle.objectfile/src/com/oracle/objectfile/debugentry

1 file changed

+37
-1
lines changed

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,14 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
156156
int hiAtLine = lo + debugLineInfo.addressHi();
157157
int line = debugLineInfo.line();
158158
Path cachePathAtLine = debugLineInfo.cachePath();
159+
Range caller = addCallersSubRanges(debugLineInfo.getCaller(), primaryRange, debugContext);
159160
/*
160161
* Record all subranges even if they have no line or file so we at least get a
161162
* symbol for them.
162163
*/
163164
Range subRange = new Range(fileNameAtLine, filePathAtLine, cachePathAtLine, classNameAtLine,
164165
methodNameAtLine, paramNamesAtLine, returnTypeNameAtLine, stringTable, loAtLine, hiAtLine,
165-
line, isInlined, primaryRange, false, null);
166+
line, isInlined, primaryRange, false, caller);
166167
addSubRange(primaryRange, subRange);
167168
try (DebugContext.Scope s = debugContext.scope("Subranges")) {
168169
debugContext.log(DebugContext.VERBOSE_LEVEL, "SubRange %s.%s %s %s:%d 0x%x, 0x%x]", classNameAtLine, methodNameAtLine, filePathAtLine, fileNameAtLine, line, loAtLine, hiAtLine);
@@ -178,6 +179,41 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
178179
*/
179180
}
180181

182+
/**
183+
* Recursively creates the inlined caller subranges for nested inline subranges.
184+
*
185+
* @param lineInfo
186+
* @param primaryRange
187+
* @param debugContext
188+
* @return the subrange for {@code lineInfo} linked with all its caller subranges up to the primaryRange
189+
*/
190+
@SuppressWarnings("try")
191+
private Range addCallersSubRanges(DebugInfoProvider.DebugLineInfo lineInfo, Range primaryRange, DebugContext debugContext) {
192+
/* Don't process the root method, it is already added as the primary range */
193+
if (lineInfo == null || lineInfo.getCaller() == null) {
194+
return primaryRange;
195+
}
196+
Range caller = addCallersSubRanges(lineInfo.getCaller(), primaryRange, debugContext);
197+
final String fileName = lineInfo.fileName();
198+
final Path filePath = lineInfo.filePath();
199+
final Path cachePath = lineInfo.cachePath();
200+
final String className = lineInfo.className();
201+
final String methodName = lineInfo.methodName();
202+
final String paramNames = lineInfo.paramNames();
203+
final String returnTypeName = lineInfo.returnTypeName();
204+
final int lo = primaryRange.getLo() + lineInfo.addressLo();
205+
final int hi = primaryRange.getLo() + lineInfo.addressHi();
206+
final int line = lineInfo.line();
207+
Range subRange = new Range(fileName, filePath, cachePath, className, methodName, paramNames, returnTypeName,
208+
stringTable, lo, hi, line, true, primaryRange, true, caller);
209+
addSubRange(primaryRange, subRange);
210+
try (DebugContext.Scope s = debugContext.scope("Subranges")) {
211+
debugContext.log(DebugContext.VERBOSE_LEVEL, "SubRange %s.%s %s %s:%d 0x%x, 0x%x]",
212+
className, methodName, filePath, fileName, line, lo, hi);
213+
}
214+
return subRange;
215+
}
216+
181217
private ClassEntry ensureClassEntry(Range range) {
182218
String className = range.getClassName();
183219
/*

0 commit comments

Comments
 (0)