Skip to content

Commit 26cf91d

Browse files
committed
correct debug info test script for new object layout and to bypass latest gdb bug
1 parent bcb4763 commit 26cf91d

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

substratevm/mx.substratevm/testhello.py

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
import re
4444
import sys
45+
import os
4546

4647
# A helper class which checks that a sequence of lines of output
4748
# from a gdb command matches a sequence of per-line regular
@@ -139,10 +140,16 @@ def test():
139140
# n.b. can only get back here with one match
140141
match = matches[0]
141142
major = int(match.group(1))
142-
# may need this if 8.x and 9.x get patched
143-
# minor = int(match.group(2))
144-
# printing object data requires gdb 10+
145-
can_print_data = major > 9
143+
minor = int(match.group(2))
144+
# printing object data requires a patched gdb
145+
# once the patch is in we can check for a suitable
146+
# range of major.minor versions
147+
# for now we use an env setting
148+
print("Found gdb version %s.%s"%(major, minor))
149+
# can_print_data = major > 10 or (major == 10 and minor > 1)
150+
can_print_data = False
151+
if os.environ.get('GDB_CAN_PRINT', '') == 'True':
152+
can_print_data = True
146153

147154
if not can_print_data:
148155
print("Warning: cannot test printing of objects!")
@@ -182,12 +189,13 @@ def test():
182189
exec_string = execute("print /x *(('java.lang.String[]' *)$rdi)")
183190
checker = Checker("print String[] args",
184191
[r"%s = {"%(wildcard_pattern),
185-
r"%s<_arrhdrA> = {"%(spaces_pattern),
192+
r"%s<java.lang.Object> = {"%(spaces_pattern),
193+
r"%s<_objhdr> = {"%(spaces_pattern),
186194
r"%shub = %s,"%(spaces_pattern, address_pattern),
187-
r"%sidHash = %s,"%(spaces_pattern, address_pattern),
188-
r"%slen = 0x0"%(spaces_pattern),
189-
r"%s},"%(spaces_pattern),
195+
r"%sidHash = %s"%(spaces_pattern, address_pattern),
196+
r"%s}, <No data fields>}, "%(spaces_pattern),
190197
r"%smembers of java\.lang\.String\[\]:"%(spaces_pattern),
198+
r"%slen = 0x0,"%(spaces_pattern),
191199
r"%sdata = %s"%(spaces_pattern, address_pattern),
192200
"}"])
193201

@@ -225,7 +233,7 @@ def test():
225233
# ensure we can dereference static fields
226234
exec_string = execute("print 'java.math.BigDecimal'::BIG_TEN_POWERS_TABLE->data[3]->mag->data[0]")
227235
checker = Checker("print static field value contents",
228-
r"%s = 1000\$"%(wildcard_pattern))
236+
r"%s = 1000"%(wildcard_pattern))
229237
checker.check(exec_string, skip_fails=False)
230238

231239
# look up PrintStream.println methods
@@ -308,13 +316,12 @@ def test():
308316
checker = Checker('ptype _objhdr', rexp)
309317
checker.check(exec_string, skip_fails=True)
310318

311-
exec_string = execute("ptype _arrhdrA")
312-
rexp = [r"type = struct _arrhdrA {",
313-
r"%sjava\.lang\.Class \*hub;"%(spaces_pattern),
314-
r"%sint idHash;"%(spaces_pattern),
319+
exec_string = execute("ptype 'java.lang.String[]'")
320+
rexp = [r"type = class java.lang.String\[\] : public java.lang.Object {",
315321
r"%sint len;"%(spaces_pattern),
322+
r"%sjava\.lang\.String \*data\[0\];"%(spaces_pattern),
316323
r"}"]
317-
checker = Checker('ptype _objhdr', rexp)
324+
checker = Checker('ptype String[]', rexp)
318325
checker.check(exec_string, skip_fails=True)
319326

320327
# run a backtrace

0 commit comments

Comments
 (0)