blob: b0d9fd93586d6c47bfec1d6287f03954457b45df [file] [log] [blame]
Johnny Chenacfbeff2010-07-08 00:17:29 +00001"""
2Test that debug symbols have the correct order as specified by the order file.
3"""
4
Zachary Turner77db4a82015-10-22 20:06:20 +00005import lldb_shared
6
Johnny Chenacfbeff2010-07-08 00:17:29 +00007import os, time
8import re
Johnny Chenacfbeff2010-07-08 00:17:29 +00009import lldb
Johnny Chen17941842010-08-09 23:44:24 +000010from lldbtest import *
Johnny Chenacfbeff2010-07-08 00:17:29 +000011
Johnny Chencbb4be02010-09-01 19:59:58 +000012class OrderFileTestCase(TestBase):
Johnny Chenacfbeff2010-07-08 00:17:29 +000013
Greg Clayton4570d3e2013-12-10 23:19:29 +000014 mydir = TestBase.compute_mydir(__file__)
Johnny Chenacfbeff2010-07-08 00:17:29 +000015
Robert Flack13c7ad92015-03-30 14:12:17 +000016 @skipUnlessDarwin
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000017 def test(self):
Johnny Chenacfbeff2010-07-08 00:17:29 +000018 """Test debug symbols follow the correct order by the order file."""
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000019 self.build()
Johnny Chenacfbeff2010-07-08 00:17:29 +000020 exe = os.path.join(os.getcwd(), "a.out")
Johnny Chenff3d01d2010-08-20 21:03:09 +000021 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
Johnny Chenacfbeff2010-07-08 00:17:29 +000022
23 # Test that the debug symbols have Function f3 before Function f1.
Johnny Chen96332142010-12-17 18:02:08 +000024 # Use "-s address" option to sort by address.
25 self.runCmd("image dump symtab -s address a.out")
Johnny Chenff3d01d2010-08-20 21:03:09 +000026 output = self.res.GetOutput()
Johnny Chen9440d1c2010-09-13 16:59:11 +000027 mo_f3 = re.search("Code +.+f3", output)
28 mo_f1 = re.search("Code +.+f1", output)
Johnny Chenacfbeff2010-07-08 00:17:29 +000029
30 # Match objects for f3 and f1 must exist and f3 must come before f1.
Johnny Chen17941842010-08-09 23:44:24 +000031 self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(),
32 "Symbols have correct order by the order file")
Johnny Chenacfbeff2010-07-08 00:17:29 +000033
Johnny Chenff3d01d2010-08-20 21:03:09 +000034 self.runCmd("run", RUN_COMPLETED)