blob: 3907e445da20615d77787f1be2f4e4b033ccede8 [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
Robert Flack13c7ad92015-03-30 14:12:17 +00009@skipUnlessDarwin
Jason Molenda680a7d72013-08-15 02:49:16 +000010class 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
Tamas Berghammerc8fd1302015-09-30 10:12:40 +000019 @no_debug_info_test # Prevent the genaration of the dwarf version of this test
Jason Molenda680a7d72013-08-15 02:49:16 +000020 def test_add_dsym_mid_execution(self):
21 """Test that add-dsym mid-execution loads the symbols at the right place for a slid binary."""
22 self.buildDsym(clean=True)
23 exe = os.path.join(os.getcwd(), "a.out")
24
25 self.target = self.dbg.CreateTarget(exe)
26 self.assertTrue(self.target, VALID_TARGET)
27
28 main_bp = self.target.BreakpointCreateByName ("main", "a.out")
29 self.assertTrue(main_bp, VALID_BREAKPOINT)
30
31 self.runCmd("settings set target.disable-aslr false")
Greg Claytonc6947512013-12-13 19:18:59 +000032 self.process = self.target.LaunchSimple (None, None, self.get_process_working_directory())
Jason Molenda680a7d72013-08-15 02:49:16 +000033 self.assertTrue(self.process, PROCESS_IS_VALID)
34
35 # The stop reason of the thread should be breakpoint.
36 self.assertTrue(self.process.GetState() == lldb.eStateStopped,
37 STOPPED_DUE_TO_BREAKPOINT)
38
39 self.runCmd("add-dsym hide.app/Contents/a.out.dSYM")
40
41 self.expect("frame select",
42 substrs = ['a.out`main at main.c'])
43
44if __name__ == '__main__':
45 import atexit
46 lldb.SBDebugger.Initialize()
47 atexit.register(lambda: lldb.SBDebugger.Terminate())
48 unittest2.main()