blob: 22108f51fca57c84a6ac993d5f9fc4a67c90c37f [file] [log] [blame]
Jason Molenda680a7d72013-08-15 02:49:16 +00001"""Test that the 'add-dsym', aka 'target symbols add', succeeds in the middle of debug session."""
2
3import os, time
4import unittest2
5import lldb
Todd Fialae373b682014-03-25 18:55:48 +00006import sys
Jason Molenda680a7d72013-08-15 02:49:16 +00007from lldbtest import *
8
9@unittest2.skipUnless(sys.platform.startswith("darwin"), "requires Darwin")
10class AddDsymMidExecutionCommandCase(TestBase):
11
Greg Clayton4570d3e2013-12-10 23:19:29 +000012 mydir = TestBase.compute_mydir(__file__)
Jason Molenda680a7d72013-08-15 02:49:16 +000013
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")
Greg Claytonc6947512013-12-13 19:18:59 +000031 self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory())
Jason Molenda680a7d72013-08-15 02:49:16 +000032 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
43if __name__ == '__main__':
44 import atexit
45 lldb.SBDebugger.Initialize()
46 atexit.register(lambda: lldb.SBDebugger.Terminate())
47 unittest2.main()