2 This tests that we do not lose control of the inferior, while doing an instruction-level step
3 over a thread creation instruction.
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class CreateDuringInstructionStepTestCase(TestBase):
16 mydir = TestBase.compute_mydir(__file__)
17 NO_DEBUG_INFO_TESTCASE = True
19 @skipUnlessPlatform(['linux'])
20 @expectedFailureAndroid('llvm.org/pr24737', archs=['arm'])
24 bugnumber="llvm.org/pr24737")
25 def test_step_inst(self):
26 self.build(dictionary=self.getBuildFlags())
27 exe = self.getBuildArtifact("a.out")
28 target = self.dbg.CreateTarget(exe)
29 self.assertTrue(target and target.IsValid(), "Target is valid")
31 # This should create a breakpoint in the stepping thread.
32 breakpoint = target.BreakpointCreateByName("main")
34 breakpoint and breakpoint.IsValid(),
35 "Breakpoint is valid")
38 process = target.LaunchSimple(
39 None, None, self.get_process_working_directory())
40 self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
42 # The stop reason of the thread should be breakpoint.
48 threads = lldbutil.get_threads_stopped_at_breakpoint(
50 self.assertEqual(len(threads), 1, STOPPED_DUE_TO_BREAKPOINT)
53 self.assertTrue(thread and thread.IsValid(), "Thread is valid")
55 # Make sure we see only one threads
57 process.GetNumThreads(),
59 'Number of expected threads and actual threads do not match.')
61 # Keep stepping until we see the thread creation
62 while process.GetNumThreads() < 2:
63 thread.StepInstruction(False)
69 thread.GetStopReason(),
70 lldb.eStopReasonPlanComplete,
71 "Step operation succeeded")
73 self.runCmd("disassemble --pc")
76 self.runCmd("thread list")
78 # We have successfully caught thread creation. Now just run to
82 # At this point, the inferior process should have exited.
83 self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)