xref: /llvm-project/lldb/test/API/macosx/duplicate-archive-members/TestDuplicateMembers.py (revision ec009994a06338995dfb6431c943b299f9327fd2)
1"""Test breaking inside functions defined within a BSD archive file libfoo.a."""
2
3
4import lldb
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9
10class BSDArchivesTestCase(TestBase):
11    def test(self):
12        """Break inside a() and b() defined within libfoo.a."""
13        self.build()
14
15        exe = self.getBuildArtifact("a.out")
16        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
17
18        # Break on a() and b() symbols
19        lldbutil.run_break_set_by_symbol(self, "a", sym_exact=True)
20        lldbutil.run_break_set_by_symbol(self, "b", sym_exact=True)
21
22        self.runCmd("run", RUN_SUCCEEDED)
23
24        # The stop reason of the thread should be breakpoint.
25        self.expect(
26            "thread list",
27            STOPPED_DUE_TO_BREAKPOINT,
28            substrs=["stopped", "stop reason = breakpoint"],
29        )
30
31        # Break at a(int) first.
32        self.expect(
33            "frame variable", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(int) arg = 1"]
34        )
35        self.expect(
36            "frame variable __a_global",
37            VARIABLES_DISPLAYED_CORRECTLY,
38            substrs=["(int) __a_global = 1"],
39        )
40
41        # Continue the program, we should break at b(int) next.
42        self.runCmd("continue")
43        self.expect(
44            "thread list",
45            STOPPED_DUE_TO_BREAKPOINT,
46            substrs=["stopped", "stop reason = breakpoint"],
47        )
48        self.expect(
49            "frame variable", VARIABLES_DISPLAYED_CORRECTLY, substrs=["(int) arg = 2"]
50        )
51        self.expect(
52            "frame variable __b_global",
53            VARIABLES_DISPLAYED_CORRECTLY,
54            substrs=["(int) __b_global = 2"],
55        )
56