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