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 setUp(self): 14 TestBase.setUp(self) 15 16 def test(self): 17 """Exercise some SBCompileUnit APIs.""" 18 self.build() 19 20 (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 'break here', lldb.SBFileSpec('main.c')) 21 self.assertTrue(target, VALID_TARGET) 22 self.assertTrue(process, PROCESS_IS_VALID) 23 self.assertTrue(bkpt and bkpt.GetNumLocations() == 1, 24 VALID_BREAKPOINT) 25 26 self.assertTrue( 27 thread.IsValid(), 28 "There should be a thread stopped due to breakpoint condition") 29 frame0 = thread.GetFrameAtIndex(0) 30 line_entry = frame0.GetLineEntry() 31 32 sc_list = target.FindCompileUnits(line_entry.GetFileSpec()) 33 self.assertGreater(sc_list.GetSize(), 0) 34 35 main_cu = sc_list.compile_units[0] 36 self.assertTrue(main_cu.IsValid(), "Main executable CU is not valid") 37 38 self.assertEqual(main_cu.FindLineEntryIndex(line_entry, True), 39 main_cu.FindLineEntryIndex(0, line_entry.GetLine(), 40 line_entry.GetFileSpec(), True)) 41 42 43