Skip to content

[lldb] Modify the DWARFDebugAbbrev interface to be closer to LLVM's #67190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,30 @@ using namespace lldb;
using namespace lldb_private;

// DWARFDebugAbbrev constructor
DWARFDebugAbbrev::DWARFDebugAbbrev()
: m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()) {}
DWARFDebugAbbrev::DWARFDebugAbbrev(const DWARFDataExtractor &data)
: m_abbrevCollMap(), m_prev_abbr_offset_pos(m_abbrevCollMap.end()),
m_data(data.GetAsLLVM()) {}

// DWARFDebugAbbrev::Parse()
llvm::Error DWARFDebugAbbrev::parse(const DWARFDataExtractor &data) {
llvm::DataExtractor llvm_data = data.GetAsLLVM();
llvm::Error DWARFDebugAbbrev::parse() {
if (!m_data)
return llvm::Error::success();

lldb::offset_t offset = 0;

while (llvm_data.isValidOffset(offset)) {
while (m_data->isValidOffset(offset)) {
uint32_t initial_cu_offset = offset;
DWARFAbbreviationDeclarationSet abbrevDeclSet;

llvm::Error error = abbrevDeclSet.extract(llvm_data, &offset);
if (error)
llvm::Error error = abbrevDeclSet.extract(*m_data, &offset);
if (error) {
m_data = std::nullopt;
return error;
}

m_abbrevCollMap[initial_cu_offset] = abbrevDeclSet;
}
m_data = std::nullopt;
m_prev_abbr_offset_pos = m_abbrevCollMap.end();
return llvm::ErrorSuccess();
}
Expand Down
5 changes: 3 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ typedef DWARFAbbreviationDeclarationCollMap::const_iterator

class DWARFDebugAbbrev {
public:
DWARFDebugAbbrev();
DWARFDebugAbbrev(const lldb_private::DWARFDataExtractor &data);
const DWARFAbbreviationDeclarationSet *
GetAbbreviationDeclarationSet(dw_offset_t cu_abbr_offset) const;
/// Extract all abbreviations for a particular compile unit. Returns
/// llvm::ErrorSuccess() on success, and an appropriate llvm::Error object
/// otherwise.
llvm::Error parse(const lldb_private::DWARFDataExtractor &data);
llvm::Error parse();
void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const;

protected:
DWARFAbbreviationDeclarationCollMap m_abbrevCollMap;
mutable DWARFAbbreviationDeclarationCollMapConstIter m_prev_abbr_offset_pos;
mutable std::optional<llvm::DataExtractor> m_data;
};

#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGABBREV_H
4 changes: 2 additions & 2 deletions lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ DWARFDebugAbbrev *SymbolFileDWARF::DebugAbbrev() {
if (debug_abbrev_data.GetByteSize() == 0)
return nullptr;

auto abbr = std::make_unique<DWARFDebugAbbrev>();
llvm::Error error = abbr->parse(debug_abbrev_data);
auto abbr = std::make_unique<DWARFDebugAbbrev>(debug_abbrev_data);
llvm::Error error = abbr->parse();
if (error) {
Log *log = GetLog(DWARFLog::DebugInfo);
LLDB_LOG_ERROR(log, std::move(error),
Expand Down