Skip to content

Commit 61b403b

Browse files
committed
DebugInfo: Add test (in debuginfotest) for substituted methods
1 parent 0feed58 commit 61b403b

File tree

3 files changed

+53
-5
lines changed

3 files changed

+53
-5
lines changed

substratevm/mx.substratevm/suite.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@
560560
"sourceDirs": ["src"],
561561
"dependencies": [
562562
"mx:JUNIT_TOOL",
563-
"sdk:GRAAL_SDK",
563+
"SVM",
564564
],
565565
"checkstyle": "com.oracle.svm.core",
566566
"workingSets": "SVM",
@@ -1129,7 +1129,7 @@
11291129
],
11301130
"distDependencies": [
11311131
"mx:JUNIT_TOOL",
1132-
"sdk:GRAAL_SDK",
1132+
"SVM",
11331133
],
11341134
"testDistribution" : True,
11351135
},

substratevm/mx.substratevm/testhello.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,13 @@ def test():
158158
])
159159
checker.check(exec_string, skip_fails=False)
160160

161+
# set a break point at PrintStream::println(String)
162+
# expect "Breakpoint 2 at 0x[0-9a-f]+: file hello/Target_Hello_DefaultGreeter.java, line [0-9]+."
163+
exec_string = execute("break hello.Hello.DefaultGreeter::greet")
164+
rexp = r"Breakpoint 2 at %s: file hello/Target_hello_Hello_DefaultGreeter\.java, line %s\."%(address_pattern, digits_pattern)
165+
checker = Checker("break on substituted method", rexp)
166+
checker.check(exec_string, skip_fails=False)
167+
161168
# look up PrintStream::println methods
162169
# expect "All functions matching regular expression "java.io.PrintStream::println":"
163170
# expect ""
@@ -177,9 +184,9 @@ def test():
177184
checker.check(exec_string)
178185

179186
# set a break point at PrintStream::println(String)
180-
# expect "Breakpoint 2 at 0x[0-9a-f]+: java.base/java/io/PrintStream.java, line [0-9]+."
187+
# expect "Breakpoint 3 at 0x[0-9a-f]+: java.base/java/io/PrintStream.java, line [0-9]+."
181188
exec_string = execute("break java.io.PrintStream::println(java.lang.String)")
182-
rexp = r"Breakpoint 2 at %s: file .*java/io/PrintStream\.java, line %s\."%(address_pattern, digits_pattern)
189+
rexp = r"Breakpoint 3 at %s: file .*java/io/PrintStream\.java, line %s\."%(address_pattern, digits_pattern)
183190
checker = Checker('break println', rexp)
184191
checker.check(exec_string, skip_fails=False)
185192

@@ -221,7 +228,8 @@ def test():
221228
print(checker)
222229
sys.exit(1)
223230

224-
# continue to next breakpoint
231+
# continue to next 2 breakpoints
232+
execute("continue")
225233
execute("continue")
226234

227235
# 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)