36 lines · python
1"""2Test stepping out of a function when the return location is an unsuitable3stopping point.4"""5 6 7import lldb8from lldbsuite.test.decorators import *9from lldbsuite.test.lldbtest import *10from lldbsuite.test import lldbutil11 12 13class ThreadStepOutLine0TestCase(TestBase):14 def test(self):15 self.build()16 target, process, thread, _ = lldbutil.run_to_source_breakpoint(17 self, "// Set breakpoint here", lldb.SBFileSpec("main.c")18 )19 correct_stepped_out_line = line_number("main.c", "// Should stop here")20 return_statement_line = line_number("main.c", "// Ran too far")21 safety_bp = target.BreakpointCreateByLocation(22 lldb.SBFileSpec("main.c"), return_statement_line23 )24 self.assertTrue(safety_bp.IsValid())25 26 error = lldb.SBError()27 thread.StepOut(error)28 self.assertTrue(error.Success())29 30 frame = thread.GetSelectedFrame()31 self.assertEqual(32 frame.line_entry.GetLine(),33 correct_stepped_out_line,34 "Step-out lost control of execution, ran too far",35 )36