Skip to content

Commit

Permalink
Allow for different method prologues in debuginfotest.
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jan 26, 2023
1 parent 773d799 commit 66d1486
Showing 1 changed file with 19 additions and 24 deletions.
43 changes: 19 additions & 24 deletions substratevm/mx.substratevm/testhello.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 66d1486

Please sign in to comment.