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
14    NO_DEBUG_INFO_TESTCASE = True
15
16    @skipUnlessDarwin
17    def test_breakpoint_resolution_dwarf(self):
18        if self.getArchitecture() == 'x86_64':
19            self.build()
20            self.main()
21        else:
22            self.skipTest(
23                "This test requires x86_64 as the architecture for the inferior")
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            self.assertTrue(
51                line_entry.GetFileSpec(),
52                "Verify breakpoint in fat BSD archive has source file information")
53            self.assertTrue(
54                line_entry.GetLine() != 0,
55                "Verify breakpoint in fat BSD archive has source line information")
56