1"""Test attaching GDB to a running process. 2 3SPDX-License-Identifier: GPL-2.0-or-later 4""" 5from test_gdbstub import main, report 6 7 8def run_test(): 9 """Run through the tests one by one""" 10 try: 11 phase = gdb.parse_and_eval("phase").string() 12 except gdb.error: 13 # Assume the guest did not reach main(). 14 phase = "start" 15 16 if phase == "start": 17 gdb.execute("break sigwait") 18 gdb.execute("continue") 19 phase = gdb.parse_and_eval("phase").string() 20 report(phase == "sigwait", "{} == \"sigwait\"".format(phase)) 21 22 gdb.execute("signal SIGUSR1") 23 24 exitcode = int(gdb.parse_and_eval("$_exitcode")) 25 report(exitcode == 0, "{} == 0".format(exitcode)) 26 27 28main(run_test) 29