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