1""" 2Test thread stepping features in combination with frame select. 3""" 4 5 6 7import lldb 8import lldbsuite.test.lldbutil as lldbutil 9from lldbsuite.test.lldbtest import * 10import lldbsuite.test.lldbutil as lldbutil 11 12 13class ThreadSteppingTestCase(TestBase): 14 15 mydir = TestBase.compute_mydir(__file__) 16 17 def setUp(self): 18 # Call super's setUp(). 19 TestBase.setUp(self) 20 # Find the line number to of function 'c'. 21 self.line1 = line_number( 22 'main.c', '// Find the line number of function "c" here.') 23 self.line2 = line_number( 24 'main.c', '// frame select 2, thread step-out while stopped at "c(1)"') 25 self.line3 = line_number( 26 'main.c', '// thread step-out while stopped at "c(2)"') 27 self.line4 = line_number( 28 'main.c', '// frame select 1, thread step-out while stopped at "c(3)"') 29 30 def test_step_out_with_run_command(self): 31 """Exercise thread step-out and frame select followed by thread step-out.""" 32 self.build() 33 exe = self.getBuildArtifact("a.out") 34 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 35 36 # Create a breakpoint inside function 'c'. 37 lldbutil.run_break_set_by_file_and_line( 38 self, "main.c", self.line1, num_expected_locations=1, loc_exact=True) 39 40 # Now run the program. 41 self.runCmd("run", RUN_SUCCEEDED) 42 43 # The process should be stopped at this point. 44 self.expect("process status", PROCESS_STOPPED, 45 patterns=['Process .* stopped']) 46 47 # The frame #0 should correspond to main.c:32, the executable statement 48 # in function name 'c'. And frame #3 should point to main.c:37. 49 self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT, 50 substrs=["stop reason = breakpoint"], 51 patterns=["frame #0.*main.c:%d" % self.line1, 52 "frame #3.*main.c:%d" % self.line2]) 53 54 # We want to move the pc to frame #3. This can be accomplished by 55 # 'frame select 2', followed by 'thread step-out'. 56 self.runCmd("frame select 2") 57 self.runCmd("thread step-out") 58 self.expect("thread backtrace", STEP_OUT_SUCCEEDED, 59 substrs=["stop reason = step out"], 60 patterns=["frame #0.*main.c:%d" % self.line2]) 61 62 # Let's move on to a single step-out case. 63 self.runCmd("process continue") 64 65 # The process should be stopped at this point. 66 self.expect("process status", PROCESS_STOPPED, 67 patterns=['Process .* stopped']) 68 self.runCmd("thread step-out") 69 self.expect("thread backtrace", STEP_OUT_SUCCEEDED, 70 substrs=["stop reason = step out"], 71 patterns=["frame #0.*main.c:%d" % self.line3]) 72 73 # Do another frame selct, followed by thread step-out. 74 self.runCmd("process continue") 75 76 # The process should be stopped at this point. 77 self.expect("process status", PROCESS_STOPPED, 78 patterns=['Process .* stopped']) 79 self.runCmd("frame select 1") 80 self.runCmd("thread step-out") 81 self.expect("thread backtrace", STEP_OUT_SUCCEEDED, 82 substrs=["stop reason = step out"], 83 patterns=["frame #0.*main.c:%d" % self.line4]) 84