1 """ 2 Test that debug symbols have the correct order as specified by the order file. 3 """ 4 5 import os, time 6 import re 7 import unittest2 8 import lldb 9 from lldbtest import * 10 11 class OrderFileTestCase(TestBase): 12 13 mydir = os.path.join("macosx", "order") 14 15 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 16 @dsym_test 17 def test_with_dsym(self): 18 """Test debug symbols follow the correct order by the order file.""" 19 self.buildDsym() 20 self.order_file() 21 22 @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") 23 @dwarf_test 24 def test_with_dwarf(self): 25 """Test debug symbols follow the correct order by the order file.""" 26 self.buildDwarf() 27 self.order_file() 28 29 def order_file(self): 30 """Test debug symbols follow the correct order by the order file.""" 31 exe = os.path.join(os.getcwd(), "a.out") 32 self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) 33 34 # Test that the debug symbols have Function f3 before Function f1. 35 # Use "-s address" option to sort by address. 36 self.runCmd("image dump symtab -s address a.out") 37 output = self.res.GetOutput() 38 mo_f3 = re.search("Code +.+f3", output) 39 mo_f1 = re.search("Code +.+f1", output) 40 41 # Match objects for f3 and f1 must exist and f3 must come before f1. 42 self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(), 43 "Symbols have correct order by the order file") 44 45 self.runCmd("run", RUN_COMPLETED) 46 47 48 if __name__ == '__main__': 49 import atexit 50 lldb.SBDebugger.Initialize() 51 atexit.register(lambda: lldb.SBDebugger.Terminate()) 52 unittest2.main() 53