1"""
2Test that debug symbols have the correct order as specified by the order file.
3"""
4
5
6
7import re
8import lldb
9from lldbsuite.test.decorators import *
10from lldbsuite.test.lldbtest import *
11from lldbsuite.test import lldbutil
12
13
14class OrderFileTestCase(TestBase):
15
16    mydir = TestBase.compute_mydir(__file__)
17
18    @skipUnlessDarwin
19    def test(self):
20        """Test debug symbols follow the correct order by the order file."""
21        self.build()
22        exe = self.getBuildArtifact("a.out")
23        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
24
25        # Test that the debug symbols have Function f3 before Function f1.
26        # Use "-s address" option to sort by address.
27        self.runCmd("image dump symtab -s address %s" % exe)
28        output = self.res.GetOutput()
29        mo_f3 = re.search("Code +.+f3", output)
30        mo_f1 = re.search("Code +.+f1", output)
31
32        # Match objects for f3 and f1 must exist and f3 must come before f1.
33        self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(),
34                        "Symbols have correct order by the order file")
35
36        self.runCmd("run", RUN_COMPLETED)
37