late-attach.py 721 B

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