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