1"""Test stepping through ObjC method dispatch in various forms.""" 2 3from __future__ import print_function 4 5 6import lldb 7from lldbsuite.test.decorators import * 8from lldbsuite.test.lldbtest import * 9from lldbsuite.test import lldbutil 10 11 12class TestObjCDirectDispatchStepping(TestBase): 13 NO_DEBUG_INFO_TESTCASE = True 14 15 def setUp(self): 16 # Call super's setUp(). 17 TestBase.setUp(self) 18 # Find the line numbers that we will step to in main: 19 self.main_source = lldb.SBFileSpec("stepping-tests.m") 20 21 @add_test_categories(['pyapi', 'basic_process']) 22 def test_with_python_api(self): 23 """Test stepping through the 'direct dispatch' optimized method calls.""" 24 self.build() 25 26 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 27 "Stop here to start stepping", 28 self.main_source) 29 stop_bkpt = target.BreakpointCreateBySourceRegex("// Stop Location [0-9]+", self.main_source) 30 self.assertEqual(stop_bkpt.GetNumLocations(), 15) 31 32 # Here we step through all the overridden methods of OverridesALot 33 # The last continue will get us to the call ot OverridesInit. 34 for idx in range(2,16): 35 thread.StepInto() 36 func_name = thread.GetFrameAtIndex(0).GetFunctionName() 37 self.assertIn("OverridesALot", func_name, "%d'th step did not match name: %s"%(idx, func_name)) 38 stop_threads = lldbutil.continue_to_breakpoint(process, stop_bkpt) 39 self.assertEqual(len(stop_threads), 1) 40 self.assertEqual(stop_threads[0], thread) 41 42 thread.StepInto() 43 func_name = thread.GetFrameAtIndex(0).GetFunctionName() 44 self.assertEqual(func_name, "-[OverridesInit init]", "Stopped in [OverridesInit init]") 45 46 47 48