2 Test that SBCompileUnit::FindLineEntryIndex works correctly.
6 import lldbsuite
.test
.lldbutil
as lldbutil
7 from lldbsuite
.test
.lldbtest
import *
10 class FindLineEntry(TestBase
):
11 def test_compile_unit_find_line_entry_index(self
):
12 """Test the CompileUnit LineEntryIndex lookup API"""
14 exe
= self
.getBuildArtifact("a.out")
15 self
.target
= self
.dbg
.CreateTarget(exe
)
16 self
.assertTrue(self
.target
.IsValid(), "Target is not valid")
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")
24 # First look for valid line
25 self
.line
= line_number("main.c", "int change_me")
27 cu
.FindLineEntryIndex(0, self
.line
, self
.file),
28 lldb
.LLDB_INVALID_LINE_NUMBER
,
31 # Then look for a line out of bound
33 cu
.FindLineEntryIndex(0, 42, self
.file), lldb
.LLDB_INVALID_LINE_NUMBER