2010-07-08 08:17:29 +08:00
|
|
|
"""
|
|
|
|
Test that debug symbols have the correct order as specified by the order file.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import os, time
|
|
|
|
import re
|
2010-08-06 07:42:46 +08:00
|
|
|
import unittest2
|
2010-07-08 08:17:29 +08:00
|
|
|
import lldb
|
2010-08-10 07:44:24 +08:00
|
|
|
from lldbtest import *
|
2010-07-08 08:17:29 +08:00
|
|
|
|
2010-09-02 03:59:58 +08:00
|
|
|
class OrderFileTestCase(TestBase):
|
2010-07-08 08:17:29 +08:00
|
|
|
|
2013-12-11 07:19:29 +08:00
|
|
|
mydir = TestBase.compute_mydir(__file__)
|
2010-07-08 08:17:29 +08:00
|
|
|
|
2010-09-15 06:55:48 +08:00
|
|
|
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
2012-04-07 03:54:10 +08:00
|
|
|
@dsym_test
|
2010-09-15 06:55:48 +08:00
|
|
|
def test_with_dsym(self):
|
2010-07-08 08:17:29 +08:00
|
|
|
"""Test debug symbols follow the correct order by the order file."""
|
2010-09-15 06:55:48 +08:00
|
|
|
self.buildDsym()
|
|
|
|
self.order_file()
|
2010-09-15 06:50:50 +08:00
|
|
|
|
2011-12-23 03:21:46 +08:00
|
|
|
@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
|
2012-04-07 03:54:10 +08:00
|
|
|
@dwarf_test
|
2010-09-15 06:55:48 +08:00
|
|
|
def test_with_dwarf(self):
|
|
|
|
"""Test debug symbols follow the correct order by the order file."""
|
|
|
|
self.buildDwarf()
|
|
|
|
self.order_file()
|
|
|
|
|
|
|
|
def order_file(self):
|
|
|
|
"""Test debug symbols follow the correct order by the order file."""
|
2010-07-08 08:17:29 +08:00
|
|
|
exe = os.path.join(os.getcwd(), "a.out")
|
2010-08-21 05:03:09 +08:00
|
|
|
self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
|
2010-07-08 08:17:29 +08:00
|
|
|
|
|
|
|
# Test that the debug symbols have Function f3 before Function f1.
|
2010-12-18 02:02:08 +08:00
|
|
|
# Use "-s address" option to sort by address.
|
|
|
|
self.runCmd("image dump symtab -s address a.out")
|
2010-08-21 05:03:09 +08:00
|
|
|
output = self.res.GetOutput()
|
2010-09-14 00:59:11 +08:00
|
|
|
mo_f3 = re.search("Code +.+f3", output)
|
|
|
|
mo_f1 = re.search("Code +.+f1", output)
|
2010-07-08 08:17:29 +08:00
|
|
|
|
|
|
|
# Match objects for f3 and f1 must exist and f3 must come before f1.
|
2010-08-10 07:44:24 +08:00
|
|
|
self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(),
|
|
|
|
"Symbols have correct order by the order file")
|
2010-07-08 08:17:29 +08:00
|
|
|
|
2010-08-21 05:03:09 +08:00
|
|
|
self.runCmd("run", RUN_COMPLETED)
|
2010-07-08 08:17:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2010-08-06 05:23:45 +08:00
|
|
|
import atexit
|
2010-07-08 08:17:29 +08:00
|
|
|
lldb.SBDebugger.Initialize()
|
2010-08-06 05:23:45 +08:00
|
|
|
atexit.register(lambda: lldb.SBDebugger.Terminate())
|
2010-08-06 07:42:46 +08:00
|
|
|
unittest2.main()
|