Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 39 additions & 39 deletions substratevm/mx.substratevm/testhello.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def test():
wildcard_pattern = '.*'
# disable prompting to continue output
execute("set pagination off")
# set a break point at hello.Hello::main
# set a break point at hello.Hello.main
# expect "Breakpoint 1 at 0x[0-9a-f]+: file hello.Hello.java, line 67."
exec_string = execute("break hello.Hello::main")
exec_string = execute("break hello.Hello.main")
rexp = r"Breakpoint 1 at %s: file hello/Hello\.java, line 67\."%address_pattern
checker = Checker('break main', rexp)
checker.check(exec_string)
Expand All @@ -149,36 +149,36 @@ def test():
checker.check(exec_string, skip_fails=False)

# run a backtrace
# expect "#0 hello.Hello::main(java.lang.String[]).* at hello.Hello.java:67"
# expect "#1 0x[0-9a-f]+ in com.oracle.svm.core.code.IsolateEnterStub::JavaMainWrapper_run_.* at [a-z/]+/JavaMainWrapper.java:[0-9]+"
# expect "#0 hello.Hello.main(java.lang.String[]).* at hello.Hello.java:67"
# expect "#1 0x[0-9a-f]+ in com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_.* at [a-z/]+/JavaMainWrapper.java:[0-9]+"
exec_string = execute("backtrace")
checker = Checker("backtrace hello.Hello::main",
[r"#0%shello\.Hello::main\(java\.lang\.String\[\]\)%s at hello/Hello\.java:67"%(spaces_pattern, wildcard_pattern),
r"#1%s%s in com\.oracle\.svm\.core\.code\.IsolateEnterStub::JavaMainWrapper_run_%s at %sJavaMainWrapper\.java:[0-9]+"%(spaces_pattern, address_pattern, wildcard_pattern, package_pattern)
])
checker = Checker("backtrace hello.Hello.main",
[r"#0%shello\.Hello\.main\(java\.lang\.String\[\]\)%s at hello/Hello\.java:67"%(spaces_pattern, wildcard_pattern),
r"#1%s%s in com\.oracle\.svm\.core\.code\.IsolateEnterStub\.JavaMainWrapper_run_%s at %sJavaMainWrapper\.java:[0-9]+"%(spaces_pattern, address_pattern, wildcard_pattern, package_pattern)
])
checker.check(exec_string, skip_fails=False)

# look up PrintStream::println methods
# expect "All functions matching regular expression "java.io.PrintStream::println":"
# look up PrintStream.println methods
# expect "All functions matching regular expression "java.io.PrintStream.println":"
# expect ""
# expect "File java.base/java/io/PrintStream.java:"
# expect " void java.io.PrintStream::println(java.lang.Object)(void);"
# expect " void java.io.PrintStream::println(java.lang.String)(void);"
exec_string = execute("info func java.io.PrintStream::println")
# checker = Checker("info func java.io.PrintStream::println",
# ["All functions matching regular expression \"java\\.io\\.PrintStream::println\":",
# "",
# "File .*java/io/PrintStream.java:",
# "[ \t]*void java.io.PrintStream::println\\(java\\.lang\\.Object\\)\\(void\\);",
# "[ \t]*void java.io.PrintStream::println\\(java\\.lang\\.String\\)\\(void\\);",
# ])
checker = Checker("info func java.io.PrintStream::println",
r"%svoid java.io.PrintStream::println\(java\.lang\.String\)"%maybe_spaces_pattern)
# expect " void java.io.PrintStream.println(java.lang.Object)(void);"
# expect " void java.io.PrintStream.println(java.lang.String)(void);"
exec_string = execute("info func java.io.PrintStream.println")
# checker = Checker("info func java.io.PrintStream.println",
# ["All functions matching regular expression \"java\\.io\\.PrintStream\.println\":",
# "",
# "File .*java/io/PrintStream.java:",
# "[ \t]*void java.io.PrintStream\.println\\(java\\.lang\\.Object\\)\\(void\\);",
# "[ \t]*void java.io.PrintStream\.println\\(java\\.lang\\.String\\)\\(void\\);",
# ])
checker = Checker("info func java.io.PrintStream.println",
r"%svoid java.io.PrintStream\.println\(java\.lang\.String\)"%maybe_spaces_pattern)
checker.check(exec_string)

