1""" 2When using C++11 in place member initialization, show that we 3can set and hit breakpoints on initialization lines. This is a 4little bit tricky because we try not to move file and line breakpoints 5across function boundaries but these lines are outside the source range 6of the constructor. 7""" 8 9 10 11import lldb 12import lldbsuite.test.lldbutil as lldbutil 13from lldbsuite.test.lldbtest import * 14 15 16class TestCase(TestBase): 17 18 mydir = TestBase.compute_mydir(__file__) 19 20 def test_breakpoints_on_initializers(self): 21 """Show we can set breakpoints on initializers appearing both before 22 and after the constructor body, and hit them.""" 23 self.build() 24 self.main_source_file = lldb.SBFileSpec("main.cpp") 25 self.first_initializer_line = line_number("main.cpp", "Set the before constructor breakpoint here") 26 self.second_initializer_line = line_number("main.cpp", "Set the after constructor breakpoint here") 27 28 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 29 " Set a breakpoint here to get started", self.main_source_file) 30 31 # Now set breakpoints on the two initializer lines we found in the test startup: 32 bkpt1 = target.BreakpointCreateByLocation(self.main_source_file, self.first_initializer_line) 33 self.assertEqual(bkpt1.GetNumLocations(), 1) 34 bkpt2 = target.BreakpointCreateByLocation(self.main_source_file, self.second_initializer_line) 35 self.assertEqual(bkpt2.GetNumLocations(), 1) 36 37 # Now continue, we should stop at the two breakpoints above, first the one before, then 38 # the one after. 39 self.assertEqual(len(lldbutil.continue_to_breakpoint(process, bkpt1)), 1, "Hit first breakpoint") 40 self.assertEqual(len(lldbutil.continue_to_breakpoint(process, bkpt2)), 1, "Hit second breakpoint") 41 42 43