Skip to content

Commit

Permalink
debuginfotest: Move main to the end of the file
Browse files Browse the repository at this point in the history
This way we can add methods on top of main without affecting
significantly the linenumbers in testhello.py
  • Loading branch information
zakkak committed Jun 27, 2023
1 parent 5d78bdd commit 7b9b353
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 40 deletions.
20 changes: 10 additions & 10 deletions substratevm/mx.substratevm/testhello.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ def test():
checker.check(exec_string)

# set a break point at hello.Hello::main
# expect "Breakpoint 1 at 0x[0-9a-f]+: file hello.Hello.java, line 77."
# expect "Breakpoint 1 at 0x[0-9a-f]+: file hello.Hello.java, line 244."
exec_string = execute("break hello.Hello::main")
rexp = r"Breakpoint 1 at %s: file hello/Hello\.java, line 77\."%address_pattern
rexp = r"Breakpoint 1 at %s: file hello/Hello\.java, line 244\."%address_pattern
checker = Checker('break main', rexp)
checker.check(exec_string)

Expand All @@ -110,16 +110,16 @@ def test():
execute("delete breakpoints")

# list the line at the breakpoint
# expect "77 Greeter greeter = Greeter.greeter(args);"
# expect "244 Greeter greeter = Greeter.greeter(args);"
exec_string = execute("list")
checker = Checker(r"list bp 1", "77%sGreeter greeter = Greeter\.greeter\(args\);"%spaces_pattern)
checker = Checker(r"list bp 1", "244%sGreeter greeter = Greeter\.greeter\(args\);"%spaces_pattern)
checker.check(exec_string, skip_fails=False)

