1"""Test that the 'add-dsym', aka 'target symbols add', succeeds in the middle of debug session."""
2
3
4
5import lldb
6from lldbsuite.test.decorators import *
7from lldbsuite.test.lldbtest import *
8from lldbsuite.test import lldbutil
9
10
11@skipUnlessDarwin
12class AddDsymMidExecutionCommandCase(TestBase):
13
14    def setUp(self):
15        # Call super's setUp().
16        TestBase.setUp(self)
17        self.source = 'main.c'
18
19    @no_debug_info_test  # Prevent the genaration of the dwarf version of this test
20    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.build(debug_info="dsym")
23        exe = self.getBuildArtifact("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")
32        self.process = self.target.LaunchSimple(
33            None, None, self.get_process_working_directory())
34        self.assertTrue(self.process, PROCESS_IS_VALID)
35
36        # The stop reason of the thread should be breakpoint.
37        self.assertState(self.process.GetState(), lldb.eStateStopped,
38                         STOPPED_DUE_TO_BREAKPOINT)
39
40        self.runCmd("add-dsym " +
41                    self.getBuildArtifact("hide.app/Contents/a.out.dSYM"))
42
43        self.expect("frame select",
44                    substrs=['a.out`main at main.c'])
45