From 66d1486241a1aa84aab79624a4937f79f42e4cb4 Mon Sep 17 00:00:00 2001 From: Fabio Niephaus Date: Thu, 26 Jan 2023 10:45:44 +0100 Subject: [PATCH] Allow for different method prologues in `debuginfotest`. --- substratevm/mx.substratevm/testhello.py | 43 +++++++++++-------------- 1 file changed, 19 insertions(+), 24 deletions(-) diff --git a/substratevm/mx.substratevm/testhello.py b/substratevm/mx.substratevm/testhello.py index e045bdbd1bc15..897741997690c 100644 --- a/substratevm/mx.substratevm/testhello.py +++ b/substratevm/mx.substratevm/testhello.py @@ -159,9 +159,7 @@ def test(): musl = os.environ.get('debuginfotest_musl', 'no') == 'yes' - isolates = False - if os.environ.get('debuginfotest_isolates', 'no') == 'yes': - isolates = True + isolates = os.environ.get('debuginfotest_isolates', 'no') == 'yes' arch = os.environ.get('debuginfotest_arch', 'amd64') @@ -781,30 +779,27 @@ def test(): r"f11 = 12.375"] 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 arch == 'aarch64': - exec_string = execute("stepi") - print(exec_string) - # n.b. stack param offsets will be wrong here because - # aarch64 creates the frame in two steps, a sub of - # the frame size followed by a stack push of [lr,sp] - # (needs fixing in the initial frame location info split - # in the generator not here) + # proceed to the next infopoint, which is at the end of the method prologue. + # since the compiler may emit different instruction sequences, we step + # through the instructions until we find and execute the first instruction + # that adjusts the stack pointer register, which concludes the prologue. + sp_register = 'sp' if arch == 'aarch64' else 'rsp' + instruction_adjusts_sp_register_pattern = re.compile(r"%s,%%%s"%(wildcard_pattern,sp_register)) + max_num_stepis = 6 + num_stepis = 0 + while True: exec_string = execute("x/i $pc") print(exec_string) - exec_string = execute("stepi") - print(exec_string) - else: - exec_string = execute("stepi") - + execute("stepi") + num_stepis += 1 + if instruction_adjusts_sp_register_pattern.match(exec_string): + print("method prologue reached successfully") + break + if num_stepis >= max_num_stepis: + print("method prologue is unexpectedly long, did not reach end after %s stepis" % num_stepis) + sys.exit(1) + exec_string = execute("info args") rexp =[r"i0 = 0", r"i1 = 1",