2 This tests that we do not lose control of the inferior, while doing an instruction-level step
3 over a thread creation instruction.
8 from lldbsuite
.test
.decorators
import *
9 from lldbsuite
.test
.lldbtest
import *
10 from lldbsuite
.test
import lldbutil
13 class CreateDuringInstructionStepTestCase(TestBase
):
14 NO_DEBUG_INFO_TESTCASE
= True
16 @skipUnlessPlatform(["linux"])
17 @expectedFailureAndroid("llvm.org/pr24737", archs
=["arm"])
18 @skipIf(oslist
=["linux"], archs
=["arm", "aarch64"], bugnumber
="llvm.org/pr24737")
19 def test_step_inst(self
):
21 exe
= self
.getBuildArtifact("a.out")
22 target
= self
.dbg
.CreateTarget(exe
)
23 self
.assertTrue(target
and target
.IsValid(), "Target is valid")
25 # This should create a breakpoint in the stepping thread.
26 breakpoint
= target
.BreakpointCreateByName("main")
27 self
.assertTrue(breakpoint
and breakpoint
.IsValid(), "Breakpoint is valid")
30 process
= target
.LaunchSimple(None, None, self
.get_process_working_directory())
31 self
.assertTrue(process
and process
.IsValid(), PROCESS_IS_VALID
)
33 # The stop reason of the thread should be breakpoint.
34 self
.assertEqual(process
.GetState(), lldb
.eStateStopped
, PROCESS_STOPPED
)
36 threads
= lldbutil
.get_threads_stopped_at_breakpoint(process
, breakpoint
)
37 self
.assertEqual(len(threads
), 1, STOPPED_DUE_TO_BREAKPOINT
)
40 self
.assertTrue(thread
and thread
.IsValid(), "Thread is valid")
42 # Make sure we see only one threads
44 process
.GetNumThreads(),
46 "Number of expected threads and actual threads do not match.",
49 # Keep stepping until we see the thread creation
50 while process
.GetNumThreads() < 2:
51 thread
.StepInstruction(False)
52 self
.assertEqual(process
.GetState(), lldb
.eStateStopped
, PROCESS_STOPPED
)
54 thread
.GetStopReason(),
55 lldb
.eStopReasonPlanComplete
,
56 "Step operation succeeded",
59 self
.runCmd("disassemble --pc")
62 self
.runCmd("thread list")
64 # We have successfully caught thread creation. Now just run to
68 # At this point, the inferior process should have exited.
69 self
.assertState(process
.GetState(), lldb
.eStateExited
, PROCESS_EXITED
)