xref: /llvm-project/lldb/test/API/macosx/order/TestOrderFile.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
199451b44SJordan Rupprecht"""
299451b44SJordan RupprechtTest that debug symbols have the correct order as specified by the order file.
399451b44SJordan Rupprecht"""
499451b44SJordan Rupprecht
599451b44SJordan Rupprecht
699451b44SJordan Rupprechtimport re
799451b44SJordan Rupprechtimport lldb
899451b44SJordan Rupprechtfrom lldbsuite.test.decorators import *
999451b44SJordan Rupprechtfrom lldbsuite.test.lldbtest import *
1099451b44SJordan Rupprechtfrom lldbsuite.test import lldbutil
1199451b44SJordan Rupprecht
1299451b44SJordan Rupprecht
1399451b44SJordan Rupprechtclass OrderFileTestCase(TestBase):
1499451b44SJordan Rupprecht    @skipUnlessDarwin
1599451b44SJordan Rupprecht    def test(self):
1699451b44SJordan Rupprecht        """Test debug symbols follow the correct order by the order file."""
1799451b44SJordan Rupprecht        self.build()
1899451b44SJordan Rupprecht        exe = self.getBuildArtifact("a.out")
1999451b44SJordan Rupprecht        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
2099451b44SJordan Rupprecht
2199451b44SJordan Rupprecht        # Test that the debug symbols have Function f3 before Function f1.
2299451b44SJordan Rupprecht        # Use "-s address" option to sort by address.
2399451b44SJordan Rupprecht        self.runCmd("image dump symtab -s address %s" % exe)
2499451b44SJordan Rupprecht        output = self.res.GetOutput()
2599451b44SJordan Rupprecht        mo_f3 = re.search("Code +.+f3", output)
2699451b44SJordan Rupprecht        mo_f1 = re.search("Code +.+f1", output)
2799451b44SJordan Rupprecht
2899451b44SJordan Rupprecht        # Match objects for f3 and f1 must exist and f3 must come before f1.
29*2238dcc3SJonas Devlieghere        self.assertTrue(
30*2238dcc3SJonas Devlieghere            mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(),
31*2238dcc3SJonas Devlieghere            "Symbols have correct order by the order file",
32*2238dcc3SJonas Devlieghere        )
3399451b44SJordan Rupprecht
3499451b44SJordan Rupprecht        self.runCmd("run", RUN_COMPLETED)
35