Skip to content

Commit 9ba04e4

Browse files
committed
DebugInfo: Add test (in debuginfotest) for substituted methods
1 parent 40b6448 commit 9ba04e4

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@
587587
"sourceDirs": ["src"],
588588
"dependencies": [
589589
"mx:JUNIT_TOOL",
590-
"sdk:GRAAL_SDK",
590+
"SVM",
591591
],
592592
"checkstyle": "com.oracle.svm.core",
593593
"workingSets": "SVM",
@@ -1321,7 +1321,7 @@
13211321
],
13221322
"distDependencies": [
13231323
"mx:JUNIT_TOOL",
1324-
"sdk:GRAAL_SDK",
1324+
"SVM",
13251325
"SVM_CONFIGURE",
13261326
],
13271327
"testDistribution" : True,

substratevm/mx.substratevm/testhello.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,13 @@ def test():
263263
r"%s = 1000"%(wildcard_pattern))
264264
checker.check(exec_string, skip_fails=False)
265265

266+
# set a break point at hello.Hello$DefaultGreeter::greet
267+
# expect "Breakpoint 2 at 0x[0-9a-f]+: file hello/Target_Hello_DefaultGreeter.java, line [0-9]+."
268+
exec_string = execute("break hello.Hello$DefaultGreeter::greet")
269+
rexp = r"Breakpoint 2 at %s: file hello/Target_hello_Hello_DefaultGreeter\.java, line %s\."%(address_pattern, digits_pattern)
270+
checker = Checker("break on substituted method", rexp)
271+
checker.check(exec_string, skip_fails=False)
272+
266273
# look up PrintStream.println methods
267274
# expect "All functions matching regular expression "java.io.PrintStream.println":"
268275
# expect ""
@@ -284,7 +291,7 @@ def test():
284291
# set a break point at PrintStream.println(String)
285292
# expect "Breakpoint 2 at 0x[0-9a-f]+: java.base/java/io/PrintStream.java, line [0-9]+."
286293
exec_string = execute("break java.io.PrintStream::println(java.lang.String *)")
287-
rexp = r"Breakpoint 2 at %s: file .*java/io/PrintStream\.java, line %s\."%(address_pattern, digits_pattern)
294+
rexp = r"Breakpoint 3 at %s: file .*java/io/PrintStream\.java, line %s\."%(address_pattern, digits_pattern)
288295
checker = Checker('break println', rexp)
289296
checker.check(exec_string, skip_fails=False)
290297

@@ -400,7 +407,8 @@ def test():
400407
print(checker)
401408
sys.exit(1)
402409

403-
# continue to next breakpoint
410+
# continue to next 2 breakpoints
411+
execute("continue")
404412
execute("continue")
405413

406414
# run backtrace to check we are in java.io.PrintStream::println(java.lang.String)
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved.
3+
* Copyright (c) 2020, 2020, Red Hat Inc. All rights reserved.
4+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5+
*
6+
* This code is free software; you can redistribute it and/or modify it
7+
* under the terms of the GNU General Public License version 2 only, as
8+
* published by the Free Software Foundation. Oracle designates this
9+
* particular file as subject to the "Classpath" exception as provided
10+
* by Oracle in the LICENSE file that accompanied this code.
11+
*
12+
* This code is distributed in the hope that it will be useful, but WITHOUT
13+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15+
* version 2 for more details (a copy is included in the LICENSE file that
16+
* accompanied this code).
17+
*
18+
* You should have received a copy of the GNU General Public License version
19+
* 2 along with this work; if not, write to the Free Software Foundation,
20+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21+
*
22+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23+
* or visit www.oracle.com if you need additional information or have any
24+
* questions.
25+
*/
26+
27+
package hello;
28+
29+
import com.oracle.svm.core.annotate.Substitute;
30+
import com.oracle.svm.core.annotate.TargetClass;
31+
32+
@TargetClass(value = Hello.DefaultGreeter.class)
33+
final class Target_hello_Hello_DefaultGreeter {
34+
@Substitute
35+
public void greet() {
36+
// Checkstyle: stop
37+
System.out.println("Hello, substituted world!");
38+
// Checkstyle: resume
39+
}
40+
}

0 commit comments

Comments
 (0)