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