Skip to content

Commit 2e89e8c

Browse files
Move debuginfotests into its own module.
This makes native image builds for debuginfo tests independent of svm tests. Make debuginfotests work with -O2.
1 parent f9fff9f commit 2e89e8c

22 files changed

+81
-69
lines changed

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -982,9 +982,9 @@ def _collector(x):
982982
raise Exception('Unexpected output: ' + str(actual_output) + " != " + str(expected_output))
983983

984984
def _debuginfotest(native_image, path, build_only, with_isolates_only, args):
985-
sourcepath = mx.project('com.oracle.svm.test').source_dirs()[0]
985+
sourcepath = mx.project('com.oracle.svm.test.debug').source_dirs()[0]
986986
# the header file for foreign types resides at the root of the
987-
# com.oracle.svm.test source tree
987+
# com.oracle.svm.test.debug source tree
988988
cincludepath = sourcepath
989989
for key, value in get_java_properties().items():
990990
args.append("-D" + key + "=" + value)
@@ -1012,7 +1012,7 @@ def build_debug_test(variant_name, image_name, extra_args):
10121012
# this is a non-layered build
10131013
env['debuginfotest_layered'] = 'no'
10141014

1015-
testhello_py = join(suite.dir, 'mx.substratevm', 'testhello.py')
1015+
testhello_py = join(sourcepath, 'gdb-tests', 'testhello.py')
10161016
testhello_args = [
10171017
# We do not want to step into class initializer, so initialize everything at build time.
10181018
'--initialize-at-build-time=hello',
@@ -1034,7 +1034,7 @@ def build_debug_test(variant_name, image_name, extra_args):
10341034

10351035

10361036
def _layereddebuginfotest(native_image, output_path, skip_base_layer, with_isolates_only, args):
1037-
sourcepath = mx.project('com.oracle.svm.test').source_dirs()[0]
1037+
sourcepath = mx.project('com.oracle.svm.test.debug').source_dirs()[0]
10381038
cincludepath = sourcepath
10391039

10401040
for key, value in get_java_properties().items():
@@ -1058,7 +1058,7 @@ def build_layer(layer_path, layer_args):
10581058
build_layer(base_layer_path, [
10591059
'-o', join(base_layer_path, base_layer_name),
10601060
] + svm_experimental_options([
1061-
f'-H:LayerCreate={base_layer_name}.nil,module=java.base,package=com.oracle.svm.test'
1061+
f'-H:LayerCreate={base_layer_name}.nil,module=java.base'
10621062
]))
10631063

10641064
app_layer_path = join(output_path, 'app-layer')
@@ -1080,7 +1080,7 @@ def build_layer(layer_path, layer_args):
10801080
env['LD_LIBRARY_PATH'] = base_layer_path
10811081

10821082
# fetch python test file
1083-
testhello_py = join(suite.dir, 'mx.substratevm', 'testhello.py')
1083+
testhello_py = join(sourcepath, 'gdb-tests', 'testhello.py')
10841084

10851085
# run gdb
10861086
mx.run(gdb_base_command() + ['-x', testhello_py, app_layer], cwd=app_layer_path, env=env)
@@ -1110,13 +1110,13 @@ def testhello_ni_args(cincludepath, sourcepath):
11101110
'--native-compiler-options=-I' + cincludepath,
11111111
'-H:CLibraryPath=' + sourcepath,
11121112
'--native-image-info',
1113-
'-cp', classpath('com.oracle.svm.test'),
1113+
'-cp', classpath('com.oracle.svm.test.debug'),
11141114
'-Djdk.graal.LogFile=graal.log',
1115-
'-DbuildDebugInfoTestExample=true', # set property controlling inclusion of foreign struct header
1116-
] + svm_experimental_options([
1117-
'-H:+SourceLevelDebug',
1118-
'-H:DebugInfoSourceSearchPath=' + sourcepath,
1119-
])
1115+
'-DbuildDebugInfoTestExample=true', # set property controlling inclusion of foreign struct header
1116+
] + svm_experimental_options([
1117+
'-H:+SourceLevelDebug',
1118+
'-H:DebugInfoSourceSearchPath=' + sourcepath,
1119+
])
11201120

11211121
def _gdbdebughelperstest(native_image, path, with_isolates_only, args):
11221122

