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