• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_var_path("__a_global", type="int", value="1")
47
48        # Set breakpoint for b() next.
49        lldbutil.run_break_set_by_symbol(
50            self, "b", num_expected_locations=1, sym_exact=True)
51
52        # Continue the program, we should break at b(int) next.
53        self.runCmd("continue")
54        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
55                    substrs=['stopped',
56                             'stop reason = breakpoint'])
57        self.expect("frame variable", VARIABLES_DISPLAYED_CORRECTLY,
58                    substrs=['(int) arg = 2'])
59        self.expect_var_path("__b_global", type="int", value="2")
60