Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 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 |
Johnny Chen | 7325883 | 2010-08-05 23:42:46 +0000 | [diff] [blame] | 7 | import unittest2 |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 8 | import lldb |
Johnny Chen | 1794184 | 2010-08-09 23:44:24 +0000 | [diff] [blame] | 9 | from lldbtest import * |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 10 | |
Johnny Chen | cbb4be0 | 2010-09-01 19:59:58 +0000 | [diff] [blame] | 11 | class OrderFileTestCase(TestBase): |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 12 | |
Johnny Chen | fd70999 | 2011-06-27 18:25:00 +0000 | [diff] [blame] | 13 | mydir = os.path.join("macosx", "order") |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 14 | |
Johnny Chen | 1d8ab8a | 2010-09-14 22:55:48 +0000 | [diff] [blame] | 15 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 16 | @dsym_test |
Johnny Chen | 1d8ab8a | 2010-09-14 22:55:48 +0000 | [diff] [blame] | 17 | def test_with_dsym(self): |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 18 | """Test debug symbols follow the correct order by the order file.""" |
Johnny Chen | 1d8ab8a | 2010-09-14 22:55:48 +0000 | [diff] [blame] | 19 | self.buildDsym() |
| 20 | self.order_file() |
Johnny Chen | 6c3f686 | 2010-09-14 22:50:50 +0000 | [diff] [blame] | 21 | |
Johnny Chen | 025c58f | 2011-12-22 19:21:46 +0000 | [diff] [blame] | 22 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
Johnny Chen | 24086bc | 2012-04-06 19:54:10 +0000 | [diff] [blame] | 23 | @dwarf_test |
Johnny Chen | 1d8ab8a | 2010-09-14 22:55:48 +0000 | [diff] [blame] | 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.""" |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 31 | exe = os.path.join(os.getcwd(), "a.out") |
Johnny Chen | ff3d01d | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 32 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 33 | |
| 34 | # Test that the debug symbols have Function f3 before Function f1. |
Johnny Chen | 9633214 | 2010-12-17 18:02:08 +0000 | [diff] [blame] | 35 | # Use "-s address" option to sort by address. |
| 36 | self.runCmd("image dump symtab -s address a.out") |
Johnny Chen | ff3d01d | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 37 | output = self.res.GetOutput() |
Johnny Chen | 9440d1c | 2010-09-13 16:59:11 +0000 | [diff] [blame] | 38 | mo_f3 = re.search("Code +.+f3", output) |
| 39 | mo_f1 = re.search("Code +.+f1", output) |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 40 | |
| 41 | # Match objects for f3 and f1 must exist and f3 must come before f1. |
Johnny Chen | 1794184 | 2010-08-09 23:44:24 +0000 | [diff] [blame] | 42 | self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(), |
| 43 | "Symbols have correct order by the order file") |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 44 | |
Johnny Chen | ff3d01d | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 45 | self.runCmd("run", RUN_COMPLETED) |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 46 | |
| 47 | |
| 48 | if __name__ == '__main__': |
Johnny Chen | a212495 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 49 | import atexit |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 50 | lldb.SBDebugger.Initialize() |
Johnny Chen | a212495 | 2010-08-05 21:23:45 +0000 | [diff] [blame] | 51 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
Johnny Chen | 7325883 | 2010-08-05 23:42:46 +0000 | [diff] [blame] | 52 | unittest2.main() |