# set a break point at PrintStream::println(String)
# set a break point at PrintStream.println(String)
# expect "Breakpoint 2 at 0x[0-9a-f]+: java.base/java/io/PrintStream.java, line [0-9]+."
exec_string = execute("break java.io.PrintStream::println(java.lang.String)")
exec_string = execute("break java.io.PrintStream.println(java.lang.String)")
rexp = r"Breakpoint 2 at %s: file .*java/io/PrintStream\.java, line %s\."%(address_pattern, digits_pattern)
checker = Checker('break println', rexp)
checker.check(exec_string, skip_fails=False)
Expand All @@ -190,28 +190,28 @@ def test():
# expect "34 if (args.length == 0) {"
exec_string = execute("list")
rexp = r"34%sif \(args\.length == 0\) {"%spaces_pattern
checker = Checker('list hello.Hello.Greeter::greeter', rexp)
checker = Checker('list hello.Hello.Greeter.greeter', rexp)
checker.check(exec_string, skip_fails=False)

# run a backtrace
# expect "#0 hello.Hello.greeter::greeter(java.lang.String[]).* at hello.Hello.java:34"
# expect "#1 0x[0-9a-f]+ in hello.Hello::main(java.lang.String[]).* at hello.Hello.java:67"
# expect "#2 0x[0-9a-f]+ in com.oracle.svm.core.code.IsolateEnterStub::JavaMainWrapper_run_.* at [a-z/]+/JavaMainWrapper.java:[0-9]+"
# expect "#0 hello.Hello.greeter.greeter(java.lang.String[]).* at hello.Hello.java:34"
# expect "#1 0x[0-9a-f]+ in hello.Hello.main(java.lang.String[]).* at hello.Hello.java:67"
# expect "#2 0x[0-9a-f]+ in com.oracle.svm.core.code.IsolateEnterStub.JavaMainWrapper_run_.* at [a-z/]+/JavaMainWrapper.java:[0-9]+"
exec_string = execute("backtrace")
checker = Checker("backtrace hello.Hello.Greeter::greeter",
[r"#0%shello\.Hello\.Greeter::greeter\(java\.lang\.String\[\]\)%s at hello/Hello\.java:34"%(spaces_pattern, wildcard_pattern),
r"#1%s%s in hello\.Hello::main\(java\.lang\.String\[\]\)%s at hello/Hello\.java:67"%(spaces_pattern, address_pattern, wildcard_pattern),
r"#2%s%s in com\.oracle\.svm\.core\.code\.IsolateEnterStub::JavaMainWrapper_run_%s at [a-z/]+/JavaMainWrapper\.java:%s"%(spaces_pattern, address_pattern, wildcard_pattern, digits_pattern)
])
checker = Checker("backtrace hello.Hello.Greeter.greeter",
[r"#0%shello\.Hello\.Greeter\.greeter\(java\.lang\.String\[\]\)%s at hello/Hello\.java:34"%(spaces_pattern, wildcard_pattern),
r"#1%s%s in hello\.Hello\.main\(java\.lang\.String\[\]\)%s at hello/Hello\.java:67"%(spaces_pattern, address_pattern, wildcard_pattern),
r"#2%s%s in com\.oracle\.svm\.core\.code\.IsolateEnterStub\.JavaMainWrapper_run_%s at [a-z/]+/JavaMainWrapper\.java:%s"%(spaces_pattern, address_pattern, wildcard_pattern, digits_pattern)
])
checker.check(exec_string, skip_fails=False)

# now step into inlined code
execute("next")

# check we are still in hello.Hello.Greeter::greeter but no longer in hello.Hello.java
# check we are still in hello.Hello.Greeter.greeter but no longer in hello.Hello.java
exec_string = execute("backtrace 1")
checker = Checker("backtrace inline",
[r"#0%shello\.Hello\.Greeter::greeter\(java\.lang\.String\[\]\)%s at (%s):%s"%(spaces_pattern, wildcard_pattern, package_file_pattern, digits_pattern)])
[r"#0%shello\.Hello\.Greeter\.greeter\(java\.lang\.String\[\]\)%s at (%s):%s"%(spaces_pattern, wildcard_pattern, package_file_pattern, digits_pattern)])
matches = checker.check(exec_string, skip_fails=False)
# n.b. can only get back here with one match
match = matches[0]
Expand All @@ -224,11 +224,11 @@ def test():
# continue to next breakpoint
execute("continue")

# run backtrace to check we are in java.io.PrintStream::println(java.lang.String)
# expect "#0 java.io.PrintStream::println(java.lang.String).* at java.base/java/io/PrintStream.java:[0-9]+"
# run backtrace to check we are in java.io.PrintStream.println(java.lang.String)
# expect "#0 java.io.PrintStream.println(java.lang.String).* at java.base/java/io/PrintStream.java:[0-9]+"
exec_string = execute("backtrace 1")
checker = Checker("backtrace 1 PrintStream::println",
[r"#0%sjava\.io\.PrintStream::println\(java\.lang\.String\)%s at %sjava/io/PrintStream.java:%s"%(spaces_pattern, wildcard_pattern, wildcard_pattern, digits_pattern)])
checker = Checker("backtrace 1 PrintStream.println",
[r"#0%sjava\.io\.PrintStream\.println\(java\.lang\.String\)%s at %sjava/io/PrintStream.java:%s"%(spaces_pattern, wildcard_pattern, wildcard_pattern, digits_pattern)])
checker.check(exec_string, skip_fails=False)