@@ -1134,21 +1134,21 @@ def _gdbdebughelperstest(native_image, path, with_isolates_only, args):
11341134
('GDB Python API is not available.' if gdb_version == 0 else f'found GDB version {gdb_version}.'))
11351135
# ===============================
11361136

1137-
test_proj = mx.dependency('com.oracle.svm.test')
1137+
test_proj = mx.dependency('com.oracle.svm.test.debug')
11381138
test_source_path = test_proj.source_dirs()[0]
11391139
tutorial_proj = mx.dependency('com.oracle.svm.tutorial')
11401140
tutorial_c_source_dir = join(tutorial_proj.dir, 'native')
11411141
tutorial_source_path = tutorial_proj.source_dirs()[0]
11421142

1143-
test_python_source_dir = join(test_source_path, 'com', 'oracle', 'svm', 'test', 'debug', 'helper')
1143+
test_python_source_dir = join(test_source_path, 'gdb-tests')
11441144
test_pretty_printer_py = join(test_python_source_dir, 'test_pretty_printer.py')
11451145
test_cinterface_py = join(test_python_source_dir, 'test_cinterface.py')
11461146
test_class_loader_py = join(test_python_source_dir, 'test_class_loader.py')
11471147
test_settings_py = join(test_python_source_dir, 'test_settings.py')
11481148
test_svm_util_py = join(test_python_source_dir, 'test_svm_util.py')
11491149

11501150
test_pretty_printer_args = [
1151-
'-cp', classpath('com.oracle.svm.test'),
1151+
'-cp', classpath('com.oracle.svm.test.debug'),
11521152
# We do not want to step into class initializer, so initialize everything at build time.
11531153
'--initialize-at-build-time=com.oracle.svm.test.debug.helper',
11541154
'com.oracle.svm.test.debug.helper.PrettyPrinterTest'
@@ -1159,11 +1159,11 @@ def _gdbdebughelperstest(native_image, path, with_isolates_only, args):
11591159
'-cp', tutorial_proj.output_dir()
11601160
]
11611161
test_class_loader_args = [
1162-
'-cp', classpath('com.oracle.svm.test'),
1163-
'-Dsvm.test.missing.classes=' + classpath('com.oracle.svm.test.missing.classes'),
1162+
'-cp', classpath('com.oracle.svm.test.debug'),
1163+
'-Dcom.oracle.svm.test.debug.missing.classes=' + classpath('com.oracle.svm.test.debug.missing.classes'),
11641164
'--initialize-at-build-time=com.oracle.svm.test.debug.helper',
11651165
# We need the static initializer of the ClassLoaderTest to run at image build time
1166-
'--initialize-at-build-time=com.oracle.svm.test.missing.classes',
1166+
'--initialize-at-build-time=com.oracle.svm.test.debug.missing.classes',
11671167
'com.oracle.svm.test.debug.helper.ClassLoaderTest'
11681168
]
11691169

@@ -1253,13 +1253,13 @@ def _runtimedebuginfotest(native_image, output_path, with_isolates_only, args=No
12531253

12541254
args = [] if args is None else args
12551255

1256-
test_proj = mx.dependency('com.oracle.svm.test')
1256+
test_proj = mx.dependency('com.oracle.svm.test.debug')
12571257
test_source_path = test_proj.source_dirs()[0]
12581258

1259-
test_python_source_dir = join(test_source_path, 'com', 'oracle', 'svm', 'test', 'debug', 'helper')
1259+
test_python_source_dir = join(test_source_path, 'gdb-tests')
12601260
test_runtime_compilation_py = join(test_python_source_dir, 'test_runtime_compilation.py')
12611261
test_runtime_deopt_py = join(test_python_source_dir, 'test_runtime_deopt.py')
1262-
testdeopt_js = join(suite.dir, 'mx.substratevm', 'testdeopt.js')
1262+
testdeopt_js = join(test_python_source_dir, 'testdeopt.js')
12631263

12641264
# clean / create output directory
12651265
if exists(output_path):
@@ -1273,9 +1273,11 @@ def _runtimedebuginfotest(native_image, output_path, with_isolates_only, args=No
12731273
'-DbuildDebugInfoTestExample=true',
12741274
'--native-compiler-options=-I' + test_source_path,
12751275
'-o', join(output_path, 'runtimedebuginfotest'),
1276-
'-cp', classpath('com.oracle.svm.test'),
1276+
'-cp', classpath('com.oracle.svm.test.debug'),
12771277
# We do not want to step into class initializer, so initialize everything at build time.
12781278
'--initialize-at-build-time=com.oracle.svm.test.debug.helper',
1279+
# We need access to ModuleSupport
1280+
'--add-exports=org.graalvm.nativeimage.base/com.oracle.svm.util=ALL-UNNAMED',
12791281
'--features=com.oracle.svm.test.debug.helper.RuntimeCompileDebugInfoTest$RegisterMethodsFeature',
12801282
'com.oracle.svm.test.debug.helper.RuntimeCompileDebugInfoTest',
12811283
] + svm_experimental_options([
@@ -1876,7 +1878,7 @@ def debuginfotest(args, config=None):
18761878
def layereddebuginfotest(args, config=None):
18771879
"""
18781880
Builds a layered native image and tests it with gdb.
1879-
Base layer: java.base, com.oracle.svm.test
1881+
Base layer: java.base
18801882
App Layer: hello.Hello
18811883
"""
18821884
parser = ArgumentParser(prog='mx layereddebuginfotest')

substratevm/mx.substratevm/suite.py

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,10 +1172,6 @@
11721172
"jdk.internal.misc",
11731173
"sun.security.jca",
11741174
],
1175-
"jdk.internal.vm.ci" : [
1176-
"jdk.vm.ci.code",
1177-
"jdk.vm.ci.meta",
1178-
],
11791175
},
11801176
"checkstyle": "com.oracle.svm.test",
11811177
"checkstyleVersion" : "10.21.0",
@@ -1189,19 +1185,46 @@
11891185
"jacoco" : "exclude",
11901186
},
11911187

