xref: /llvm-project/lldb/test/API/functionalities/fat_archives/TestFatArchives.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1"""
2Test some lldb command abbreviations.
3"""
4
5
6import lldb
7from lldbsuite.test.decorators import *
8from lldbsuite.test.lldbtest import *
9from lldbsuite.test import lldbutil
10
11
12class FatArchiveTestCase(TestBase):
13    NO_DEBUG_INFO_TESTCASE = True
14
15    @skipUnlessDarwin
16    def test_breakpoint_resolution_dwarf(self):
17        if self.getArchitecture() == "x86_64":
18            self.build()
19            self.main()
20        else:
21            self.skipTest(
22                "This test requires x86_64 as the architecture for the inferior"
23            )
24
25    def main(self):
26        """This test compiles a quick example by making a fat file (universal) full of
27        skinny .o files and makes sure we can use them to resolve breakpoints when doing
28        DWARF in .o file debugging. The only thing this test needs to do is to compile and
29        set a breakpoint in the target and verify any breakpoint locations have valid debug
30        info for the function, and source file and line."""
31        exe = self.getBuildArtifact("a.out")
32
33        # Create the target
34        target = self.dbg.CreateTarget(exe)
35
36        # Create a breakpoint by name
37        breakpoint = target.BreakpointCreateByName("foo", exe)
38        self.assertTrue(breakpoint, VALID_BREAKPOINT)
39
40        # Make sure the breakpoint resolves to a function, file and line
41        for bp_loc in breakpoint:
42            # Get a section offset address (lldb.SBAddress) from the breakpoint
43            # location
44            bp_loc_addr = bp_loc.GetAddress()
45            line_entry = bp_loc_addr.GetLineEntry()
46            function = bp_loc_addr.GetFunction()
47            self.assertTrue(
48                function.IsValid(),
49                "Verify breakpoint in fat BSD archive has valid function debug info",
50            )
51            self.assertTrue(
52                line_entry.GetFileSpec(),
53                "Verify breakpoint in fat BSD archive has source file information",
54            )
55            self.assertNotEqual(
56                line_entry.GetLine(),
57                0,
58                "Verify breakpoint in fat BSD archive has source line information",
59            )
60