# list current line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ public enum RelocationKind {
DIRECT_2,
DIRECT_4,
DIRECT_8,
/**
* The index of the object file section containing the relocation's symbol supplies the
* fixup bytes. (used in CodeView debug information)
*/
SECTION_2,
/**
* The address of the object file section containing the relocation's symbol (plus addend)
* supplies the fixup bytes. (used in CodeView debug information)
*/
SECREL_4,
/**
* The relocation's symbol provides an address whose PC-relative value (plus addend)
* supplies the fixup bytes.
Expand Down Expand Up @@ -325,9 +335,11 @@ public static int getRelocationSize(RelocationKind kind) {
return 1;
case DIRECT_2:
case PC_RELATIVE_2:
case SECTION_2:
return 2;
case DIRECT_4:
case PC_RELATIVE_4:
case SECREL_4:
return 4;
case DIRECT_8:
case PC_RELATIVE_8:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
// switch '$' in class names for '.'
String className = debugCodeInfo.className().replaceAll("\\$", ".");
String methodName = debugCodeInfo.methodName();
String symbolName = debugCodeInfo.symbolNameForMethod();
String paramNames = debugCodeInfo.paramNames();
String returnTypeName = debugCodeInfo.returnTypeName();
int lo = debugCodeInfo.addressLo();
int hi = debugCodeInfo.addressHi();
int primaryLine = debugCodeInfo.line();
boolean isDeoptTarget = debugCodeInfo.isDeoptTarget();

Range primaryRange = new Range(fileName, filePath, cachePath, className, methodName, paramNames, returnTypeName, stringTable, lo, hi, primaryLine, isDeoptTarget);
Range primaryRange = new Range(fileName, filePath, cachePath, className, methodName, symbolName, paramNames, returnTypeName, stringTable, lo, hi, primaryLine, isDeoptTarget);
debugContext.log(DebugContext.INFO_LEVEL, "PrimaryRange %s.%s %s %s:%d [0x%x, 0x%x]", className, methodName, filePath, fileName, primaryLine, lo, hi);
addRange(primaryRange, debugCodeInfo.getFrameSizeChanges(), debugCodeInfo.getFrameSize());
debugCodeInfo.lineInfoProvider().forEach(debugLineInfo -> {
Expand All @@ -149,6 +150,7 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
// Switch '$' in class names for '.'
String classNameAtLine = debugLineInfo.className().replaceAll("\\$", ".");
String methodNameAtLine = debugLineInfo.methodName();
String symbolNameAtLine = debugLineInfo.symbolNameForMethod();
int loAtLine = lo + debugLineInfo.addressLo();
int hiAtLine = lo + debugLineInfo.addressHi();
int line = debugLineInfo.line();
Expand All @@ -157,7 +159,8 @@ public void installDebugInfo(DebugInfoProvider debugInfoProvider) {
* Record all subranges even if they have no line or file so we at least get a
* symbol for them.
*/
Range subRange = new Range(fileNameAtLine, filePathAtLine, cachePathAtLine, classNameAtLine, methodNameAtLine, "", "", stringTable, loAtLine, hiAtLine, line, primaryRange);
Range subRange = new Range(fileNameAtLine, filePathAtLine, cachePathAtLine, classNameAtLine, methodNameAtLine, symbolNameAtLine, "", "", stringTable, loAtLine, hiAtLine, line,
primaryRange);
addSubRange(primaryRange, subRange);
try (DebugContext.Scope s = debugContext.scope("Subranges")) {
debugContext.log(DebugContext.VERBOSE_LEVEL, "SubRange %s.%s %s %s:%d 0x%x, 0x%x]", classNameAtLine, methodNameAtLine, filePathAtLine, fileNameAtLine, line, loAtLine, hiAtLine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public String getPathName() {
}

public String getFullName() {
return getDirEntry().getPath().resolve(getFileName()).toString();
return getDirEntry() != null ? getDirEntry().getPath().resolve(getFileName()).toString() : getFileName();
}

/**
Expand All @@ -68,4 +68,14 @@ public DirEntry getDirEntry() {
public String getCachePath() {
return cachePath;
}

@Override
public String toString() {
if (getDirEntry() == null) {
return getFileName() == null ? "-" : getFileName();
} else if (getFileName() == null) {
return "--";
}
return String.format("FileEntry(%s)", getFullName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,15 @@
*/

public class Range {

private static final String CLASS_DELIMITER = ".";

private final String cachePath;
private String fileName;
private Path filePath;
private String className;
private String methodName;
private String symbolName;
private String paramNames;
private String returnTypeName;
private String fullMethodName;
Expand All @@ -56,24 +60,24 @@ public class Range {
/*
* Create a primary range.
*/
public Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String paramNames, String returnTypeName, StringTable stringTable, int lo, int hi, int line,
boolean isDeoptTarget) {
this(fileName, filePath, cachePath, className, methodName, paramNames, returnTypeName, stringTable, lo, hi, line, isDeoptTarget, null);
public Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String symbolName, String paramNames, String returnTypeName, StringTable stringTable, int lo,
int hi, int line, boolean isDeoptTarget) {
this(fileName, filePath, cachePath, className, methodName, symbolName, paramNames, returnTypeName, stringTable, lo, hi, line, isDeoptTarget, null);
}

/*
* Create a secondary range.
*/
public Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String paramNames, String returnTypeName, StringTable stringTable, int lo, int hi, int line,
Range primary) {
this(fileName, filePath, cachePath, className, methodName, paramNames, returnTypeName, stringTable, lo, hi, line, false, primary);
public Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String symbolName, String paramNames, String returnTypeName, StringTable stringTable, int lo,
int hi, int line, Range primary) {
this(fileName, filePath, cachePath, className, methodName, symbolName, paramNames, returnTypeName, stringTable, lo, hi, line, false, primary);
}

/*
* Create a primary or secondary range.
*/
private Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String paramNames, String returnTypeName, StringTable stringTable, int lo, int hi, int line,
boolean isDeoptTarget, Range primary) {
private Range(String fileName, Path filePath, Path cachePath, String className, String methodName, String symbolName, String paramNames, String returnTypeName, StringTable stringTable, int lo,
int hi, int line, boolean isDeoptTarget, Range primary) {
/*
* Currently file name and full method name need to go into the debug_str section other
* strings just need to be deduplicated to save space.
Expand All @@ -83,6 +87,7 @@ private Range(String fileName, Path filePath, Path cachePath, String className,
this.cachePath = (cachePath == null ? "" : stringTable.uniqueDebugString(cachePath.toString()));
this.className = stringTable.uniqueString(className);
this.methodName = stringTable.uniqueString(methodName);
this.symbolName = stringTable.uniqueString(symbolName);
this.paramNames = stringTable.uniqueString(paramNames);
this.returnTypeName = stringTable.uniqueString(returnTypeName);
this.fullMethodName = stringTable.uniqueDebugString(constructClassAndMethodNameWithParams());
Expand Down Expand Up @@ -131,6 +136,10 @@ public String getMethodName() {
return methodName;
}

public String getSymbolName() {
return symbolName;
}

public int getHi() {
return hi;
}
Expand All @@ -151,6 +160,14 @@ public boolean isDeoptTarget() {
return isDeoptTarget;
}

public String getParamNames() {
return paramNames;
}

public String getClassAndMethodName() {
return getExtendedMethodName(false, false);
}

private String getExtendedMethodName(boolean includeParams, boolean includeReturnType) {
StringBuilder builder = new StringBuilder();
if (includeReturnType && returnTypeName.length() > 0) {
Expand All @@ -159,7 +176,7 @@ private String getExtendedMethodName(boolean includeParams, boolean includeRetur
}
if (className != null) {
builder.append(className);
builder.append("::");
builder.append(CLASS_DELIMITER);
}
builder.append(methodName);
if (includeParams && !paramNames.isEmpty()) {
Expand All @@ -180,4 +197,9 @@ private String constructClassAndMethodNameWithParams() {
public String getCachePath() {
return cachePath;
}

@Override
public String toString() {
return String.format("Range(lo=0x%05x hi=0x%05x %s %s:%d)", lo, hi, constructClassAndMethodNameWithParams(), getFileAsPath(), line);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public StringTable() {
* Ensures a unique instance of a string exists in the table, inserting the supplied String if
* no equivalent String is already present. This should only be called before the string section
* has been written.
*
*
* @param string the string to be included in the table
* @return the unique instance of the String
*/
Expand All @@ -58,7 +58,7 @@ public String uniqueString(String string) {
* Ensures a unique instance of a string exists in the table and is marked for inclusion in the
* debug_str section, inserting the supplied String if no equivalent String is already present.
* This should only be called before the string section has been written.
*
*
* @param string the string to be included in the table and marked for inclusion in the
* debug_str section
* @return the unique instance of the String
Expand All @@ -82,7 +82,7 @@ private String ensureString(String string, boolean addToStrSection) {
/**
* Retrieves the offset at which a given string was written into the debug_str section. This
* should only be called after the string section has been written.
*
*
* @param string the strng whose offset is to be retrieved
* @return the offset or -1 if the string does not define an entry or the entry has not been
* written to the debug_str section
Expand Down
Loading