[Lldb-commits] [lldb] 36a5183 - [lldb][NFCI] Move functionality for getting unsupported DW_FORM values (#67579)
via lldb-commits
lldb-commits at lists.llvm.org
Thu Sep 28 12:18:13 PDT 2023
Author: Alex Langford
Date: 2023-09-28T12:18:08-07:00
New Revision: 36a518317fdaab377830f8d18ead9301b06e9e8d
URL: https://github.com/llvm/llvm-project/commit/36a518317fdaab377830f8d18ead9301b06e9e8d
DIFF: https://github.com/llvm/llvm-project/commit/36a518317fdaab377830f8d18ead9301b06e9e8d.diff
LOG: [lldb][NFCI] Move functionality for getting unsupported DW_FORM values (#67579)
The LLVM implementation of DWARFDebugAbbrev does not have a way of
listing all the DW_FORM values that have been parsed but are unsupported
or otherwise unknown. AFAICT this functionality does not exist in LLVM
at all. Since my primary goal is to unify the implementations and not
judge the usefulness or completeness of this functionality, I decided to
move it out of LLDB's implementation of DWARFDebugAbbrev for the time
being.
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 bcebba6abd3ee5c..f3c2755c5a527cc 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.cpp
@@ -61,13 +61,3 @@ DWARFDebugAbbrev::GetAbbreviationDeclarationSet(
return &(pos->second);
return nullptr;
}
-
-// DWARFDebugAbbrev::GetUnsupportedForms()
-void DWARFDebugAbbrev::GetUnsupportedForms(
- std::set<dw_form_t> &invalid_forms) const {
- for (const auto &pair : m_abbrevCollMap)
- for (const auto &decl : pair.second)
- for (const auto &attr : decl.attributes())
- if (!DWARFFormValue::FormIsSupported(attr.Form))
- invalid_forms.insert(attr.Form);
-}
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
index 6d0616deeb91038..d2fade0934c8a88 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
+++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAbbrev.h
@@ -36,7 +36,15 @@ class DWARFDebugAbbrev {
/// llvm::ErrorSuccess() on success, and an appropriate llvm::Error object
/// otherwise.
llvm::Error parse();
- void GetUnsupportedForms(std::set<dw_form_t> &invalid_forms) const;
+
+ DWARFAbbreviationDeclarationCollMapConstIter begin() const {
+ assert(!m_data && "Must call parse before iterating over DWARFDebugAbbrev");
+ return m_abbrevCollMap.begin();
+ }
+
+ DWARFAbbreviationDeclarationCollMapConstIter end() const {
+ return m_abbrevCollMap.end();
+ }
protected:
DWARFAbbreviationDeclarationCollMap m_abbrevCollMap;
diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
index 9832c324a2c0e55..aae481e2ae74177 100644
--- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
+++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
@@ -511,6 +511,20 @@ bool SymbolFileDWARF::SupportedVersion(uint16_t version) {
return version >= 2 && version <= 5;
}
+static std::set<dw_form_t> GetUnsupportedForms(DWARFDebugAbbrev *debug_abbrev) {
+ if (!debug_abbrev)
+ return {};
+
+ std::set<dw_form_t> unsupported_forms;
+ for (const auto &[_, decl_set] : *debug_abbrev)
+ for (const auto &decl : decl_set)
+ for (const auto &attr : decl.attributes())
+ if (!DWARFFormValue::FormIsSupported(attr.Form))
+ unsupported_forms.insert(attr.Form);
+
+ return unsupported_forms;
+}
+
uint32_t SymbolFileDWARF::CalculateAbilities() {
uint32_t abilities = 0;
if (m_objfile_sp != nullptr) {
@@ -540,19 +554,15 @@ uint32_t SymbolFileDWARF::CalculateAbilities() {
debug_abbrev_file_size = section->GetFileSize();
DWARFDebugAbbrev *abbrev = DebugAbbrev();
- if (abbrev) {
- std::set<dw_form_t> invalid_forms;
- abbrev->GetUnsupportedForms(invalid_forms);
- if (!invalid_forms.empty()) {
- StreamString error;
- error.Printf("unsupported DW_FORM value%s:",
- invalid_forms.size() > 1 ? "s" : "");
- for (auto form : invalid_forms)
- error.Printf(" %#x", form);
- m_objfile_sp->GetModule()->ReportWarning(
- "{0}", error.GetString().str().c_str());
- return 0;
- }
+ std::set<dw_form_t> unsupported_forms = GetUnsupportedForms(abbrev);
+ if (!unsupported_forms.empty()) {
+ StreamString error;
+ error.Printf("unsupported DW_FORM value%s:",
+ unsupported_forms.size() > 1 ? "s" : "");
+ for (auto form : unsupported_forms)
+ error.Printf(" %#x", form);
+ m_objfile_sp->GetModule()->ReportWarning("{0}", error.GetString());
+ return 0;
}
section =
More information about the lldb-commits
mailing list