mib created this revision. mib added reviewers: jingham, JDevlieghere. mib added a project: LLDB. Herald added a subscriber: arphaman. Herald added a project: All. mib requested review of this revision. Herald added a subscriber: lldb-commits.
This patch adds a new `GetIndexForLineEntry` method to the `SBCompileUnit` class. As the name suggests, given an `SBLineEntry` object, this will return the line entry index within a specific compile unit. This method can take a `exact` boolean that will make sure that the provided line entry matches perfectly another line entry in the compile unit. rdar://47450887 Signed-off-by: Med Ismail Bennani <medismail.benn...@gmail.com> Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D125437 Files: lldb/bindings/interface/SBCompileUnit.i lldb/include/lldb/API/SBCompileUnit.h lldb/source/API/SBCompileUnit.cpp Index: lldb/source/API/SBCompileUnit.cpp =================================================================== --- lldb/source/API/SBCompileUnit.cpp +++ 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); Index: lldb/include/lldb/API/SBCompileUnit.h =================================================================== --- lldb/include/lldb/API/SBCompileUnit.h +++ 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; Index: lldb/bindings/interface/SBCompileUnit.i =================================================================== --- lldb/bindings/interface/SBCompileUnit.i +++ 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,
Index: lldb/source/API/SBCompileUnit.cpp =================================================================== --- lldb/source/API/SBCompileUnit.cpp +++ 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); Index: lldb/include/lldb/API/SBCompileUnit.h =================================================================== --- lldb/include/lldb/API/SBCompileUnit.h +++ 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; Index: lldb/bindings/interface/SBCompileUnit.i =================================================================== --- lldb/bindings/interface/SBCompileUnit.i +++ 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,
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits