1""" 2Test that inlined breakpoints (breakpoint set on a file/line included from 3another source file) works correctly. 4""" 5 6 7 8import lldb 9from lldbsuite.test.lldbtest import * 10import lldbsuite.test.lldbutil as lldbutil 11 12 13class InlinedBreakpointsTestCase(TestBase): 14 """Bug fixed: rdar://problem/8464339""" 15 16 mydir = TestBase.compute_mydir(__file__) 17 18 def test_with_run_command(self): 19 """Test 'b basic_types.cpp:176' does break (where int.cpp includes basic_type.cpp).""" 20 self.build() 21 self.inlined_breakpoints() 22 23 def setUp(self): 24 # Call super's setUp(). 25 TestBase.setUp(self) 26 # Find the line number to break inside basic_type.cpp. 27 self.line = line_number( 28 'basic_type.cpp', 29 '// Set break point at this line.') 30 31 def inlined_breakpoints(self): 32 """Test 'b basic_types.cpp:176' does break (where int.cpp includes basic_type.cpp).""" 33 exe = self.getBuildArtifact("a.out") 34 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 35 36 # With the inline-breakpoint-strategy, our file+line breakpoint should 37 # not resolve to a location. 38 self.runCmd('settings set target.inline-breakpoint-strategy headers') 39 40 # Set a breakpoint and fail because it is in an inlined source 41 # implemenation file 42 lldbutil.run_break_set_by_file_and_line( 43 self, "basic_type.cpp", self.line, num_expected_locations=0) 44 45 # Now enable breakpoints in implementation files and see the breakpoint 46 # set succeed 47 self.runCmd('settings set target.inline-breakpoint-strategy always') 48 # And add hooks to restore the settings during tearDown(). 49 self.addTearDownHook(lambda: self.runCmd( 50 "settings set target.inline-breakpoint-strategy always")) 51 52 lldbutil.run_break_set_by_file_and_line( 53 self, 54 "basic_type.cpp", 55 self.line, 56 num_expected_locations=1, 57 loc_exact=True) 58 59 self.runCmd("run", RUN_SUCCEEDED) 60 61 # The stop reason of the thread should be breakpoint. 62 # And it should break at basic_type.cpp:176. 63 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 64 substrs=['stopped', 65 'basic_type.cpp:%d' % self.line, 66 'stop reason = breakpoint',]) 67