1"""Test variable lookup when stopped in inline functions.""" 2 3 4import lldb 5from lldbsuite.test.decorators import * 6from lldbsuite.test.lldbtest import * 7from lldbsuite.test import lldbutil 8 9 10class InlinesTestCase(TestBase): 11 12 def setUp(self): 13 # Call super's setUp(). 14 TestBase.setUp(self) 15 # Find the line number to break inside main(). 16 self.line = line_number( 17 'inlines.cpp', 18 '// Set break point at this line.') 19 20 def test(self): 21 """Test that local variables are visible in expressions.""" 22 self.build() 23 self.runToBreakpoint() 24 25 # Check that 'frame variable' finds a variable 26 self.expect( 27 "frame variable inner_input", 28 VARIABLES_DISPLAYED_CORRECTLY, 29 startstr='(int) inner_input =') 30 31 # Check that 'expr' finds a variable 32 self.expect("expr inner_input", VARIABLES_DISPLAYED_CORRECTLY, 33 startstr='(int) $0 =') 34 35 def runToBreakpoint(self): 36 exe = self.getBuildArtifact("a.out") 37 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 38 39 # Break inside the main. 40 lldbutil.run_break_set_by_file_and_line( 41 self, 42 "inlines.cpp", 43 self.line, 44 num_expected_locations=2, 45 loc_exact=True) 46 47 self.runCmd("run", RUN_SUCCEEDED) 48 49 # The stop reason of the thread should be breakpoint. 50 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 51 substrs=['stopped', 52 'stop reason = breakpoint']) 53 54 # The breakpoint should have a hit count of 1. 55 lldbutil.check_breakpoint(self, bpno = 1, expected_hit_count = 1) 56