1 2 3import gdbremote_testcase 4import lldbgdbserverutils 5from lldbsuite.test.decorators import * 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test import lldbutil 8 9 10class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase): 11 12 def test_attach_commandline_kill_after_initial_stop(self): 13 self.build() 14 self.set_inferior_startup_attach() 15 reg_expr = r"^\$[XW][0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}" 16 procs = self.prep_debug_monitor_and_inferior() 17 self.test_sequence.add_log_lines([ 18 "read packet: $k#6b", 19 {"direction": "send", "regex": reg_expr}, 20 ], True) 21 22 if self.stub_sends_two_stop_notifications_on_kill: 23 # Add an expectation for a second X result for stubs that send two 24 # of these. 25 self.test_sequence.add_log_lines([ 26 {"direction": "send", "regex": reg_expr}, 27 ], True) 28 29 self.expect_gdbremote_sequence() 30 31 # Wait a moment for completed and now-detached inferior process to 32 # clear. 33 time.sleep(self.DEFAULT_SLEEP) 34 35 if not lldb.remote_platform: 36 # Process should be dead now. Reap results. 37 poll_result = procs["inferior"].poll() 38 self.assertIsNotNone(poll_result) 39 40 # Where possible, verify at the system level that the process is not 41 # running. 42 self.assertFalse( 43 lldbgdbserverutils.process_is_running( 44 procs["inferior"].pid, False)) 45