xref: /llvm-project/lldb/test/API/macosx/duplicate-archive-members/TestDuplicateMembers.py (revision ec009994a06338995dfb6431c943b299f9327fd2)
199451b44SJordan Rupprecht"""Test breaking inside functions defined within a BSD archive file libfoo.a."""
299451b44SJordan Rupprecht
399451b44SJordan Rupprecht
499451b44SJordan Rupprechtimport lldb
599451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
699451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
799451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
899451b44SJordan Rupprecht
999451b44SJordan Rupprecht
1099451b44SJordan Rupprechtclass BSDArchivesTestCase(TestBase):
1199451b44SJordan Rupprecht    def test(self):
1299451b44SJordan Rupprecht        """Break inside a() and b() defined within libfoo.a."""
1399451b44SJordan Rupprecht        self.build()
1499451b44SJordan Rupprecht
1599451b44SJordan Rupprecht        exe = self.getBuildArtifact("a.out")
1699451b44SJordan Rupprecht        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
1799451b44SJordan Rupprecht
1899451b44SJordan Rupprecht        # Break on a() and b() symbols
19*2238dcc3SJonas Devlieghere        lldbutil.run_break_set_by_symbol(self, "a", sym_exact=True)
20*2238dcc3SJonas Devlieghere        lldbutil.run_break_set_by_symbol(self, "b", sym_exact=True)
2199451b44SJordan Rupprecht
2299451b44SJordan Rupprecht        self.runCmd("run", RUN_SUCCEEDED)
2399451b44SJordan Rupprecht
2499451b44SJordan Rupprecht        # The stop reason of the thread should be breakpoint.
25*2238dcc3SJonas Devlieghere        self.expect(
26*2238dcc3SJonas Devlieghere            "thread list",
27*2238dcc3SJonas Devlieghere            STOPPED_DUE_TO_BREAKPOINT,
28*2238dcc3SJonas Devlieghere            substrs=["stopped", "stop reason = breakpoint"],
29*2238dcc3SJonas Devlieghere        )
3099451b44SJordan Rupprecht
3199451b44SJordan Rupprecht        # Break at a(int) first.
32*2238dcc3SJonas Devlieghere        self.expect(
33*2238dcc3SJonas Devlieghere            "frame variable", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(int) arg = 1"]
34*2238dcc3SJonas Devlieghere        )
35*2238dcc3SJonas Devlieghere        self.expect(
36*2238dcc3SJonas Devlieghere            "frame variable __a_global",
37*2238dcc3SJonas Devlieghere            VARIABLES_DISPLAYED_CORRECTLY,
38*2238dcc3SJonas Devlieghere            substrs=["(int) __a_global = 1"],
39*2238dcc3SJonas Devlieghere        )
4099451b44SJordan Rupprecht
4199451b44SJordan Rupprecht        # Continue the program, we should break at b(int) next.
4299451b44SJordan Rupprecht        self.runCmd("continue")
43*2238dcc3SJonas Devlieghere        self.expect(
44*2238dcc3SJonas Devlieghere            "thread list",
45*2238dcc3SJonas Devlieghere            STOPPED_DUE_TO_BREAKPOINT,
46*2238dcc3SJonas Devlieghere            substrs=["stopped", "stop reason = breakpoint"],
47*2238dcc3SJonas Devlieghere        )
48*2238dcc3SJonas Devlieghere        self.expect(
49*2238dcc3SJonas Devlieghere            "frame variable", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(int) arg = 2"]
50*2238dcc3SJonas Devlieghere        )
51*2238dcc3SJonas Devlieghere        self.expect(
52*2238dcc3SJonas Devlieghere            "frame variable __b_global",
53*2238dcc3SJonas Devlieghere            VARIABLES_DISPLAYED_CORRECTLY,
54*2238dcc3SJonas Devlieghere            substrs=["(int) __b_global = 2"],
55*2238dcc3SJonas Devlieghere        )
56