1"""Test breaking inside functions defined within a BSD archive file libfoo.a.""" 2 3 4 5import lldb 6from lldbsuite.test.decorators import * 7from lldbsuite.test.lldbtest import * 8from lldbsuite.test import lldbutil 9 10 11class BSDArchivesTestCase(TestBase): 12 13 mydir = TestBase.compute_mydir(__file__) 14 15 def setUp(self): 16 # Call super's setUp(). 17 TestBase.setUp(self) 18 # Find the line number in a(int) to break at. 19 self.line = line_number( 20 'a.c', '// Set file and line breakpoint inside a().') 21 22 @expectedFailureAll( 23 oslist=["windows"], 24 bugnumber="llvm.org/pr24527. Makefile.rules doesn't know how to build static libs on Windows") 25 def test(self): 26 """Break inside a() and b() defined within libfoo.a.""" 27 self.build() 28 29 exe = self.getBuildArtifact("a.out") 30 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 31 32 # Break inside a() by file and line first. 33 lldbutil.run_break_set_by_file_and_line( 34 self, "a.c", self.line, num_expected_locations=1, loc_exact=True) 35 36 self.runCmd("run", RUN_SUCCEEDED) 37 38 # The stop reason of the thread should be breakpoint. 39 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 40 substrs=['stopped', 41 'stop reason = breakpoint']) 42 43 # Break at a(int) first. 44 self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, 45 substrs=['(int) arg = 1']) 46 self.expect("frame variable __a_global", VARIABLES_DISPLAYED_CORRECTLY, 47 substrs=['(int) __a_global = 1']) 48 49 # Set breakpoint for b() next. 50 lldbutil.run_break_set_by_symbol( 51 self, "b", num_expected_locations=1, sym_exact=True) 52 53 # Continue the program, we should break at b(int) next. 54 self.runCmd("continue") 55 self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, 56 substrs=['stopped', 57 'stop reason = breakpoint']) 58 self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY, 59 substrs=['(int) arg = 2']) 60 self.expect("frame variable __b_global", VARIABLES_DISPLAYED_CORRECTLY, 61 substrs=['(int) __b_global = 2']) 62