Skip to content

Commit 1d7670d

Browse files
Update tests, and add testing for hub type and values of type java.lang.Class
1 parent dcf2db1 commit 1d7670d

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

substratevm/mx.substratevm/testhello.py

Lines changed: 49 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
def test():
6363
# define some useful constants
64-
main_start = 216
64+
main_start = 221
6565
main_noinline = main_start + 17
6666
main_inlinefrom = main_start + 18
6767
match = match_gdb_version()
@@ -237,15 +237,15 @@ def test():
237237
# print the hub of the array and check it has a name field
238238
exec_string = execute("print /x *args->hub")
239239
rexp = [fr"{wildcard_pattern} = {{",
240-
fr"{spaces_pattern}<java.lang.Class> = {{" if isolates else None,
240+
fr"{spaces_pattern}<java.lang.Class> = {{",
241241
fr"{spaces_pattern}<java.lang.Object> = {{",
242242
fr"{spaces_pattern}<_objhdr> = {{",
243243
fr"{spaces_pattern}hub = {address_pattern}",
244244
fr"{spaces_pattern}idHash = {address_pattern}" if fixed_idhash_field else None,
245245
fr"{spaces_pattern}}}, <No data fields>}},",
246246
fr"{spaces_pattern}members of java\.lang\.Class:",
247247
fr"{spaces_pattern}name = {address_pattern},",
248-
fr"{spaces_pattern}}}, <No data fields>}}" if isolates else "}"]
248+
fr"{spaces_pattern}}}, <No data fields>}}"]
249249

250250
checker = Checker("print String[] hub", rexp)
251251

@@ -381,7 +381,7 @@ def test():
381381

382382
exec_string = execute("ptype _objhdr")
383383
rexp = [r"type = struct _objhdr {",
384-
fr"{spaces_pattern}{compressed_pattern if isolates else ''}java\.lang\.Class \*hub;",
384+
fr"{spaces_pattern}Encoded\$Dynamic\$Hub \*hub;",
385385
fr"{spaces_pattern}int idHash;" if fixed_idhash_field else None,
386386
r"}"]
387387

@@ -872,13 +872,56 @@ def test():
872872
exec_string = execute("backtrace 3")
873873
rexp = [
874874
fr"#0{spaces_pattern}hello\.Hello::lambda\$(static\$)?0{no_param_types_pattern} {no_arg_values_pattern} at hello/Hello\.java:210",
875-
fr"#1{spaces_pattern}{address_pattern} in hello\.Hello\$\$Lambda((\${digits_pattern}/0x)|(\$)|(\.0x|/0x))?{hex_digits_pattern}::get{wildcard_pattern} at hello/Hello\.java:238",
876-
fr"#2{spaces_pattern}hello\.Hello::main{param_types_pattern} {arg_values_pattern} at hello/Hello\.java:238"]
875+
fr"#1{spaces_pattern}{address_pattern} in hello\.Hello\$\$Lambda((\${digits_pattern}/0x)|(\$)|(\.0x|/0x))?{hex_digits_pattern}::get{wildcard_pattern} at hello/Hello\.java:243",
876+
fr"#2{spaces_pattern}hello\.Hello::main{param_types_pattern} {arg_values_pattern} at hello/Hello\.java:243"]
877877
checker = Checker('backtrace in lambda', rexp)
878878
checker.check(exec_string, skip_fails=False)
879879

880880
execute("delete breakpoints")
881881

882+
# check if java.lang.Class and the hub field is resolved correctly
883+
exec_string = execute(f"break hello.Hello::checkClassType")
884+
rexp = fr"Breakpoint {digits_pattern} at {address_pattern}: file hello/Hello\.java, line 216\."
885+
checker = Checker(fr"break hello.Hello::checkClassType", rexp)
886+
checker.check(exec_string)
887+
888+
execute("continue")
889+
exec_string = execute("print *clazz.name.value")
890+
rexp = [fr"{wildcard_pattern} = {{",
891+
fr"{spaces_pattern}<java\.lang\.Object> = {{",
892+
fr"{spaces_pattern}<_objhdr> = {{",
893+
fr"{spaces_pattern}hub = {address_pattern}",
894+
fr"{spaces_pattern}}}, <No data fields>}},",
895+
fr"{spaces_pattern}members of byte \[\]",
896+
fr"{spaces_pattern}len = 16,",
897+
fr"{spaces_pattern}data = {address_pattern}"]
898+
checker = Checker('print *clazz.name.value', rexp)
899+
checker.check(exec_string)
900+
901+
exec_string = execute("ptype clazz")
902+
rexp = [r"type = class java\.lang\.Class : public java\.lang\.Object {"]
903+
checker = Checker('ptype clazz', rexp)
904+
checker.check(exec_string)
905+
906+
exec_string = execute("print *clazz.hub.name.value")
907+
rexp = [fr"{wildcard_pattern} = {{",
908+
fr"{spaces_pattern}<java\.lang\.Object> = {{",
909+
fr"{spaces_pattern}<_objhdr> = {{",
910+
fr"{spaces_pattern}hub = {address_pattern}",
911+
fr"{spaces_pattern}}}, <No data fields>}},",
912+
fr"{spaces_pattern}members of byte \[\]",
913+
fr"{spaces_pattern}len = 15,",
914+
fr"{spaces_pattern}data = {address_pattern}"]
915+
checker = Checker('print *clazz.hub.name.value', rexp)
916+
checker.check(exec_string)
917+
918+
exec_string = execute("ptype clazz.hub")
919+
rexp = [r"type = class Encoded\$Dynamic\$Hub : public java\.lang\.Class {"]
920+
checker = Checker('ptype clazz.hub', rexp)
921+
checker.check(exec_string)
922+
923+
execute("delete breakpoints")
924+
882925
### Now check foreign debug type info
883926

884927
# check type information is reported correctly

substratevm/src/com.oracle.svm.test/src/hello/Hello.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ private static void inlineReceiveConstants(byte b, int i, long l, String s, floa
211211
return sb.toString();
212212
};
213213

214+
@NeverInline("For testing purposes")
215+
private static <T> void checkClassType(Class<T> clazz) {
216+
System.out.println("clazz = " + clazz);
217+
}
218+
214219
/* Add new methods above main */
215220
public static void main(String[] args) {
216221
Greeter greeter = Greeter.greeter(args);
@@ -236,6 +241,7 @@ public static void main(String[] args) {
236241
0.0F, 1.125F, 2.25F, 3.375F, 4.5F, 5.625F, 6.75F, 7.875F, 9.0F, 10.125D, false, 12.375F);
237242
noInlinePassConstants();
238243
System.out.println(lambda.get());
244+
checkClassType(String.class);
239245
// create and manipulate some foreign types
240246
CStructTests.composite();
241247
CStructTests.weird();

0 commit comments

Comments
 (0)