42 lines · python
1"""2Test SBCompileUnit APIs.3"""4 5import lldb6from lldbsuite.test.decorators import *7from lldbsuite.test.lldbtest import *8from lldbsuite.test import lldbutil9 10 11class CompileUnitAPITestCase(TestBase):12 def test(self):13 """Exercise some SBCompileUnit APIs."""14 self.build()15 16 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(17 self, "break here", lldb.SBFileSpec("main.c")18 )19 self.assertTrue(target, VALID_TARGET)20 self.assertTrue(process, PROCESS_IS_VALID)21 self.assertTrue(bkpt and bkpt.GetNumLocations() == 1, VALID_BREAKPOINT)22 23 self.assertTrue(24 thread.IsValid(),25 "There should be a thread stopped due to breakpoint condition",26 )27 frame0 = thread.GetFrameAtIndex(0)28 line_entry = frame0.GetLineEntry()29 30 sc_list = target.FindCompileUnits(line_entry.GetFileSpec())31 self.assertGreater(sc_list.GetSize(), 0)32 33 main_cu = sc_list.compile_units[0]34 self.assertTrue(main_cu.IsValid(), "Main executable CU is not valid")35 36 self.assertEqual(37 main_cu.FindLineEntryIndex(line_entry, True),38 main_cu.FindLineEntryIndex(39 0, line_entry.GetLine(), line_entry.GetFileSpec(), True40 ),41 )42