[Lldb-commits] [lldb] d3505c2 - [lldb] Modify the DWARFDebugAbbrev interface to be closer to LLVM's (#67190)
via lldb-commits
lldb-commits at lists.llvm.org
Mon Sep 25 13:11:43 PDT 2023
Author: Alex Langford
Date: 2023-09-25T13:11:39-07:00
New Revision: d3505c28a770fabd77d7483afbca383d453bef02
URL: https://github.com/llvm/llvm-project/commit/d3505c28a770fabd77d7483afbca383d453bef02
DIFF: https://github.com/llvm/llvm-project/commit/d3505c28a770fabd77d7483afbca383d453bef02.diff
LOG: [lldb] Modify the DWARFDebugAbbrev interface to be closer to LLVM's (#67190)
I want to work towards unifying the implementations. It would be a lot
easier to do if LLDB's DWARFDebugAbbrev looked more similar to LLVM's
implementation, so this change moves in that direction.
Added:
Modified:
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
index 0cd53463ee65e08..bcebba6abd3ee5c 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
@@ -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();
}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
index 0a579e34b001337..6d0616deeb91038 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
@@ -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
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 04c729e333a9854..9832c324a2c0e55 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -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),
More information about the lldb-commits
mailing list