1192-
"com.oracle.svm.test.missing.classes": {
1188+
"com.oracle.svm.test.debug": {
11931189
"subDir": "src",
11941190
"sourceDirs": ["src"],
11951191
"dependencies": [
1192+
"sdk:NATIVEIMAGE",
1193+
"SVM",
11961194
],
1195+
"requiresConcealed": {
1196+
"jdk.internal.vm.ci": [
1197+
"jdk.vm.ci.code",
1198+
"jdk.vm.ci.meta",
1199+
],
1200+
},
1201+
"checkstyle": "com.oracle.svm.test",
1202+
"workingSets": "SVM",
11971203
"annotationProcessors": [
1204+
"compiler:GRAAL_PROCESSOR",
1205+
"SVM_PROCESSOR",
1206+
],
1207+
"javaCompliance": "21+",
1208+
"spotbugs": "false",
1209+
"jacoco": "exclude",
1210+
"testProject": True,
1211+
},
1212+
1213+
"com.oracle.svm.test.debug.missing.classes": {
1214+
"subDir": "src",
1215+
"sourceDirs": ["src"],
1216+
"dependencies": [
11981217
],
11991218
"checkstyle": "com.oracle.svm.test",
1200-
"javaCompliance" : "21+",
12011219
"workingSets": "SVM",
1220+
"annotationProcessors": [
1221+
"compiler:GRAAL_PROCESSOR",
1222+
"SVM_PROCESSOR",
1223+
],
1224+
"javaCompliance": "21+",
12021225
"spotbugs": "false",
1226+
"jacoco": "exclude",
12031227
"testProject": True,
1204-
"jacoco" : "exclude",
12051228
},
12061229

12071230
"com.oracle.svm.with.space.test": {
@@ -2489,27 +2512,19 @@
24892512
"com.oracle.svm.test",
24902513
"com.oracle.svm.configure.test",
24912514
"com.oracle.svm.graal.test",
2515+
"com.oracle.svm.test.debug",
2516+
"com.oracle.svm.test.debug.missing.classes",
24922517
"SVM_TEST_RESOURCE_WITH_SPACE",
24932518
],
24942519
"distDependencies": [
24952520
"mx:JUNIT_TOOL",
24962521
"sdk:NATIVEIMAGE",
24972522
"SVM",
24982523
"SVM_CONFIGURE",
2499-
"SVM_TEST_MISSING_CLASSES",
25002524
],
25012525
"testDistribution" : True,
25022526
},
25032527

