1""" 2Test inferior restart when breakpoint is set on running target. 3""" 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8 9 10class BreakpointSetRestart(TestBase): 11 12 mydir = TestBase.compute_mydir(__file__) 13 BREAKPOINT_TEXT = 'Set a breakpoint here' 14 15 @skipIfNetBSD 16 @skipIfReproducer 17 def test_breakpoint_set_restart(self): 18 self.build() 19 20 exe = self.getBuildArtifact("a.out") 21 22 target = self.dbg.CreateTarget(exe) 23 self.assertTrue(target, VALID_TARGET) 24 25 self.dbg.SetAsync(True) 26 process = target.LaunchSimple( 27 None, None, self.get_process_working_directory()) 28 self.assertTrue(process, PROCESS_IS_VALID) 29 30 event = lldb.SBEvent() 31 # Wait for inferior to transition to running state 32 while self.dbg.GetListener().WaitForEvent(2, event): 33 if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning: 34 break 35 36 bp = target.BreakpointCreateBySourceRegex( 37 self.BREAKPOINT_TEXT, lldb.SBFileSpec('main.cpp')) 38 self.assertTrue( 39 bp.IsValid() and bp.GetNumLocations() == 1, 40 VALID_BREAKPOINT) 41 42 while self.dbg.GetListener().WaitForEvent(2, event): 43 if lldb.SBProcess.GetStateFromEvent( 44 event) == lldb.eStateStopped and lldb.SBProcess.GetRestartedFromEvent(event): 45 continue 46 if lldb.SBProcess.GetStateFromEvent(event) == lldb.eStateRunning: 47 continue 48 self.fail( 49 "Setting a breakpoint generated an unexpected event: %s" % 50 lldb.SBDebugger.StateAsCString( 51 lldb.SBProcess.GetStateFromEvent(event))) 52