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