51 lines · python
1""" Testing explicit symbol loading via target symbols add. """2import lldb3from lldbsuite.test.decorators import *4from lldbsuite.test.lldbtest import *5from lldbsuite.test import lldbutil6 7 8class TargetSymbolsAddCommand(TestBase):9 def setUp(self):10 TestBase.setUp(self)11 self.source = "main.c"12 13 @no_debug_info_test # Prevent the genaration of the dwarf version of this test14 @skipUnlessPlatform(["linux"])15 def test_target_symbols_add(self):16 """Test that 'target symbols add' can load the symbols17 even if gnu.build-id and gnu_debuglink are not present in the module.18 Similar to test_add_dsym_mid_execution test for macos."""19 self.build()20 exe = self.getBuildArtifact("stripped.out")21 22 self.target = self.dbg.CreateTarget(exe)23 self.assertTrue(self.target, VALID_TARGET)24 25 main_bp = self.target.BreakpointCreateByName("main", "stripped.out")26 self.assertTrue(main_bp, VALID_BREAKPOINT)27 28 self.process = self.target.LaunchSimple(29 None, None, self.get_process_working_directory()30 )31 self.assertTrue(self.process, PROCESS_IS_VALID)32 33 # The stop reason of the thread should be breakpoint.34 self.assertState(35 self.process.GetState(), lldb.eStateStopped, STOPPED_DUE_TO_BREAKPOINT36 )37 38 exe_module = self.target.GetModuleAtIndex(0)39 40 # Check that symbols are not loaded and main.c is not know to be41 # the source file.42 self.expect("frame select", substrs=["main.c"], matching=False)43 44 # Tell LLDB that a.out has symbols for stripped.out45 self.runCmd(46 "target symbols add -s %s %s" % (exe, self.getBuildArtifact("a.out"))47 )48 49 # Check that symbols are now loaded and main.c is in the output.50 self.expect("frame select", substrs=["main.c"])51