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