Jason Molenda | 680a7d7 | 2013-08-15 02:49:16 +0000 | [diff] [blame^] | 1 | """Test that the 'add-dsym', aka 'target symbols add', succeeds in the middle of debug session.""" |
| 2 | |
| 3 | import os, time |
| 4 | import unittest2 |
| 5 | import lldb |
| 6 | import pexpect |
| 7 | from lldbtest import * |
| 8 | |
| 9 | @unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin") |
| 10 | class AddDsymMidExecutionCommandCase(TestBase): |
| 11 | |
| 12 | mydir = os.path.join ("macosx", "add-dsym") |
| 13 | |
| 14 | def setUp(self): |
| 15 | # Call super's setUp(). |
| 16 | TestBase.setUp(self) |
| 17 | self.source = 'main.c' |
| 18 | |
| 19 | def test_add_dsym_mid_execution(self): |
| 20 | """Test that add-dsym mid-execution loads the symbols at the right place for a slid binary.""" |
| 21 | self.buildDsym(clean=True) |
| 22 | exe = os.path.join(os.getcwd(), "a.out") |
| 23 | |
| 24 | self.target = self.dbg.CreateTarget(exe) |
| 25 | self.assertTrue(self.target, VALID_TARGET) |
| 26 | |
| 27 | main_bp = self.target.BreakpointCreateByName ("main", "a.out") |
| 28 | self.assertTrue(main_bp, VALID_BREAKPOINT) |
| 29 | |
| 30 | self.runCmd("settings set target.disable-aslr false") |
| 31 | self.process = self.target.LaunchSimple(None, None, os.getcwd()) |
| 32 | self.assertTrue(self.process, PROCESS_IS_VALID) |
| 33 | |
| 34 | # The stop reason of the thread should be breakpoint. |
| 35 | self.assertTrue(self.process.GetState() == lldb.eStateStopped, |
| 36 | STOPPED_DUE_TO_BREAKPOINT) |
| 37 | |
| 38 | self.runCmd("add-dsym hide.app/Contents/a.out.dSYM") |
| 39 | |
| 40 | self.expect("frame select", |
| 41 | substrs = ['a.out`main at main.c']) |
| 42 | |
| 43 | if __name__ == '__main__': |
| 44 | import atexit |
| 45 | lldb.SBDebugger.Initialize() |
| 46 | atexit.register(lambda: lldb.SBDebugger.Terminate()) |
| 47 | unittest2.main() |