2 This tests that we do not lose control of the inferior, while doing an instruction-level step
3 over a thread creation instruction.
6 from __future__ import print_function
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
16 class CreateDuringInstructionStepTestCase(TestBase):
18 mydir = TestBase.compute_mydir(__file__)
21 # Call super's setUp().
24 @skipUnlessPlatform(['linux'])
25 @expectedFailureAndroid('llvm.org/pr24737', archs=['arm'])
29 bugnumber="llvm.org/pr24737")
30 def test_step_inst(self):
31 self.build(dictionary=self.getBuildFlags())
32 exe = os.path.join(os.getcwd(), "a.out")
33 target = self.dbg.CreateTarget(exe)
34 self.assertTrue(target and target.IsValid(), "Target is valid")
36 # This should create a breakpoint in the stepping thread.
37 breakpoint = target.BreakpointCreateByName("main")
39 breakpoint and breakpoint.IsValid(),
40 "Breakpoint is valid")
43 process = target.LaunchSimple(
44 None, None, self.get_process_working_directory())
45 self.assertTrue(process and process.IsValid(), PROCESS_IS_VALID)
47 # The stop reason of the thread should be breakpoint.
53 threads = lldbutil.get_threads_stopped_at_breakpoint(
55 self.assertEqual(len(threads), 1, STOPPED_DUE_TO_BREAKPOINT)
58 self.assertTrue(thread and thread.IsValid(), "Thread is valid")
60 # Make sure we see only one threads
62 process.GetNumThreads(),
64 'Number of expected threads and actual threads do not match.')
66 # Keep stepping until we see the thread creation
67 while process.GetNumThreads() < 2:
68 thread.StepInstruction(False)
74 thread.GetStopReason(),
75 lldb.eStopReasonPlanComplete,
76 "Step operation succeeded")
78 self.runCmd("disassemble --pc")
81 self.runCmd("thread list")
83 # We have successfully caught thread creation. Now just run to
87 # At this point, the inferior process should have exited.
88 self.assertEqual(process.GetState(), lldb.eStateExited, PROCESS_EXITED)