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