diff --git a/lldb/bindings/interface/SBCompileUnit.i b/lldb/bindings/interface/SBCompileUnit.i --- a/lldb/bindings/interface/SBCompileUnit.i +++ b/lldb/bindings/interface/SBCompileUnit.i @@ -67,6 +67,9 @@ lldb::SBLineEntry GetLineEntryAtIndex (uint32_t idx) const; + uint32_t + GetIndexForLineEntry (const lldb::SBLineEntry &line_entry, bool exact = false) const; + uint32_t FindLineEntryIndex (uint32_t start_idx, uint32_t line, diff --git a/lldb/include/lldb/API/SBCompileUnit.h b/lldb/include/lldb/API/SBCompileUnit.h --- a/lldb/include/lldb/API/SBCompileUnit.h +++ b/lldb/include/lldb/API/SBCompileUnit.h @@ -34,6 +34,9 @@ lldb::SBLineEntry GetLineEntryAtIndex(uint32_t idx) const; + uint32_t GetIndexForLineEntry(const lldb::SBLineEntry &line_entry, + bool exact = false) const; + uint32_t FindLineEntryIndex(uint32_t start_idx, uint32_t line, lldb::SBFileSpec *inline_file_spec) const; diff --git a/lldb/source/API/SBCompileUnit.cpp b/lldb/source/API/SBCompileUnit.cpp --- a/lldb/source/API/SBCompileUnit.cpp +++ b/lldb/source/API/SBCompileUnit.cpp @@ -77,6 +77,28 @@ return sb_line_entry; } +uint32_t +SBCompileUnit::GetIndexForLineEntry(const lldb::SBLineEntry &line_entry, + bool exact) const { + LLDB_INSTRUMENT_VA(this, line_entry, exact); + + uint32_t index = UINT32_MAX; + if (m_opaque_ptr && line_entry.IsValid()) { + + LineEntry found_line_entry; + + uint32_t found_index = m_opaque_ptr->FindLineEntry( + 0, line_entry.GetLine(), line_entry.GetFileSpec().get(), exact, + &found_line_entry); + + if (!exact || + (exact && !LineEntry::Compare(line_entry.ref(), found_line_entry))) + index = found_index; + } + + return index; +} + uint32_t SBCompileUnit::FindLineEntryIndex(uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec) const { LLDB_INSTRUMENT_VA(this, start_idx, line, inline_file_spec);