brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · fb19ec5 Raw
65 lines · python
1import lldb2from lldbsuite.test.lldbtest import *3from lldbsuite.test.decorators import *4from lldbsuite.test.gdbclientutils import *5from lldbsuite.test.lldbgdbclient import GDBRemoteTestBase6 7 8class TestRestartBug(GDBRemoteTestBase):9    @expectedFailureAll(bugnumber="llvm.org/pr24530")10    def test(self):11        """12        Test auto-continue behavior when a process is interrupted to deliver13        an "asynchronous" packet. This simulates the situation when a process14        stops on its own just as lldb client is about to interrupt it. The15        client should not auto-continue in this case, unless the user has16        explicitly requested that we ignore signals of this type.17        """18 19        class MyResponder(MockGDBServerResponder):20            continueCount = 021 22            def setBreakpoint(self, packet):23                return "OK"24 25            def interrupt(self):26                # Simulate process stopping due to a raise(SIGINT) just as lldb27                # is about to interrupt it.28                return "T02reason:signal"29 30            def cont(self):31                self.continueCount += 132                if self.continueCount == 1:33                    # No response, wait for the client to interrupt us.34                    return None35                return "W00"  # Exit36 37        self.server.responder = MyResponder()38        target = self.createTarget("a.yaml")39        process = self.connect(target)40        self.dbg.SetAsync(True)41        process.Continue()42 43        # resume the process and immediately try to set another breakpoint. When using the remote44        # stub, this will trigger a request to stop the process.  Make sure we45        # do not lose this signal.46        bkpt = target.BreakpointCreateByAddress(0x1234)47        self.assertTrue(bkpt.IsValid())48        self.assertEqual(bkpt.GetNumLocations(), 1)49 50        event = lldb.SBEvent()51        while self.dbg.GetListener().WaitForEvent(2, event):52            if self.TraceOn():53                print(54                    "Process changing state to:",55                    self.dbg.StateAsCString(process.GetStateFromEvent(event)),56                )57            if process.GetStateFromEvent(event) == lldb.eStateExited:58                break59 60        # We should get only one continue packet as the client should not61        # auto-continue after setting the breakpoint.62        self.assertEqual(self.server.responder.continueCount, 1)63        # And the process should end up in the stopped state.64        self.assertState(process.GetState(), lldb.eStateStopped)65