brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.1 KiB · 3f1760e Raw
35 lines · python
1"""2Test that SBCompileUnit::FindLineEntryIndex works correctly.3"""4 5import lldb6import lldbsuite.test.lldbutil as lldbutil7from lldbsuite.test.lldbtest import *8 9 10class FindLineEntry(TestBase):11    def test_compile_unit_find_line_entry_index(self):12        """Test the CompileUnit LineEntryIndex lookup API"""13        self.build()14        exe = self.getBuildArtifact("a.out")15        self.target = self.dbg.CreateTarget(exe)16        self.assertTrue(self.target.IsValid(), "Target is not valid")17 18        self.file = lldb.SBFileSpec("main.c")19        sc_list = self.target.FindCompileUnits(self.file)20        self.assertEqual(len(sc_list), 1)21        cu = sc_list[0].GetCompileUnit()22        self.assertTrue(cu.IsValid(), "CompileUnit is not valid")23 24        # First look for valid line25        self.line = line_number("main.c", "int change_me")26        self.assertNotEqual(27            cu.FindLineEntryIndex(0, self.line, self.file),28            lldb.LLDB_INVALID_LINE_NUMBER,29        )30 31        # Then look for a line out of bound32        self.assertEqual(33            cu.FindLineEntryIndex(0, 42, self.file), lldb.LLDB_INVALID_LINE_NUMBER34        )35