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 | |
Zachary Turner | 77db4a8 | 2015-10-22 20:06:20 +0000 | [diff] [blame^] | 5 | import lldb_shared |
| 6 | |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 7 | import os, time |
| 8 | import re |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 9 | import lldb |
Johnny Chen | 1794184 | 2010-08-09 23:44:24 +0000 | [diff] [blame] | 10 | from lldbtest import * |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 11 | |
Johnny Chen | cbb4be0 | 2010-09-01 19:59:58 +0000 | [diff] [blame] | 12 | class OrderFileTestCase(TestBase): |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 13 | |
Greg Clayton | 4570d3e | 2013-12-10 23:19:29 +0000 | [diff] [blame] | 14 | mydir = TestBase.compute_mydir(__file__) |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 15 | |
Robert Flack | 13c7ad9 | 2015-03-30 14:12:17 +0000 | [diff] [blame] | 16 | @skipUnlessDarwin |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 17 | def test(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.""" |
Tamas Berghammer | c8fd130 | 2015-09-30 10:12:40 +0000 | [diff] [blame] | 19 | self.build() |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 20 | exe = os.path.join(os.getcwd(), "a.out") |
Johnny Chen | ff3d01d | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 21 | self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 22 | |
| 23 | # Test that the debug symbols have Function f3 before Function f1. |
Johnny Chen | 9633214 | 2010-12-17 18:02:08 +0000 | [diff] [blame] | 24 | # Use "-s address" option to sort by address. |
| 25 | self.runCmd("image dump symtab -s address a.out") |
Johnny Chen | ff3d01d | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 26 | output = self.res.GetOutput() |
Johnny Chen | 9440d1c | 2010-09-13 16:59:11 +0000 | [diff] [blame] | 27 | mo_f3 = re.search("Code +.+f3", output) |
| 28 | mo_f1 = re.search("Code +.+f1", output) |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 29 | |
| 30 | # 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] | 31 | self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(), |
| 32 | "Symbols have correct order by the order file") |
Johnny Chen | acfbeff | 2010-07-08 00:17:29 +0000 | [diff] [blame] | 33 | |
Johnny Chen | ff3d01d | 2010-08-20 21:03:09 +0000 | [diff] [blame] | 34 | self.runCmd("run", RUN_COMPLETED) |