# run a backtrace
# expect "#0 hello.Hello.main(java.lang.String[] *).* at hello.Hello.java:77"
# expect "#0 hello.Hello.main(java.lang.String[] *).* at hello.Hello.java:244"
# 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")
stacktraceRegex = [r"#0%shello\.Hello::main%s %s at hello/Hello\.java:77"%(spaces_pattern, param_types_pattern, arg_values_pattern),
stacktraceRegex = [r"#0%shello\.Hello::main%s %s at hello/Hello\.java:244"%(spaces_pattern, param_types_pattern, arg_values_pattern),
r"#1%s%s in com\.oracle\.svm\.core\.JavaMainWrapper::invokeMain%s %s at %sJavaMainWrapper\.java:[0-9]+"%(spaces_pattern, address_pattern, param_types_pattern, arg_values_pattern, package_pattern),
r"#2%s(%s in )?com\.oracle\.svm\.core\.JavaMainWrapper::runCore0%s %s at %sJavaMainWrapper\.java:[0-9]+"%(spaces_pattern, address_pattern, no_param_types_pattern, no_arg_values_pattern, package_pattern),
r"#3%s%s in com\.oracle\.svm\.core\.JavaMainWrapper::runCore%s %s at %sJavaMainWrapper\.java:[0-9]+"%(spaces_pattern, address_pattern, no_param_types_pattern, no_arg_values_pattern, package_pattern),
Expand Down Expand Up @@ -372,7 +372,7 @@ def test():
# run a backtrace
exec_string = execute("backtrace")
stacktraceRegex = [r"#0%shello\.Hello\$Greeter::greeter%s %s at hello/Hello\.java:38"%(spaces_pattern, param_types_pattern, arg_values_pattern),
r"#1%s%s in hello\.Hello::main%s %s at hello/Hello\.java:77"%(spaces_pattern, address_pattern, param_types_pattern, arg_values_pattern),
r"#1%s%s in hello\.Hello::main%s %s at hello/Hello\.java:244"%(spaces_pattern, address_pattern, param_types_pattern, arg_values_pattern),
r"#2%s%s in com\.oracle\.svm\.core\.JavaMainWrapper::invokeMain%s %s at %sJavaMainWrapper\.java:[0-9]+"%(spaces_pattern, address_pattern, param_types_pattern, arg_values_pattern, package_pattern),
r"#3%s(%s in )?com\.oracle\.svm\.core\.JavaMainWrapper::runCore0%s %s at %sJavaMainWrapper\.java:[0-9]+"%(spaces_pattern, address_pattern, no_param_types_pattern, no_arg_values_pattern, package_pattern),
r"#4%s%s in com\.oracle\.svm\.core\.JavaMainWrapper::runCore%s %s at %sJavaMainWrapper\.java:[0-9]+"%(spaces_pattern, address_pattern, no_param_types_pattern, no_arg_values_pattern, package_pattern),
Expand Down Expand Up @@ -796,9 +796,9 @@ def test():
execute("delete breakpoints");

### Now check foreign debug type info

# check type information is reported correctly

exec_string=execute("info types com.oracle.svm.test.debug.CStructTests\$")
rexp = [r"%stypedef composite_struct \* com\.oracle\.svm\.test\.debug\.CStructTests\$CompositeStruct;"%spaces_pattern,
r"%stypedef int32_t \* com\.oracle\.svm\.test\.debug\.CStructTests\$MyCIntPointer;"%spaces_pattern,
Expand Down Expand Up @@ -852,7 +852,7 @@ def test():


# check foreign data is printed correctly if we can

if can_print_data:
# set a break point at com.oracle.svm.test.debug.CStructTests::free
exec_string = execute("break com.oracle.svm.test.debug.CStructTests::free")
Expand Down
63 changes: 33 additions & 30 deletions substratevm/src/com.oracle.svm.test/src/hello/Hello.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,36 +73,6 @@ public void greet() {
}
}

public static void main(String[] args) {
Greeter greeter = Greeter.greeter(args);
greeter.greet();
/*-
* Perform the following call chains
*
* main --no-inline--> noInlineFoo --inline--> inlineMee --inline--> inlineMoo
* main --inline--> inlineCallChain --inline--> inlineMee --inline--> inlineMoo
* main --no-inline--> noInlineThis --inline--> inlineIs --inline--> inlineA --no-inline--> noInlineTest
* main --inline--> inlineFrom --no-inline--> noInlineHere --inline--> inlineMixTo --no-inline--+
* ^ |
* +-------------(rec call n-times)-------------+
* main --inline--> inlineFrom --inline--> inlineHere --inline--> inlineTo --inline--+
* ^ |
* +---------(rec call n-times)----------+
*/
noInlineFoo();
inlineCallChain();
noInlineThis();
inlineFrom();
noInlineManyArgs(0, 1, 2, 3, true, 5, 6, 7, 8, 9,
0.0F, 1.125F, 2.25F, 3.375F, 4.5F, 5.625F, 6.75F, 7.875F, 9.0F, 10.125D, false, 12.375F);
noInlinePassConstants();
// create and manipulate some foreign types
CStructTests tests = new CStructTests();
tests.composite();
tests.weird();
System.exit(0);
}

@NeverInline("For testing purposes")
private static void noInlineFoo() {
inlineMee();
Expand Down Expand Up @@ -236,4 +206,37 @@ private static void inlineReceiveConstants(byte b, int i, long l, String s, floa
}

final static java.util.function.Supplier<String> lambda = () -> "lambdaText";

/* Add new methods above main */
public static void main(String[] args) {
Greeter greeter = Greeter.greeter(args);
greeter.greet();
/*-
* Perform the following call chains
*
* main --no-inline--> noInlineFoo --inline--> inlineMee --inline--> inlineMoo
* main --inline--> inlineCallChain --inline--> inlineMee --inline--> inlineMoo
* main --no-inline--> noInlineThis --inline--> inlineIs --inline--> inlineA --no-inline--> noInlineTest
* main --inline--> inlineFrom --no-inline--> noInlineHere --inline--> inlineMixTo --no-inline--+
* ^ |
* +-------------(rec call n-times)-------------+
* main --inline--> inlineFrom --inline--> inlineHere --inline--> inlineTo --inline--+
* ^ |
* +---------(rec call n-times)----------+
*/
noInlineFoo();
inlineCallChain();
noInlineThis();
inlineFrom();
noInlineManyArgs(0, 1, 2, 3, true, 5, 6, 7, 8, 9,
0.0F, 1.125F, 2.25F, 3.375F, 4.5F, 5.625F, 6.75F, 7.875F, 9.0F, 10.125D, false, 12.375F);
noInlinePassConstants();
// create and manipulate some foreign types
CStructTests tests = new CStructTests();
tests.composite();
tests.weird();
System.exit(0);
}
/* Keep main the last method in the file and add new methods right above it to avoid updating all line numbers
in testhello.py each time new methods are added */
}

0 comments on commit 7b9b353

Please sign in to comment.