2504-
"SVM_TEST_MISSING_CLASSES" : {
2505-
"subDir": "src",
2506-
"relpath" : True,
2507-
"dependencies": [
2508-
"com.oracle.svm.test.missing.classes"
2509-
],
2510-
"testDistribution": True,
2511-
},
2512-
25132528
# Special test distribution used for testing inclusion of resources from jar files with a space in their name.
25142529
# The space in the distribution name is intentional.
25152530
"SVM_TESTS WITH SPACE" : {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* or visit www.oracle.com if you need additional information or have any
2323
* questions.
2424
*/
25-
package com.oracle.svm.test.missing.classes;
25+
package com.oracle.svm.test.debug.missing.classes;
2626

2727
public class TestClass {
2828
public static final Object CONSTANT_OBJECT_FIELD = 42;
File renamed without changes.
File renamed without changes.

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/debug/helper/ClassLoaderTest.java renamed to substratevm/src/com.oracle.svm.test.debug/src/com/oracle/svm/test/debug/helper/ClassLoaderTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,18 @@ public class ClassLoaderTest {
4444

4545
static {
4646
try {
47-
Path path = Paths.get(System.getProperty("svm.test.missing.classes"));
47+
Path path = Paths.get(System.getProperty("com.oracle.svm.test.debug.missing.classes"));
4848
URL[] urls = new URL[]{path.toUri().toURL()};
4949
try (URLClassLoader classLoader = new URLClassLoader("testClassLoader", urls, ClassLoaderTest.class.getClassLoader())) {
50-
testClass = classLoader.loadClass("com.oracle.svm.test.missing.classes.TestClass");
50+
testClass = classLoader.loadClass("com.oracle.svm.test.debug.missing.classes.TestClass");
5151
testObj = testClass.getConstructor().newInstance();
5252
instanceMethod = testClass.getDeclaredMethod("instanceMethod");
5353
} catch (IOException | ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
5454
throw new RuntimeException(e);
5555
}
5656
// load the same class from two different classLoaders
5757
try (URLClassLoader classLoader = new URLClassLoader(urls, ClassLoaderTest.class.getClassLoader())) {
58-
testClass2 = classLoader.loadClass("com.oracle.svm.test.missing.classes.TestClass");
58+
testClass2 = classLoader.loadClass("com.oracle.svm.test.debug.missing.classes.TestClass");
5959
testObj2 = testClass2.getConstructor().newInstance();
6060
instanceMethod2 = testClass2.getDeclaredMethod("instanceMethod");
6161
} catch (IOException | ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException | InvocationTargetException e) {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ static void testHashMap(HashMap<String, String> strMap, Map<Object, Object> mixe
151151
@SuppressWarnings("unused")
152152
@NeverInline("For testing purposes")
153153
static void testLambda(Function<String, String> lambda) {
154-
blackhole(lambda);
154+
lambda.apply("test");
155155
}
156156

157157
@SuppressWarnings("unused")
@@ -166,6 +166,7 @@ static void blackhole(Object... value) {
166166
}
167167

168168
static ExampleClass setupExampleObject(boolean recursive) {
169+
ExampleClass.s1 += "!"; // Ensure the static field ends up in the debug info.
169170
ExampleClass example = new ExampleClass();
170171
example.f10 = new ExampleClass(10, 20, (short) 30, '\40', (byte) 50, true, "60", Day.Sunday, new Object(), null);
171172
example.f9 = new ArrayList<>(List.of(example.f10, new ExampleClass()));
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525

2626
package com.oracle.svm.test.debug.helper;
2727

28-
import static com.oracle.svm.core.util.VMError.shouldNotReachHere;
29-
3028
import java.util.ArrayList;
3129
import java.util.List;
3230

@@ -46,6 +44,7 @@
4644
import com.oracle.svm.core.AlwaysInline;
4745
import com.oracle.svm.core.NeverInline;
4846
import com.oracle.svm.core.c.InvokeJavaFunctionPointer;
47+
import com.oracle.svm.core.util.VMError;
4948
import com.oracle.svm.graal.SubstrateGraalUtils;
5049
import com.oracle.svm.graal.hosted.runtimecompilation.RuntimeCompilationFeature;
5150
import com.oracle.svm.graal.meta.SubstrateMethod;
@@ -256,7 +255,7 @@ private static SubstrateMethod prepareMethodForRuntimeCompilation(BeforeAnalysis
256255
try {
257256
return runtimeCompilationFeature.prepareMethodForRuntimeCompilation(holder.getMethod(methodName, signature), config);
258257
} catch (NoSuchMethodException ex) {
259-
throw shouldNotReachHere(ex);
258+
throw VMError.shouldNotReachHere(ex);
260259
}
261260
}
262261
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)