Skip to content

Commit

Permalink
Add --skip-asm-instructions option for debuginfotest.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jan 26, 2023
1 parent 773d799 commit bd50635
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 7 additions & 3 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,7 @@ def _collector(x):
if actual_output != expected_output:
raise Exception('Unexpected output: ' + str(actual_output) + " != " + str(expected_output))

def _debuginfotest(native_image, path, build_only, with_isolates_only, args):
def _debuginfotest(native_image, path, build_only, with_isolates_only, skip_asm_instructions, args):
mkpath(path)
mx.log("path=%s"%path)
sourcepath = mx.project('com.oracle.svm.test').source_dirs()[0]
Expand Down Expand Up @@ -831,6 +831,8 @@ def build_debug_test(extra_args):
if '--libc=musl' in args:
os.environ.update({'debuginfotest_musl' : 'yes'})

os.environ.update({'debuginfotest_asm_insns' : 'no' if skip_asm_instructions else 'yes'})

testhello_py = join(suite.dir, 'mx.substratevm', 'testhello.py')
hello_binary = join(path, 'hello.hello')

Expand Down Expand Up @@ -1232,19 +1234,21 @@ def debuginfotest(args, config=None):
builds a debuginfo Hello native image and tests it with gdb.
"""
parser = ArgumentParser(prog='mx debuginfotest')
all_args = ['--output-path', '--build-only', '--with-isolates-only']
all_args = ['--output-path', '--build-only', '--with-isolates-only', '--skip-asm-instructions']
masked_args = [_mask(arg, all_args) for arg in args]
parser.add_argument(all_args[0], metavar='<output-path>', nargs=1, help='Path of the generated image', default=[svmbuild_dir(suite)])
parser.add_argument(all_args[1], action='store_true', help='Only build the native image')
parser.add_argument(all_args[2], action='store_true', help='Only build and test the native image with isolates')
parser.add_argument(all_args[3], action='store_true', help='Skip assembly instructions checks')
parser.add_argument('image_args', nargs='*', default=[])
parsed = parser.parse_args(masked_args)
output_path = unmask(parsed.output_path)[0]
build_only = parsed.build_only
with_isolates_only = parsed.with_isolates_only
skip_asm_instructions = parsed.skip_asm_instructions
native_image_context_run(
lambda native_image, a:
_debuginfotest(native_image, output_path, build_only, with_isolates_only, a), unmask(parsed.image_args),
_debuginfotest(native_image, output_path, build_only, with_isolates_only, skip_asm_instructions, a), unmask(parsed.image_args),
config=config
)

Expand Down
16 changes: 9 additions & 7 deletions substratevm/mx.substratevm/testhello.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def test():
can_print_data = True

musl = os.environ.get('debuginfotest_musl', 'no') == 'yes'
asm_insns = os.environ.get('debuginfotest_asm_insns', 'no') == 'yes'

isolates = False
if os.environ.get('debuginfotest_isolates', 'no') == 'yes':
Expand Down Expand Up @@ -782,13 +783,14 @@ def test():
checker = Checker('info args', rexp)
checker.check(exec_string)

exec_string = execute("x/i $pc")
if arch == 'aarch64':
rexp = r"%ssub%ssp, sp, #0x%s"%(wildcard_pattern, spaces_pattern, hex_digits_pattern)
else:
rexp = r"%ssub %s\$0x%s,%%rsp"%(wildcard_pattern, spaces_pattern, hex_digits_pattern)
checker = Checker('x/i $pc', rexp)
checker.check(exec_string)
if asm_insns:
exec_string = execute("x/i $pc")
if arch == 'aarch64':
rexp = r"%ssub%ssp, sp, #0x%s"%(wildcard_pattern, spaces_pattern, hex_digits_pattern)
else:
rexp = r"%ssub %s\$0x%s,%%rsp"%(wildcard_pattern, spaces_pattern, hex_digits_pattern)
checker = Checker('x/i $pc', rexp)
checker.check(exec_string)

if arch == 'aarch64':
exec_string = execute("stepi")
Expand Down

0 comments on commit bd50635

Please sign in to comment.