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 @add_test_categories(["dwarf", "dwo"]) 12 def test_limit_debug_info(self): 13 self.build() 14 15 self._check_info_is_limited() 16 17 src_file = os.path.join(self.getSourceDir(), "main.cpp") 18 src_file_spec = lldb.SBFileSpec(src_file) 19 self.assertTrue(src_file_spec.IsValid(), "breakpoint file") 20 21 # Get the path of the executable 22 exe_path = self.getBuildArtifact("a.out") 23 24 # Load the executable 25 target = self.dbg.CreateTarget(exe_path) 26 self.assertTrue(target.IsValid(), VALID_TARGET) 27 28 # Break on main function 29 breakpoint = target.BreakpointCreateBySourceRegex( 30 "break here", src_file_spec) 31 self.assertTrue( 32 breakpoint.IsValid() and breakpoint.GetNumLocations() >= 1, 33 VALID_BREAKPOINT) 34 35 # Launch the process 36 process = target.LaunchSimple( 37 None, None, self.get_process_working_directory()) 38 self.assertTrue(process.IsValid(), PROCESS_IS_VALID) 39 40 # Get the thread of the process 41 self.assertEqual( 42 process.GetState(), lldb.eStateStopped, 43 PROCESS_STOPPED) 44 thread = lldbutil.get_stopped_thread( 45 process, lldb.eStopReasonBreakpoint) 46 thread.StepInto() 47 48 # Get frame for current thread 49 frame = thread.GetSelectedFrame() 50 51 self.expect_expr("1", result_type="int", result_value="1") 52 53 v2 = frame.EvaluateExpression("this") 54 self.assertTrue( 55 v2.IsValid(), 56 "'expr this' results in a valid SBValue object") 57 self.assertSuccess( 58 v2.GetError(), 59 "'expr this' succeeds without an error.") 60 61 def _check_info_is_limited(self): 62 target = self.dbg.CreateTarget(self.getBuildArtifact("main.o")) 63 self.assertTrue(target.IsValid()) 64 Foo = target.FindFirstType("Foo") 65 self.assertFalse(Foo.IsValid()) 66