1import lldb
2from lldbsuite.test.decorators import *
3from lldbsuite.test.lldbtest import *
4from lldbsuite.test import lldbutil
5
6
7class TestWithLimitDebugInfo(TestBase):
8
9    @add_test_categories(["dwarf", "dwo"])
10    def test_limit_debug_info(self):
11        self.build()
12
13        src_file = os.path.join(self.getSourceDir(), "main.cpp")
14        src_file_spec = lldb.SBFileSpec(src_file)
15        self.assertTrue(src_file_spec.IsValid(), "breakpoint file")
16
17        # Get the path of the executable
18        exe_path = self.getBuildArtifact("a.out")
19
20        # Load the executable
21        target = self.dbg.CreateTarget(exe_path)
22        self.assertTrue(target.IsValid(), VALID_TARGET)
23
24        # Break on main function
25        breakpoint = target.BreakpointCreateBySourceRegex(
26            "break here", src_file_spec)
27        self.assertTrue(
28            breakpoint.IsValid() and breakpoint.GetNumLocations() >= 1,
29            VALID_BREAKPOINT)
30
31        # Launch the process
32        process = target.LaunchSimple(
33            None, None, self.get_process_working_directory())
34        self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
35
36        # Get the thread of the process
37        self.assertEqual(
38            process.GetState(), lldb.eStateStopped,
39            PROCESS_STOPPED)
40        thread = lldbutil.get_stopped_thread(
41            process, lldb.eStopReasonBreakpoint)
42        thread.StepInto()
43
44        # Get frame for current thread
45        frame = thread.GetSelectedFrame()
46
47        self.expect_expr("1", result_type="int", result_value="1")
48
49        v2 = frame.EvaluateExpression("this")
50        self.assertTrue(
51            v2.IsValid(),
52            "'expr this' results in a valid SBValue object")
53        self.assertSuccess(
54            v2.GetError(),
55            "'expr this' succeeds without an error.")
56