https://github.com/walter-erquinigo updated https://github.com/llvm/llvm-project/pull/68150
>From 52f91bcf453790f89626b9d597671c17d0102dcb Mon Sep 17 00:00:00 2001 From: walter erquinigo <wal...@modular.com> Date: Mon, 2 Oct 2023 16:56:16 -0400 Subject: [PATCH] [LLDB][NFC] Create a namespace for the DWARF plugin As a followup of https://github.com/llvm/llvm-project/pull/67851, I'm defining a new namespace `lldb_plugin::dwarf` for the classes in this Plugins/SymbolFile/DWARF folder. This change is very NFC and helped me with exporting the necessary symbols for my out-of-tree language plugin. The only two classes that I didn't change are DWARFDataExtractor, because that's being explicitly exported as part of lldb_private in `lldb-forward.h` , and the ClangDWARFASTParser, because that shouldn't be in the same namespace as the generic language-agnostic dwarf parser, but I'm okay with changing that. In any case, even if I didn't need this for my work, adding this namespace could be considered a good practice. --- .../include/lldb/Expression/DWARFExpression.h | 26 ++- .../lldb/Expression/DWARFExpressionList.h | 11 +- lldb/include/lldb/Symbol/TypeSystem.h | 10 +- lldb/source/Expression/DWARFExpression.cpp | 1 + .../SymbolFile/DWARF/AppleDWARFIndex.cpp | 1 + .../SymbolFile/DWARF/AppleDWARFIndex.h | 37 ++-- .../Plugins/SymbolFile/DWARF/DIERef.cpp | 1 + lldb/source/Plugins/SymbolFile/DWARF/DIERef.h | 9 +- .../SymbolFile/DWARF/DWARFASTParser.cpp | 1 + .../Plugins/SymbolFile/DWARF/DWARFASTParser.h | 7 +- .../SymbolFile/DWARF/DWARFASTParserClang.cpp | 2 + .../SymbolFile/DWARF/DWARFASTParserClang.h | 160 ++++++++++-------- .../SymbolFile/DWARF/DWARFAttribute.cpp | 1 + .../Plugins/SymbolFile/DWARF/DWARFAttribute.h | 5 + .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp | 7 +- .../Plugins/SymbolFile/DWARF/DWARFBaseDIE.h | 4 + .../SymbolFile/DWARF/DWARFCompileUnit.cpp | 1 + .../SymbolFile/DWARF/DWARFCompileUnit.h | 6 +- .../Plugins/SymbolFile/DWARF/DWARFContext.cpp | 1 + .../Plugins/SymbolFile/DWARF/DWARFContext.h | 50 +++--- .../Plugins/SymbolFile/DWARF/DWARFDIE.cpp | 1 + .../Plugins/SymbolFile/DWARF/DWARFDIE.h | 4 + .../SymbolFile/DWARF/DWARFDataExtractor.h | 2 +- .../SymbolFile/DWARF/DWARFDebugArangeSet.cpp | 1 + .../SymbolFile/DWARF/DWARFDebugArangeSet.h | 4 + .../SymbolFile/DWARF/DWARFDebugAranges.cpp | 1 + .../SymbolFile/DWARF/DWARFDebugAranges.h | 4 + .../SymbolFile/DWARF/DWARFDebugInfo.cpp | 4 +- .../Plugins/SymbolFile/DWARF/DWARFDebugInfo.h | 14 +- .../SymbolFile/DWARF/DWARFDebugInfoEntry.cpp | 1 + .../SymbolFile/DWARF/DWARFDebugInfoEntry.h | 4 + .../SymbolFile/DWARF/DWARFDebugMacro.cpp | 1 + .../SymbolFile/DWARF/DWARFDebugMacro.h | 8 +- .../SymbolFile/DWARF/DWARFDebugRanges.cpp | 1 + .../SymbolFile/DWARF/DWARFDebugRanges.h | 8 +- .../SymbolFile/DWARF/DWARFDeclContext.cpp | 1 + .../SymbolFile/DWARF/DWARFDeclContext.h | 4 + .../Plugins/SymbolFile/DWARF/DWARFDefines.cpp | 6 +- .../Plugins/SymbolFile/DWARF/DWARFDefines.h | 6 +- .../SymbolFile/DWARF/DWARFFormValue.cpp | 1 + .../Plugins/SymbolFile/DWARF/DWARFFormValue.h | 6 +- .../Plugins/SymbolFile/DWARF/DWARFIndex.cpp | 1 + .../Plugins/SymbolFile/DWARF/DWARFIndex.h | 45 ++--- .../SymbolFile/DWARF/DWARFTypeUnit.cpp | 1 + .../Plugins/SymbolFile/DWARF/DWARFTypeUnit.h | 6 +- .../Plugins/SymbolFile/DWARF/DWARFUnit.cpp | 28 +-- .../Plugins/SymbolFile/DWARF/DWARFUnit.h | 19 ++- .../SymbolFile/DWARF/DebugNamesDWARFIndex.cpp | 3 +- .../SymbolFile/DWARF/DebugNamesDWARFIndex.h | 41 ++--- .../SymbolFile/DWARF/ManualDWARFIndex.cpp | 1 + .../SymbolFile/DWARF/ManualDWARFIndex.h | 39 +++-- .../Plugins/SymbolFile/DWARF/NameToDIE.cpp | 1 + .../Plugins/SymbolFile/DWARF/NameToDIE.h | 7 +- .../SymbolFile/DWARF/SymbolFileDWARF.cpp | 10 +- .../SymbolFile/DWARF/SymbolFileDWARF.h | 23 ++- .../DWARF/SymbolFileDWARFDebugMap.cpp | 5 + .../DWARF/SymbolFileDWARFDebugMap.h | 15 +- .../SymbolFile/DWARF/SymbolFileDWARFDwo.cpp | 1 + .../SymbolFile/DWARF/SymbolFileDWARFDwo.h | 11 +- .../SymbolFile/DWARF/UniqueDWARFASTType.cpp | 1 + .../SymbolFile/DWARF/UniqueDWARFASTType.h | 7 +- .../TypeSystem/Clang/TypeSystemClang.cpp | 1 + .../TypeSystem/Clang/TypeSystemClang.h | 2 +- 63 files changed, 440 insertions(+), 251 deletions(-) diff --git a/lldb/include/lldb/Expression/DWARFExpression.h b/lldb/include/lldb/Expression/DWARFExpression.h index 5e03f539a272cac..624c189223981fa 100644 --- a/lldb/include/lldb/Expression/DWARFExpression.h +++ b/lldb/include/lldb/Expression/DWARFExpression.h @@ -18,7 +18,11 @@ #include "llvm/DebugInfo/DWARF/DWARFLocationExpression.h" #include <functional> +namespace lldb_plugin { +namespace dwarf { class DWARFUnit; +} // namespace dwarf +} // namespace lldb_plugin namespace lldb_private { @@ -64,18 +68,21 @@ class DWARFExpression { /// \return /// The address specified by the operation, if the operation exists, or /// LLDB_INVALID_ADDRESS otherwise. - lldb::addr_t GetLocation_DW_OP_addr(const DWARFUnit *dwarf_cu, - bool &error) const; + lldb::addr_t + GetLocation_DW_OP_addr(const lldb_plugin::dwarf::DWARFUnit *dwarf_cu, + bool &error) const; - bool Update_DW_OP_addr(const DWARFUnit *dwarf_cu, lldb::addr_t file_addr); + bool Update_DW_OP_addr(const lldb_plugin::dwarf::DWARFUnit *dwarf_cu, + lldb::addr_t file_addr); void UpdateValue(uint64_t const_value, lldb::offset_t const_value_byte_size, uint8_t addr_byte_size); - bool ContainsThreadLocalStorage(const DWARFUnit *dwarf_cu) const; + bool ContainsThreadLocalStorage( + const lldb_plugin::dwarf::DWARFUnit *dwarf_cu) const; bool LinkThreadLocalStorage( - const DWARFUnit *dwarf_cu, + const lldb_plugin::dwarf::DWARFUnit *dwarf_cu, std::function<lldb::addr_t(lldb::addr_t file_addr)> const &link_address_callback); @@ -128,15 +135,16 @@ class DWARFExpression { /// details of the failure are provided through it. static bool Evaluate(ExecutionContext *exe_ctx, RegisterContext *reg_ctx, lldb::ModuleSP module_sp, const DataExtractor &opcodes, - const DWARFUnit *dwarf_cu, + const lldb_plugin::dwarf::DWARFUnit *dwarf_cu, const lldb::RegisterKind reg_set, const Value *initial_value_ptr, const Value *object_address_ptr, Value &result, Status *error_ptr); - static bool ParseDWARFLocationList(const DWARFUnit *dwarf_cu, - const DataExtractor &data, - DWARFExpressionList *loc_list); + static bool + ParseDWARFLocationList(const lldb_plugin::dwarf::DWARFUnit *dwarf_cu, + const DataExtractor &data, + DWARFExpressionList *loc_list); bool GetExpressionData(DataExtractor &data) const { data = m_data; diff --git a/lldb/include/lldb/Expression/DWARFExpressionList.h b/lldb/include/lldb/Expression/DWARFExpressionList.h index c0939647056dcbf..195bbcd5c13aa5c 100644 --- a/lldb/include/lldb/Expression/DWARFExpressionList.h +++ b/lldb/include/lldb/Expression/DWARFExpressionList.h @@ -13,7 +13,11 @@ #include "lldb/Utility/RangeMap.h" #include "lldb/lldb-private.h" +namespace lldb_plugin { +namespace dwarf { class DWARFUnit; +} // namespace dwarf +} // namespace lldb_plugin namespace lldb_private { @@ -24,13 +28,14 @@ class DWARFExpressionList { public: DWARFExpressionList() = default; - DWARFExpressionList(lldb::ModuleSP module_sp, const DWARFUnit *dwarf_cu, + DWARFExpressionList(lldb::ModuleSP module_sp, + const lldb_plugin::dwarf::DWARFUnit *dwarf_cu, lldb::addr_t func_file_addr) : m_module_wp(module_sp), m_dwarf_cu(dwarf_cu), m_func_file_addr(func_file_addr) {} DWARFExpressionList(lldb::ModuleSP module_sp, DWARFExpression expr, - const DWARFUnit *dwarf_cu) + const lldb_plugin::dwarf::DWARFUnit *dwarf_cu) : m_module_wp(module_sp), m_dwarf_cu(dwarf_cu) { AddExpression(0, LLDB_INVALID_ADDRESS, expr); } @@ -136,7 +141,7 @@ class DWARFExpressionList { /// The DWARF compile unit this expression belongs to. It is used to evaluate /// values indexing into the .debug_addr section (e.g. DW_OP_GNU_addr_index, /// DW_OP_GNU_const_index) - const DWARFUnit *m_dwarf_cu = nullptr; + const lldb_plugin::dwarf::DWARFUnit *m_dwarf_cu = nullptr; // Function base file address. lldb::addr_t m_func_file_addr = LLDB_INVALID_ADDRESS; diff --git a/lldb/include/lldb/Symbol/TypeSystem.h b/lldb/include/lldb/Symbol/TypeSystem.h index eb6e453e1aec0d0..f141fe62c7750aa 100644 --- a/lldb/include/lldb/Symbol/TypeSystem.h +++ b/lldb/include/lldb/Symbol/TypeSystem.h @@ -28,8 +28,13 @@ #include "lldb/Symbol/CompilerDeclContext.h" #include "lldb/lldb-private.h" +namespace lldb_plugin { +namespace dwarf { class DWARFDIE; class DWARFASTParser; +} // namespace dwarf +} // namespace lldb_plugin + class PDBASTParser; namespace lldb_private { @@ -93,7 +98,10 @@ class TypeSystem : public PluginInterface, /// removing all the TypeSystems from the TypeSystemMap. virtual void Finalize() {} - virtual DWARFASTParser *GetDWARFParser() { return nullptr; } + virtual lldb_plugin::dwarf::DWARFASTParser *GetDWARFParser() { + return nullptr; + } + virtual PDBASTParser *GetPDBParser() { return nullptr; } virtual npdb::PdbAstBuilder *GetNativePDBParser() { return nullptr; } diff --git a/lldb/source/Expression/DWARFExpression.cpp b/lldb/source/Expression/DWARFExpression.cpp index 93fcf0579be0b18..18528d78f1cf01b 100644 --- a/lldb/source/Expression/DWARFExpression.cpp +++ b/lldb/source/Expression/DWARFExpression.cpp @@ -45,6 +45,7 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; // DWARFExpression constructor DWARFExpression::DWARFExpression() : m_data() {} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp index 34fb98b5a9b690a..286fadfb2dcdaf6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.cpp @@ -18,6 +18,7 @@ using namespace lldb_private; using namespace lldb; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; std::unique_ptr<AppleDWARFIndex> AppleDWARFIndex::Create( Module &module, DWARFDataExtractor apple_names, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h index 6b948e07989531e..910c31881a72b31 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/AppleDWARFIndex.h @@ -12,15 +12,19 @@ #include "Plugins/SymbolFile/DWARF/DWARFIndex.h" #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" -namespace lldb_private { +namespace lldb_plugin { +namespace dwarf { class AppleDWARFIndex : public DWARFIndex { public: static std::unique_ptr<AppleDWARFIndex> - Create(Module &module, DWARFDataExtractor apple_names, - DWARFDataExtractor apple_namespaces, DWARFDataExtractor apple_types, - DWARFDataExtractor apple_objc, DWARFDataExtractor debug_str); + Create(lldb_private::Module &module, + lldb_private::DWARFDataExtractor apple_names, + lldb_private::DWARFDataExtractor apple_namespaces, + lldb_private::DWARFDataExtractor apple_types, + lldb_private::DWARFDataExtractor apple_objc, + lldb_private::DWARFDataExtractor debug_str); - AppleDWARFIndex(Module &module, + AppleDWARFIndex(lldb_private::Module &module, std::unique_ptr<llvm::AppleAcceleratorTable> apple_names, std::unique_ptr<llvm::AppleAcceleratorTable> apple_namespaces, std::unique_ptr<llvm::AppleAcceleratorTable> apple_types, @@ -33,33 +37,33 @@ class AppleDWARFIndex : public DWARFIndex { void Preload() override {} void - GetGlobalVariables(ConstString basename, + GetGlobalVariables(lldb_private::ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) override; void - GetGlobalVariables(const RegularExpression ®ex, + GetGlobalVariables(const lldb_private::RegularExpression ®ex, llvm::function_ref<bool(DWARFDIE die)> callback) override; void GetGlobalVariables(DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetObjCMethods(ConstString class_name, + void GetObjCMethods(lldb_private::ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) override; void GetCompleteObjCClass( - ConstString class_name, bool must_be_implementation, + lldb_private::ConstString class_name, bool must_be_implementation, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetTypes(ConstString name, + void GetTypes(lldb_private::ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) override; void GetTypes(const DWARFDeclContext &context, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetNamespaces(ConstString name, + void GetNamespaces(lldb_private::ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetFunctions(const Module::LookupInfo &lookup_info, + void GetFunctions(const lldb_private::Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, - const CompilerDeclContext &parent_decl_ctx, + const lldb_private::CompilerDeclContext &parent_decl_ctx, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetFunctions(const RegularExpression ®ex, + void GetFunctions(const lldb_private::RegularExpression ®ex, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void Dump(Stream &s) override; + void Dump(lldb_private::Stream &s) override; private: std::unique_ptr<llvm::AppleAcceleratorTable> m_apple_names_up; @@ -77,6 +81,7 @@ class AppleDWARFIndex : public DWARFIndex { std::optional<dw_tag_t> search_for_tag = std::nullopt, std::optional<uint32_t> search_for_qualhash = std::nullopt); }; -} // namespace lldb_private +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_APPLEDWARFINDEX_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp index 88a5e6027557b9b..d4c6b043fec359c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.cpp @@ -14,6 +14,7 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; void llvm::format_provider<DIERef>::format(const DIERef &ref, raw_ostream &OS, StringRef Style) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h index b5a5cfe263f7804..51f729a5ae83dce 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DIERef.h @@ -14,6 +14,8 @@ #include <cassert> #include <optional> +namespace lldb_plugin { +namespace dwarf { /// Identifies a DWARF debug info entry within a given Module. It contains three /// "coordinates": /// - file_index: identifies the separate stand alone debug info file @@ -131,10 +133,13 @@ class DIERef { static_assert(sizeof(DIERef) == 8); typedef std::vector<DIERef> DIEArray; +} // namespace dwarf +} // namespace lldb_plugin namespace llvm { -template<> struct format_provider<DIERef> { - static void format(const DIERef &ref, raw_ostream &OS, StringRef Style); +template <> struct format_provider<lldb_plugin::dwarf::DIERef> { + static void format(const lldb_plugin::dwarf::DIERef &ref, raw_ostream &OS, + StringRef Style); }; } // namespace llvm diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp index a68b7cd110eb719..06be740ad398d7d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.cpp @@ -18,6 +18,7 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; std::optional<SymbolFile::ArrayInfo> DWARFASTParser::ParseChildArrayInfo(const DWARFDIE &parent_die, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h index 18825ae060b12fe..5a67b8a369e8f25 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParser.h @@ -17,11 +17,14 @@ #include "lldb/lldb-enumerations.h" #include <optional> -class DWARFDIE; namespace lldb_private { class CompileUnit; class ExecutionContext; } + +namespace lldb_plugin { +namespace dwarf { +class DWARFDIE; class SymbolFileDWARF; class DWARFASTParser { @@ -65,5 +68,7 @@ class DWARFASTParser { static lldb::AccessType GetAccessTypeFromDWARF(uint32_t dwarf_accessibility); }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFASTPARSER_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp index d0065896b0d2292..4cb9940e97b096b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp @@ -60,6 +60,8 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; + DWARFASTParserClang::DWARFASTParserClang(TypeSystemClang &ast) : m_ast(ast), m_die_to_decl_ctx(), m_decl_ctx_to_die() {} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h index 88bfc490e890744..efc78555e6d6ba3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.h @@ -31,12 +31,16 @@ namespace lldb_private { class CompileUnit; } +namespace lldb_plugin { +namespace dwarf { class DWARFDebugInfoEntry; class SymbolFileDWARF; +} // namespace dwarf +} // namespace lldb_plugin struct ParsedDWARFTypeAttributes; -class DWARFASTParserClang : public DWARFASTParser { +class DWARFASTParserClang : public lldb_plugin::dwarf::DWARFASTParser { public: DWARFASTParserClang(lldb_private::TypeSystemClang &ast); @@ -44,32 +48,33 @@ class DWARFASTParserClang : public DWARFASTParser { // DWARFASTParser interface. lldb::TypeSP ParseTypeFromDWARF(const lldb_private::SymbolContext &sc, - const DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &die, bool *type_is_new_ptr) override; - lldb_private::ConstString - ConstructDemangledNameFromDWARF(const DWARFDIE &die) override; + lldb_private::ConstString ConstructDemangledNameFromDWARF( + const lldb_plugin::dwarf::DWARFDIE &die) override; lldb_private::Function * ParseFunctionFromDWARF(lldb_private::CompileUnit &comp_unit, - const DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &die, const lldb_private::AddressRange &func_range) override; bool - CompleteTypeFromDWARF(const DWARFDIE &die, lldb_private::Type *type, + CompleteTypeFromDWARF(const lldb_plugin::dwarf::DWARFDIE &die, + lldb_private::Type *type, lldb_private::CompilerType &compiler_type) override; lldb_private::CompilerDecl - GetDeclForUIDFromDWARF(const DWARFDIE &die) override; + GetDeclForUIDFromDWARF(const lldb_plugin::dwarf::DWARFDIE &die) override; void EnsureAllDIEsInDeclContextHaveBeenParsed( lldb_private::CompilerDeclContext decl_context) override; - lldb_private::CompilerDeclContext - GetDeclContextForUIDFromDWARF(const DWARFDIE &die) override; + lldb_private::CompilerDeclContext GetDeclContextForUIDFromDWARF( + const lldb_plugin::dwarf::DWARFDIE &die) override; - lldb_private::CompilerDeclContext - GetDeclContextContainingUIDFromDWARF(const DWARFDIE &die) override; + lldb_private::CompilerDeclContext GetDeclContextContainingUIDFromDWARF( + const lldb_plugin::dwarf::DWARFDIE &die) override; lldb_private::ClangASTImporter &GetClangASTImporter(); @@ -85,9 +90,9 @@ class DWARFASTParserClang : public DWARFASTParser { /// DWARFFormValue with the bit width of the given integer type. /// Returns an error if the value in the DWARFFormValue does not fit /// into the given integer type or the integer type isn't supported. - llvm::Expected<llvm::APInt> - ExtractIntFromFormValue(const lldb_private::CompilerType &int_type, - const DWARFFormValue &form_value) const; + llvm::Expected<llvm::APInt> ExtractIntFromFormValue( + const lldb_private::CompilerType &int_type, + const lldb_plugin::dwarf::DWARFFormValue &form_value) const; /// Returns the template parameters of a class DWARFDIE as a string. /// @@ -100,7 +105,7 @@ class DWARFASTParserClang : public DWARFASTParser { /// If the DIE's name already has '<>', returns an empty ConstString because /// it's assumed that the caller is using the DIE name anyway. lldb_private::ConstString - GetDIEClassTemplateParams(const DWARFDIE &die) override; + GetDIEClassTemplateParams(const lldb_plugin::dwarf::DWARFDIE &die) override; protected: /// Protected typedefs and members. @@ -108,14 +113,17 @@ class DWARFASTParserClang : public DWARFASTParser { class DelayedAddObjCClassProperty; typedef std::vector<DelayedAddObjCClassProperty> DelayedPropertyList; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::DeclContext *> + typedef llvm::DenseMap<const lldb_plugin::dwarf::DWARFDebugInfoEntry *, + clang::DeclContext *> DIEToDeclContextMap; - typedef std::multimap<const clang::DeclContext *, const DWARFDIE> + typedef std::multimap<const clang::DeclContext *, + const lldb_plugin::dwarf::DWARFDIE> DeclContextToDIEMap; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, + typedef llvm::DenseMap<const lldb_plugin::dwarf::DWARFDebugInfoEntry *, lldb_private::OptionalClangModuleID> DIEToModuleMap; - typedef llvm::DenseMap<const DWARFDebugInfoEntry *, clang::Decl *> + typedef llvm::DenseMap<const lldb_plugin::dwarf::DWARFDebugInfoEntry *, + clang::Decl *> DIEToDeclMap; lldb_private::TypeSystemClang &m_ast; @@ -126,11 +134,13 @@ class DWARFASTParserClang : public DWARFASTParser { std::unique_ptr<lldb_private::ClangASTImporter> m_clang_ast_importer_up; /// @} - clang::DeclContext *GetDeclContextForBlock(const DWARFDIE &die); + clang::DeclContext * + GetDeclContextForBlock(const lldb_plugin::dwarf::DWARFDIE &die); - clang::BlockDecl *ResolveBlockDIE(const DWARFDIE &die); + clang::BlockDecl *ResolveBlockDIE(const lldb_plugin::dwarf::DWARFDIE &die); - clang::NamespaceDecl *ResolveNamespaceDIE(const DWARFDIE &die); + clang::NamespaceDecl * + ResolveNamespaceDIE(const lldb_plugin::dwarf::DWARFDIE &die); /// Returns the namespace decl that a DW_TAG_imported_declaration imports. /// @@ -141,31 +151,34 @@ class DWARFASTParserClang : public DWARFASTParser { /// 'die' imports. If the imported entity is not a namespace /// or another import declaration, returns nullptr. If an error /// occurs, returns nullptr. - clang::NamespaceDecl *ResolveImportedDeclarationDIE(const DWARFDIE &die); + clang::NamespaceDecl * + ResolveImportedDeclarationDIE(const lldb_plugin::dwarf::DWARFDIE &die); - bool ParseTemplateDIE(const DWARFDIE &die, + bool ParseTemplateDIE(const lldb_plugin::dwarf::DWARFDIE &die, lldb_private::TypeSystemClang::TemplateParameterInfos &template_param_infos); bool ParseTemplateParameterInfos( - const DWARFDIE &parent_die, + const lldb_plugin::dwarf::DWARFDIE &parent_die, lldb_private::TypeSystemClang::TemplateParameterInfos &template_param_infos); - std::string GetCPlusPlusQualifiedName(const DWARFDIE &die); + std::string + GetCPlusPlusQualifiedName(const lldb_plugin::dwarf::DWARFDIE &die); bool ParseChildMembers( - const DWARFDIE &die, lldb_private::CompilerType &class_compiler_type, + const lldb_plugin::dwarf::DWARFDIE &die, + lldb_private::CompilerType &class_compiler_type, std::vector<std::unique_ptr<clang::CXXBaseSpecifier>> &base_classes, - std::vector<DWARFDIE> &member_function_dies, + std::vector<lldb_plugin::dwarf::DWARFDIE> &member_function_dies, DelayedPropertyList &delayed_properties, const lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info); size_t ParseChildParameters(clang::DeclContext *containing_decl_ctx, - const DWARFDIE &parent_die, bool skip_artificial, - bool &is_static, bool &is_variadic, + const lldb_plugin::dwarf::DWARFDIE &parent_die, + bool skip_artificial, bool &is_static, bool &is_variadic, bool &has_template_params, std::vector<lldb_private::CompilerType> &function_args, std::vector<clang::ParmVarDecl *> &function_param_decls, @@ -173,33 +186,40 @@ class DWARFASTParserClang : public DWARFASTParser { size_t ParseChildEnumerators(lldb_private::CompilerType &compiler_type, bool is_signed, uint32_t enumerator_byte_size, - const DWARFDIE &parent_die); + const lldb_plugin::dwarf::DWARFDIE &parent_die); /// Parse a structure, class, or union type DIE. lldb::TypeSP ParseStructureLikeDIE(const lldb_private::SymbolContext &sc, - const DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &die, ParsedDWARFTypeAttributes &attrs); - lldb_private::Type *GetTypeForDIE(const DWARFDIE &die); + lldb_private::Type *GetTypeForDIE(const lldb_plugin::dwarf::DWARFDIE &die); - clang::Decl *GetClangDeclForDIE(const DWARFDIE &die); + clang::Decl *GetClangDeclForDIE(const lldb_plugin::dwarf::DWARFDIE &die); - clang::DeclContext *GetClangDeclContextForDIE(const DWARFDIE &die); + clang::DeclContext * + GetClangDeclContextForDIE(const lldb_plugin::dwarf::DWARFDIE &die); - clang::DeclContext *GetClangDeclContextContainingDIE(const DWARFDIE &die, - DWARFDIE *decl_ctx_die); - lldb_private::OptionalClangModuleID GetOwningClangModule(const DWARFDIE &die); + clang::DeclContext * + GetClangDeclContextContainingDIE(const lldb_plugin::dwarf::DWARFDIE &die, + lldb_plugin::dwarf::DWARFDIE *decl_ctx_die); + lldb_private::OptionalClangModuleID + GetOwningClangModule(const lldb_plugin::dwarf::DWARFDIE &die); - bool CopyUniqueClassMethodTypes(const DWARFDIE &src_class_die, - const DWARFDIE &dst_class_die, - lldb_private::Type *class_type, - std::vector<DWARFDIE> &failures); + bool CopyUniqueClassMethodTypes( + const lldb_plugin::dwarf::DWARFDIE &src_class_die, + const lldb_plugin::dwarf::DWARFDIE &dst_class_die, + lldb_private::Type *class_type, + std::vector<lldb_plugin::dwarf::DWARFDIE> &failures); - clang::DeclContext *GetCachedClangDeclContextForDIE(const DWARFDIE &die); + clang::DeclContext * + GetCachedClangDeclContextForDIE(const lldb_plugin::dwarf::DWARFDIE &die); - void LinkDeclContextToDIE(clang::DeclContext *decl_ctx, const DWARFDIE &die); + void LinkDeclContextToDIE(clang::DeclContext *decl_ctx, + const lldb_plugin::dwarf::DWARFDIE &die); - void LinkDeclToDIE(clang::Decl *decl, const DWARFDIE &die); + void LinkDeclToDIE(clang::Decl *decl, + const lldb_plugin::dwarf::DWARFDIE &die); /// If \p type_sp is valid, calculate and set its symbol context scope, and /// update the type list for its backing symbol file. @@ -207,16 +227,17 @@ class DWARFASTParserClang : public DWARFASTParser { /// Returns \p type_sp. lldb::TypeSP UpdateSymbolContextScopeForType(const lldb_private::SymbolContext &sc, - const DWARFDIE &die, lldb::TypeSP type_sp); + const lldb_plugin::dwarf::DWARFDIE &die, + lldb::TypeSP type_sp); /// Follow Clang Module Skeleton CU references to find a type definition. lldb::TypeSP ParseTypeFromClangModule(const lldb_private::SymbolContext &sc, - const DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &die, lldb_private::Log *log); // Return true if this type is a declaration to a type in an external // module. - lldb::ModuleSP GetModuleForType(const DWARFDIE &die); + lldb::ModuleSP GetModuleForType(const lldb_plugin::dwarf::DWARFDIE &die); private: struct FieldInfo { @@ -268,32 +289,37 @@ class DWARFASTParserClang : public DWARFASTParser { /// created property. /// \param delayed_properties The list of delayed properties that the result /// will be appended to. - void ParseObjCProperty(const DWARFDIE &die, const DWARFDIE &parent_die, + void ParseObjCProperty(const lldb_plugin::dwarf::DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &parent_die, const lldb_private::CompilerType &class_clang_type, DelayedPropertyList &delayed_properties); void - ParseSingleMember(const DWARFDIE &die, const DWARFDIE &parent_die, + ParseSingleMember(const lldb_plugin::dwarf::DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &parent_die, const lldb_private::CompilerType &class_clang_type, lldb::AccessType default_accessibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info, FieldInfo &last_field_info); - bool CompleteRecordType(const DWARFDIE &die, lldb_private::Type *type, + bool CompleteRecordType(const lldb_plugin::dwarf::DWARFDIE &die, + lldb_private::Type *type, lldb_private::CompilerType &clang_type); - bool CompleteEnumType(const DWARFDIE &die, lldb_private::Type *type, + bool CompleteEnumType(const lldb_plugin::dwarf::DWARFDIE &die, + lldb_private::Type *type, lldb_private::CompilerType &clang_type); lldb::TypeSP ParseTypeModifier(const lldb_private::SymbolContext &sc, - const DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &die, ParsedDWARFTypeAttributes &attrs); lldb::TypeSP ParseEnum(const lldb_private::SymbolContext &sc, - const DWARFDIE &die, ParsedDWARFTypeAttributes &attrs); - lldb::TypeSP ParseSubroutine(const DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &die, + ParsedDWARFTypeAttributes &attrs); + lldb::TypeSP ParseSubroutine(const lldb_plugin::dwarf::DWARFDIE &die, ParsedDWARFTypeAttributes &attrs); - lldb::TypeSP ParseArrayType(const DWARFDIE &die, + lldb::TypeSP ParseArrayType(const lldb_plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs); - lldb::TypeSP ParsePointerToMemberType(const DWARFDIE &die, + lldb::TypeSP ParsePointerToMemberType(const lldb_plugin::dwarf::DWARFDIE &die, const ParsedDWARFTypeAttributes &attrs); /// Parses a DW_TAG_inheritance DIE into a base/super class. @@ -311,7 +337,8 @@ class DWARFASTParserClang : public DWARFASTParser { /// \param layout_info The layout information that will be updated for C++ /// base classes with the base offset. void ParseInheritance( - const DWARFDIE &die, const DWARFDIE &parent_die, + const lldb_plugin::dwarf::DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &parent_die, const lldb_private::CompilerType class_clang_type, const lldb::AccessType default_accessibility, const lldb::ModuleSP &module_sp, @@ -328,7 +355,8 @@ class DWARFASTParserClang : public DWARFASTParser { /// \param layout_info The layout information that will be updated for // base classes with the base offset void - ParseRustVariantPart(DWARFDIE &die, const DWARFDIE &parent_die, + ParseRustVariantPart(lldb_plugin::dwarf::DWARFDIE &die, + const lldb_plugin::dwarf::DWARFDIE &parent_die, lldb_private::CompilerType &class_clang_type, const lldb::AccessType default_accesibility, lldb_private::ClangASTImporter::LayoutInfo &layout_info); @@ -338,7 +366,7 @@ class DWARFASTParserClang : public DWARFASTParser { /// Some attributes are relevant for all kinds of types (declaration), while /// others are only meaningful to a specific type (is_virtual) struct ParsedDWARFTypeAttributes { - explicit ParsedDWARFTypeAttributes(const DWARFDIE &die); + explicit ParsedDWARFTypeAttributes(const lldb_plugin::dwarf::DWARFDIE &die); lldb::AccessType accessibility = lldb::eAccessNone; bool is_artificial = false; @@ -355,12 +383,12 @@ struct ParsedDWARFTypeAttributes { const char *mangled_name = nullptr; lldb_private::ConstString name; lldb_private::Declaration decl; - DWARFDIE object_pointer; - DWARFFormValue abstract_origin; - DWARFFormValue containing_type; - DWARFFormValue signature; - DWARFFormValue specification; - DWARFFormValue type; + lldb_plugin::dwarf::DWARFDIE object_pointer; + lldb_plugin::dwarf::DWARFFormValue abstract_origin; + lldb_plugin::dwarf::DWARFFormValue containing_type; + lldb_plugin::dwarf::DWARFFormValue signature; + lldb_plugin::dwarf::DWARFFormValue specification; + lldb_plugin::dwarf::DWARFFormValue type; lldb::LanguageType class_language = lldb::eLanguageTypeUnknown; std::optional<uint64_t> byte_size; size_t calling_convention = llvm::dwarf::DW_CC_normal; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp index 00b56537ae2b5fe..48bd62012afb393 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.cpp @@ -11,6 +11,7 @@ #include "DWARFDebugInfo.h" using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; DWARFAttributes::DWARFAttributes() : m_infos() {} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h index 90e12fa024936d6..1c3aeaec26c8eec 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFAttribute.h @@ -14,6 +14,8 @@ #include "llvm/ADT/SmallVector.h" #include <vector> +namespace lldb_plugin { +namespace dwarf { class DWARFUnit; class DWARFAttribute { @@ -31,6 +33,7 @@ class DWARFAttribute { form = m_form; val = m_value; } + protected: dw_attr_t m_attr; dw_form_t m_form; @@ -72,5 +75,7 @@ class DWARFAttributes { typedef llvm::SmallVector<AttributeValue, 8> collection; collection m_infos; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFATTRIBUTE_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp index 37a917c3a7661eb..241e30fa2557474 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.cpp @@ -18,6 +18,7 @@ #include <optional> using namespace lldb_private; +using namespace lldb_plugin::dwarf; std::optional<DIERef> DWARFBaseDIE::GetDIERef() const { if (!IsValid()) @@ -35,7 +36,7 @@ dw_tag_t DWARFBaseDIE::Tag() const { } const char *DWARFBaseDIE::GetTagAsCString() const { - return lldb_private::DW_TAG_value_to_name(Tag()); + return DW_TAG_value_to_name(Tag()); } const char *DWARFBaseDIE::GetAttributeValueAsString(const dw_attr_t attr, @@ -120,6 +121,8 @@ DWARFAttributes DWARFBaseDIE::GetAttributes(Recurse recurse) const { return DWARFAttributes(); } +namespace lldb_plugin { +namespace dwarf { bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) { return lhs.GetDIE() == rhs.GetDIE() && lhs.GetCU() == rhs.GetCU(); } @@ -127,6 +130,8 @@ bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) { bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs) { return !(lhs == rhs); } +} // namespace dwarf +} // namespace lldb_plugin const DWARFDataExtractor &DWARFBaseDIE::GetData() const { // Clients must check if this DIE is valid before calling this function. diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h index 8bcf807ad163a60..4dac0f116124c84 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFBaseDIE.h @@ -15,6 +15,8 @@ #include "llvm/Support/Error.h" #include <optional> +namespace lldb_plugin { +namespace dwarf { class DIERef; class DWARFASTParser; class DWARFAttributes; @@ -124,5 +126,7 @@ class DWARFBaseDIE { bool operator==(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs); bool operator!=(const DWARFBaseDIE &lhs, const DWARFBaseDIE &rhs); +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFBASEDIE_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp index f839a59bf6c390b..6f18c3ddf605f1d 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.cpp @@ -16,6 +16,7 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; void DWARFCompileUnit::Dump(Stream *s) const { s->Format( diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h index 65debac4c7d9265..f33f21e1cfaa3e8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFCompileUnit.h @@ -14,8 +14,10 @@ namespace llvm { class DWARFAbbreviationDeclarationSet; -} +} // namespace llvm +namespace lldb_plugin { +namespace dwarf { class DWARFCompileUnit : public DWARFUnit { public: void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges) override; @@ -40,5 +42,7 @@ class DWARFCompileUnit : public DWARFUnit { friend class DWARFUnit; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFCOMPILEUNIT_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp index f72dad88e157592..d7979a43e46e8a2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.cpp @@ -13,6 +13,7 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; static DWARFDataExtractor LoadSection(SectionList *section_list, SectionType section_type) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h index 7df776b5f514155..de276a04d444631 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFContext.h @@ -16,16 +16,17 @@ #include <memory> #include <optional> -namespace lldb_private { +namespace lldb_plugin { +namespace dwarf { class DWARFContext { private: - SectionList *m_main_section_list; - SectionList *m_dwo_section_list; + lldb_private::SectionList *m_main_section_list; + lldb_private::SectionList *m_dwo_section_list; mutable std::unique_ptr<llvm::DWARFContext> m_llvm_context; struct SectionData { llvm::once_flag flag; - DWARFDataExtractor data; + lldb_private::DWARFDataExtractor data; }; SectionData m_data_debug_abbrev; @@ -45,39 +46,40 @@ class DWARFContext { SectionData m_data_debug_tu_index; SectionData m_data_debug_types; - const DWARFDataExtractor & + const lldb_private::DWARFDataExtractor & LoadOrGetSection(std::optional<lldb::SectionType> main_section_type, std::optional<lldb::SectionType> dwo_section_type, SectionData &data); - const DWARFDataExtractor &getOrLoadCuIndexData(); - const DWARFDataExtractor &getOrLoadTuIndexData(); + const lldb_private::DWARFDataExtractor &getOrLoadCuIndexData(); + const lldb_private::DWARFDataExtractor &getOrLoadTuIndexData(); public: - explicit DWARFContext(SectionList *main_section_list, - SectionList *dwo_section_list) + explicit DWARFContext(lldb_private::SectionList *main_section_list, + lldb_private::SectionList *dwo_section_list) : m_main_section_list(main_section_list), m_dwo_section_list(dwo_section_list) {} - const DWARFDataExtractor &getOrLoadAbbrevData(); - const DWARFDataExtractor &getOrLoadAddrData(); - const DWARFDataExtractor &getOrLoadArangesData(); - const DWARFDataExtractor &getOrLoadDebugInfoData(); - const DWARFDataExtractor &getOrLoadLineData(); - const DWARFDataExtractor &getOrLoadLineStrData(); - const DWARFDataExtractor &getOrLoadLocData(); - const DWARFDataExtractor &getOrLoadLocListsData(); - const DWARFDataExtractor &getOrLoadMacroData(); - const DWARFDataExtractor &getOrLoadRangesData(); - const DWARFDataExtractor &getOrLoadRngListsData(); - const DWARFDataExtractor &getOrLoadStrData(); - const DWARFDataExtractor &getOrLoadStrOffsetsData(); - const DWARFDataExtractor &getOrLoadDebugTypesData(); + const lldb_private::DWARFDataExtractor &getOrLoadAbbrevData(); + const lldb_private::DWARFDataExtractor &getOrLoadAddrData(); + const lldb_private::DWARFDataExtractor &getOrLoadArangesData(); + const lldb_private::DWARFDataExtractor &getOrLoadDebugInfoData(); + const lldb_private::DWARFDataExtractor &getOrLoadLineData(); + const lldb_private::DWARFDataExtractor &getOrLoadLineStrData(); + const lldb_private::DWARFDataExtractor &getOrLoadLocData(); + const lldb_private::DWARFDataExtractor &getOrLoadLocListsData(); + const lldb_private::DWARFDataExtractor &getOrLoadMacroData(); + const lldb_private::DWARFDataExtractor &getOrLoadRangesData(); + const lldb_private::DWARFDataExtractor &getOrLoadRngListsData(); + const lldb_private::DWARFDataExtractor &getOrLoadStrData(); + const lldb_private::DWARFDataExtractor &getOrLoadStrOffsetsData(); + const lldb_private::DWARFDataExtractor &getOrLoadDebugTypesData(); bool isDwo() { return m_dwo_section_list != nullptr; } llvm::DWARFContext &GetAsLLVM(); }; -} // namespace lldb_private +} // namespace dwarf +} // namespace lldb_plugin #endif diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp index b31c5dcac91851d..62ef0eb356b0bc7 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.cpp @@ -18,6 +18,7 @@ using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; namespace { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h index 031ea26ad405094..37a0f7570ccfd24 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDIE.h @@ -13,6 +13,8 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/iterator_range.h" +namespace lldb_plugin { +namespace dwarf { class DWARFDIE : public DWARFBaseDIE { public: class child_iterator; @@ -126,5 +128,7 @@ class DWARFDIE::child_iterator return *this; } }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDIE_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h index b9526b079c1e9da..41b8e9ad0217b69 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDataExtractor.h @@ -33,6 +33,6 @@ class DWARFDataExtractor : public DataExtractor { llvm::DWARFDataExtractor GetAsLLVMDWARF() const; llvm::DataExtractor GetAsLLVM() const; }; -} +} // namespace lldb_private #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDATAEXTRACTOR_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp index 03cbfd28ae7413a..61f1f5f1aa8baec 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.cpp @@ -13,6 +13,7 @@ #include <cassert> using namespace lldb_private; +using namespace lldb_plugin::dwarf; DWARFDebugArangeSet::DWARFDebugArangeSet() : m_offset(DW_INVALID_OFFSET), m_next_offset(DW_INVALID_OFFSET) {} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h index 3c8633eaa3cce85..e32952cdea7f8c1 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugArangeSet.h @@ -13,6 +13,8 @@ #include <cstdint> #include <vector> +namespace lldb_plugin { +namespace dwarf { class DWARFDebugArangeSet { public: struct Header { @@ -62,5 +64,7 @@ class DWARFDebugArangeSet { Header m_header; DescriptorColl m_arange_descriptors; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGESET_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp index b38dd2b88c9d0b0..a5beafe593c2c1e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.cpp @@ -15,6 +15,7 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; // Constructor DWARFDebugAranges::DWARFDebugAranges() : m_aranges() {} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h index 5ff37e400c88403..dbf0451f93a8c7e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugAranges.h @@ -13,6 +13,8 @@ #include "lldb/Utility/RangeMap.h" #include "llvm/Support/Error.h" +namespace lldb_plugin { +namespace dwarf { class DWARFDebugAranges { protected: typedef lldb_private::RangeDataVector<dw_addr_t, uint32_t, dw_offset_t> @@ -50,5 +52,7 @@ class DWARFDebugAranges { protected: RangeToDIE m_aranges; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGARANGES_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp index 9a33d6338b87d3e..54609a1b77fc6cb 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.cpp @@ -27,10 +27,10 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; // Constructor -DWARFDebugInfo::DWARFDebugInfo(SymbolFileDWARF &dwarf, - lldb_private::DWARFContext &context) +DWARFDebugInfo::DWARFDebugInfo(SymbolFileDWARF &dwarf, DWARFContext &context) : m_dwarf(dwarf), m_context(context), m_units(), m_cu_aranges_up() {} const DWARFDebugAranges &DWARFDebugInfo::GetCompileUnitAranges() { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h index c990ac9fbe58310..365e4dc28e319c8 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfo.h @@ -19,20 +19,18 @@ #include "lldb/lldb-private.h" #include "llvm/Support/Error.h" -namespace lldb_private { +namespace lldb_plugin { +namespace dwarf { class DWARFContext; -} class DWARFDebugInfo { public: - typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data, - DWARFUnit *cu, + typedef dw_offset_t (*Callback)(SymbolFileDWARF *dwarf2Data, DWARFUnit *cu, DWARFDebugInfoEntry *die, const dw_offset_t next_offset, const uint32_t depth, void *userData); - explicit DWARFDebugInfo(SymbolFileDWARF &dwarf, - lldb_private::DWARFContext &context); + explicit DWARFDebugInfo(SymbolFileDWARF &dwarf, DWARFContext &context); size_t GetNumUnits(); DWARFUnit *GetUnitAtIndex(size_t idx); @@ -58,7 +56,7 @@ class DWARFDebugInfo { typedef std::vector<DWARFUnitSP> UnitColl; SymbolFileDWARF &m_dwarf; - lldb_private::DWARFContext &m_context; + DWARFContext &m_context; llvm::once_flag m_units_once_flag; UnitColl m_units; @@ -80,5 +78,7 @@ class DWARFDebugInfo { DWARFDebugInfo(const DWARFDebugInfo &) = delete; const DWARFDebugInfo &operator=(const DWARFDebugInfo &) = delete; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFO_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp index a6ab83700904cb9..6405ecc20542f41 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.cpp @@ -35,6 +35,7 @@ using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; extern int g_verbose; // Extract a debug info entry for a given DWARFUnit from the data diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h index 29db44a16bb1281..d85efc3392d278c 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugInfoEntry.h @@ -22,6 +22,8 @@ #include "llvm/DebugInfo/DWARF/DWARFAbbreviationDeclaration.h" +namespace lldb_plugin { +namespace dwarf { class DWARFDeclContext; #define DIE_SIBLING_IDX_BITSIZE 31 @@ -190,5 +192,7 @@ class DWARFDebugInfoEntry { void GetAttributes(DWARFUnit *cu, DWARFAttributes &attrs, Recurse recurse, uint32_t curr_depth) const; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGINFOENTRY_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp index 19c6448c4e74a06..cde5730d51e33fa 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.cpp @@ -15,6 +15,7 @@ using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; DWARFDebugMacroHeader DWARFDebugMacroHeader::ParseHeader(const DWARFDataExtractor &debug_macro_data, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h index cbf762458331bcd..647130113bc9103 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugMacro.h @@ -17,11 +17,11 @@ #include "lldb/lldb-types.h" namespace lldb_private { - class DWARFDataExtractor; +} -} // namespace lldb_private - +namespace lldb_plugin { +namespace dwarf { class SymbolFileDWARF; class DWARFDebugMacroHeader { @@ -57,5 +57,7 @@ class DWARFDebugMacroEntry { SymbolFileDWARF *sym_file_dwarf, lldb_private::DebugMacrosSP &debug_macros_sp); }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGMACRO_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp index 0b5bb23a4981f89..e37d22f07337763 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.cpp @@ -11,6 +11,7 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" using namespace lldb_private; +using namespace lldb_plugin::dwarf; DWARFDebugRanges::DWARFDebugRanges() : m_range_map() {} diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h index 2e06cd5daf6f32d..efd817461672aee 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDebugRanges.h @@ -12,21 +12,23 @@ #include "lldb/Core/dwarf.h" #include <map> +namespace lldb_plugin { +namespace dwarf { class DWARFUnit; -namespace lldb_private { class DWARFContext; -} class DWARFDebugRanges { public: DWARFDebugRanges(); - void Extract(lldb_private::DWARFContext &context); + void Extract(DWARFContext &context); DWARFRangeList FindRanges(const DWARFUnit *cu, dw_offset_t debug_ranges_offset) const; protected: std::map<dw_offset_t, DWARFRangeList> m_range_map; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEBUGRANGES_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp index 393de0038e651f3..a20dfef6bf89921 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.cpp @@ -9,6 +9,7 @@ #include "DWARFDeclContext.h" using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; const char *DWARFDeclContext::GetQualifiedName() const { if (m_qualified_name.empty()) { diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h index 13e3dfb70c0cc80..c793675b2eeb396 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDeclContext.h @@ -16,6 +16,8 @@ #include <string> #include <vector> +namespace lldb_plugin { +namespace dwarf { // DWARFDeclContext // // A class that represents a declaration context all the way down to a @@ -82,5 +84,7 @@ class DWARFDeclContext { collection m_entries; mutable std::string m_qualified_name; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDECLCONTEXT_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp index 4e99a295ce50f7d..ae6ab4218de4b44 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.cpp @@ -12,7 +12,8 @@ #include <cstring> #include <string> -namespace lldb_private { +namespace lldb_plugin { +namespace dwarf { const char *DW_TAG_value_to_name(uint32_t val) { static char invalid[100]; @@ -88,4 +89,5 @@ const char *DW_LNS_value_to_name(uint32_t val) { return llvmstr.data(); } -} // namespace lldb_private +} // namespace dwarf +} // namespace lldb_plugin diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h index 2afdbb47381a9cd..eb5758975b4137f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFDefines.h @@ -12,7 +12,8 @@ #include "lldb/Core/dwarf.h" #include <cstdint> -namespace lldb_private { +namespace lldb_plugin { +namespace dwarf { typedef uint32_t DRC_class; // Holds DRC_* class bitfields @@ -30,6 +31,7 @@ const char *DW_LANG_value_to_name(uint32_t val); const char *DW_LNS_value_to_name(uint32_t val); -} // namespace lldb_private +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFDEFINES_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp index 6ca17dcf47ff7ba..7c9f8073a3a01ae 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.cpp @@ -22,6 +22,7 @@ class DWARFUnit; using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; void DWARFFormValue::Clear() { m_unit = nullptr; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h index 2a8843c1a0d45df..9bcf43a18c2faac 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFFormValue.h @@ -13,6 +13,8 @@ #include <cstddef> #include <optional> +namespace lldb_plugin { +namespace dwarf { class DWARFUnit; class SymbolFileDWARF; class DWARFDIE; @@ -84,7 +86,9 @@ class DWARFFormValue { // It may be different from compile unit where m_value refers to. const DWARFUnit *m_unit = nullptr; // Unit for this form dw_form_t m_form = dw_form_t(0); // Form for this value - ValueType m_value; // Contains all data for the form + ValueType m_value; // Contains all data for the form }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFFORMVALUE_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp index 779b52481b856d8..791bd2d88696c26 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.cpp @@ -17,6 +17,7 @@ using namespace lldb_private; using namespace lldb; +using namespace lldb_plugin::dwarf; DWARFIndex::~DWARFIndex() = default; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h index 13fe96dae2aa1d6..71e0f6e3d48635e 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h @@ -17,13 +17,14 @@ #include "lldb/Core/Module.h" #include "lldb/Target/Statistics.h" +namespace lldb_plugin { +namespace dwarf { class DWARFDeclContext; class DWARFDIE; -namespace lldb_private { class DWARFIndex { public: - DWARFIndex(Module &module) : m_module(module) {} + DWARFIndex(lldb_private::Module &module) : m_module(module) {} virtual ~DWARFIndex(); virtual void Preload() = 0; @@ -32,53 +33,56 @@ class DWARFIndex { /// (e.g., to only retrieve variables from a given context) should be done by /// the consumer. virtual void - GetGlobalVariables(ConstString basename, + GetGlobalVariables(lldb_private::ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; virtual void - GetGlobalVariables(const RegularExpression ®ex, + GetGlobalVariables(const lldb_private::RegularExpression ®ex, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; /// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit(). virtual void GetGlobalVariables(DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; virtual void - GetObjCMethods(ConstString class_name, + GetObjCMethods(lldb_private::ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; virtual void - GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, + GetCompleteObjCClass(lldb_private::ConstString class_name, + bool must_be_implementation, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; - virtual void GetTypes(ConstString name, + virtual void GetTypes(lldb_private::ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; virtual void GetTypes(const DWARFDeclContext &context, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; virtual void - GetNamespaces(ConstString name, + GetNamespaces(lldb_private::ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; virtual void - GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, - const CompilerDeclContext &parent_decl_ctx, + GetFunctions(const lldb_private::Module::LookupInfo &lookup_info, + SymbolFileDWARF &dwarf, + const lldb_private::CompilerDeclContext &parent_decl_ctx, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; virtual void - GetFunctions(const RegularExpression ®ex, + GetFunctions(const lldb_private::RegularExpression ®ex, llvm::function_ref<bool(DWARFDIE die)> callback) = 0; - virtual void Dump(Stream &s) = 0; + virtual void Dump(lldb_private::Stream &s) = 0; - StatsDuration::Duration GetIndexTime() { return m_index_time; } + lldb_private::StatsDuration::Duration GetIndexTime() { return m_index_time; } protected: - Module &m_module; - StatsDuration m_index_time; + lldb_private::Module &m_module; + lldb_private::StatsDuration m_index_time; /// Helper function implementing common logic for processing function dies. If /// the function given by "ref" matches search criteria given by /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies" /// vector. - bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DIERef ref, - SymbolFileDWARF &dwarf, - const CompilerDeclContext &parent_decl_ctx, - llvm::function_ref<bool(DWARFDIE die)> callback); + bool + ProcessFunctionDIE(const lldb_private::Module::LookupInfo &lookup_info, + DIERef ref, SymbolFileDWARF &dwarf, + const lldb_private::CompilerDeclContext &parent_decl_ctx, + llvm::function_ref<bool(DWARFDIE die)> callback); class DIERefCallbackImpl { public: @@ -102,6 +106,7 @@ class DWARFIndex { void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const; }; -} // namespace lldb_private +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp index 87af7177ca95ee9..cdacd8425bb8ed4 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.cpp @@ -13,6 +13,7 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; void DWARFTypeUnit::Dump(Stream *s) const { s->Format("{0:x16}: Type Unit: length = {1:x8}, version = {2:x4}, " diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h index 5d939582a312e98..4b77623d6615fdc 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFTypeUnit.h @@ -14,8 +14,10 @@ namespace llvm { class DWARFAbbreviationDeclarationSet; -} +} // namespace llvm +namespace lldb_plugin { +namespace dwarf { class DWARFTypeUnit : public DWARFUnit { public: void BuildAddressRangeTable(DWARFDebugAranges *debug_aranges) override {} @@ -37,5 +39,7 @@ class DWARFTypeUnit : public DWARFUnit { friend class DWARFUnit; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFTYPEUNIT_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp index a09c68087c47659..7a3fb4028a4dce1 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.cpp @@ -28,6 +28,7 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; extern int g_verbose; @@ -201,8 +202,8 @@ DWARFUnit::ScopedExtractDIEs::ScopedExtractDIEs(ScopedExtractDIEs &&rhs) rhs.m_cu = nullptr; } -DWARFUnit::ScopedExtractDIEs &DWARFUnit::ScopedExtractDIEs::operator=( - DWARFUnit::ScopedExtractDIEs &&rhs) { +DWARFUnit::ScopedExtractDIEs & +DWARFUnit::ScopedExtractDIEs::operator=(DWARFUnit::ScopedExtractDIEs &&rhs) { m_cu = rhs.m_cu; rhs.m_cu = nullptr; m_clear_dies = rhs.m_clear_dies; @@ -311,9 +312,9 @@ void DWARFUnit::ExtractDIEsRWLocked() { } if (!m_die_array.empty()) { - // The last die cannot have children (if it did, it wouldn't be the last one). - // This only makes a difference for malformed dwarf that does not have a - // terminating null die. + // The last die cannot have children (if it did, it wouldn't be the last + // one). This only makes a difference for malformed dwarf that does not have + // a terminating null die. m_die_array.back().SetHasChildren(false); if (m_first_die) { @@ -720,7 +721,7 @@ void DWARFUnit::ParseProducerInfo() { llvm::SmallVector<llvm::StringRef, 3> matches; if (g_swiftlang_version_regex.Execute(producer, &matches)) { - m_producer_version.tryParse(matches[1]); + m_producer_version.tryParse(matches[1]); m_producer = eProducerSwift; } else if (producer.contains("clang")) { if (g_clang_version_regex.Execute(producer, &matches)) @@ -905,9 +906,10 @@ llvm::Error DWARFUnitHeader::ApplyIndexEntry( return llvm::Error::success(); } -llvm::Expected<DWARFUnitHeader> DWARFUnitHeader::extract( - const DWARFDataExtractor &data, DIERef::Section section, - lldb_private::DWARFContext &context, lldb::offset_t *offset_ptr) { +llvm::Expected<DWARFUnitHeader> +DWARFUnitHeader::extract(const DWARFDataExtractor &data, + DIERef::Section section, DWARFContext &context, + lldb::offset_t *offset_ptr) { DWARFUnitHeader header; header.m_offset = *offset_ptr; header.m_length = data.GetDWARFInitialLength(offset_ptr); @@ -1086,22 +1088,20 @@ DWARFUnit::FindRnglistFromOffset(dw_offset_t offset) { return ranges; } -llvm::Expected<DWARFRangeList> -DWARFUnit::FindRnglistFromIndex(uint32_t index) { +llvm::Expected<DWARFRangeList> DWARFUnit::FindRnglistFromIndex(uint32_t index) { llvm::Expected<uint64_t> maybe_offset = GetRnglistOffset(index); if (!maybe_offset) return maybe_offset.takeError(); return FindRnglistFromOffset(*maybe_offset); } - bool DWARFUnit::HasAny(llvm::ArrayRef<dw_tag_t> tags) { ExtractUnitDIEIfNeeded(); if (m_dwo) return m_dwo->HasAny(tags); - for (const auto &die: m_die_array) { - for (const auto tag: tags) { + for (const auto &die : m_die_array) { + for (const auto tag : tags) { if (tag == die.Tag()) return true; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h index 20871d805e77a87..f54a116ea588de3 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DWARFUnit.h @@ -19,6 +19,8 @@ #include <atomic> #include <optional> +namespace lldb_plugin { +namespace dwarf { class DWARFUnit; class DWARFCompileUnit; class NameToDIE; @@ -80,8 +82,7 @@ class DWARFUnitHeader { static llvm::Expected<DWARFUnitHeader> extract(const lldb_private::DWARFDataExtractor &data, DIERef::Section section, - lldb_private::DWARFContext &dwarf_context, - lldb::offset_t *offset_ptr); + DWARFContext &dwarf_context, lldb::offset_t *offset_ptr); }; class DWARFUnit : public lldb_private::UserID { @@ -104,6 +105,7 @@ class DWARFUnit : public lldb_private::UserID { class ScopedExtractDIEs { DWARFUnit *m_cu; + public: bool m_clear_dies = false; ScopedExtractDIEs(DWARFUnit &cu); @@ -227,7 +229,9 @@ class DWARFUnit : public lldb_private::UserID { uint8_t GetUnitType() const { return m_header.GetUnitType(); } bool IsTypeUnit() const { return m_header.IsTypeUnit(); } /// Note that this check only works for DWARF5+. - bool IsSkeletonUnit() const { return GetUnitType() == llvm::dwarf::DW_UT_skeleton; } + bool IsSkeletonUnit() const { + return GetUnitType() == llvm::dwarf::DW_UT_skeleton; + } std::optional<uint64_t> GetStringOffsetSectionItem(uint32_t index) const; @@ -272,7 +276,6 @@ class DWARFUnit : public lldb_private::UserID { /// True if any DIEs match any tag in \a tags, false otherwise. bool HasAny(llvm::ArrayRef<dw_tag_t> tags); - /// Get the fission .dwo file specific error for this compile unit. /// /// The skeleton compile unit only can have a DWO error. Any other type @@ -351,9 +354,9 @@ class DWARFUnit : public lldb_private::UserID { lldb_private::LazyBool m_is_optimized = lldb_private::eLazyBoolCalculate; std::optional<lldb_private::FileSpec> m_comp_dir; std::optional<lldb_private::FileSpec> m_file_spec; - std::optional<dw_addr_t> m_addr_base; ///< Value of DW_AT_addr_base. - dw_addr_t m_loclists_base = 0; ///< Value of DW_AT_loclists_base. - dw_addr_t m_ranges_base = 0; ///< Value of DW_AT_rnglists_base. + std::optional<dw_addr_t> m_addr_base; ///< Value of DW_AT_addr_base. + dw_addr_t m_loclists_base = 0; ///< Value of DW_AT_loclists_base. + dw_addr_t m_ranges_base = 0; ///< Value of DW_AT_rnglists_base. std::optional<uint64_t> m_gnu_addr_base; std::optional<uint64_t> m_gnu_ranges_base; @@ -390,5 +393,7 @@ class DWARFUnit : public lldb_private::UserID { DWARFUnit(const DWARFUnit &) = delete; const DWARFUnit &operator=(const DWARFUnit &) = delete; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFUNIT_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp index af2d6c554140bc0..748267e3c8bd010 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.cpp @@ -18,6 +18,7 @@ using namespace lldb_private; using namespace lldb; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> DebugNamesDWARFIndex::Create(Module &module, DWARFDataExtractor debug_names, @@ -227,7 +228,7 @@ void DebugNamesDWARFIndex::GetNamespaces( ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) { for (const DebugNames::Entry &entry : m_debug_names_up->equal_range(name.GetStringRef())) { - dwarf::Tag entry_tag = entry.tag(); + lldb_private::dwarf::Tag entry_tag = entry.tag(); if (entry_tag == DW_TAG_namespace || entry_tag == DW_TAG_imported_declaration) { if (!ProcessEntry(entry, callback)) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h index abbd700f1603feb..6aad2a40dc5e06b 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/DebugNamesDWARFIndex.h @@ -17,50 +17,52 @@ #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" #include <optional> -namespace lldb_private { +namespace lldb_plugin { +namespace dwarf { class DebugNamesDWARFIndex : public DWARFIndex { public: static llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> - Create(Module &module, DWARFDataExtractor debug_names, - DWARFDataExtractor debug_str, SymbolFileDWARF &dwarf); + Create(lldb_private::Module &module, + lldb_private::DWARFDataExtractor debug_names, + lldb_private::DWARFDataExtractor debug_str, SymbolFileDWARF &dwarf); void Preload() override { m_fallback.Preload(); } void - GetGlobalVariables(ConstString basename, + GetGlobalVariables(lldb_private::ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) override; void - GetGlobalVariables(const RegularExpression ®ex, + GetGlobalVariables(const lldb_private::RegularExpression ®ex, llvm::function_ref<bool(DWARFDIE die)> callback) override; void GetGlobalVariables(DWARFUnit &cu, llvm::function_ref<bool(DWARFDIE die)> callback) override; void - GetObjCMethods(ConstString class_name, + GetObjCMethods(lldb_private::ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) override {} void GetCompleteObjCClass( - ConstString class_name, bool must_be_implementation, + lldb_private::ConstString class_name, bool must_be_implementation, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetTypes(ConstString name, + void GetTypes(lldb_private::ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) override; void GetTypes(const DWARFDeclContext &context, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetNamespaces(ConstString name, + void GetNamespaces(lldb_private::ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetFunctions(const Module::LookupInfo &lookup_info, + void GetFunctions(const lldb_private::Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, - const CompilerDeclContext &parent_decl_ctx, + const lldb_private::CompilerDeclContext &parent_decl_ctx, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetFunctions(const RegularExpression ®ex, + void GetFunctions(const lldb_private::RegularExpression ®ex, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void Dump(Stream &s) override; + void Dump(lldb_private::Stream &s) override; private: - DebugNamesDWARFIndex(Module &module, + DebugNamesDWARFIndex(lldb_private::Module &module, std::unique_ptr<llvm::DWARFDebugNames> debug_names_up, - DWARFDataExtractor debug_names_data, - DWARFDataExtractor debug_str_data, + lldb_private::DWARFDataExtractor debug_names_data, + lldb_private::DWARFDataExtractor debug_str_data, SymbolFileDWARF &dwarf) : DWARFIndex(module), m_debug_info(dwarf.DebugInfo()), m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data), @@ -71,8 +73,8 @@ class DebugNamesDWARFIndex : public DWARFIndex { // LLVM DWARFDebugNames will hold a non-owning reference to this data, so keep // track of the ownership here. - DWARFDataExtractor m_debug_names_data; - DWARFDataExtractor m_debug_str_data; + lldb_private::DWARFDataExtractor m_debug_names_data; + lldb_private::DWARFDataExtractor m_debug_str_data; using DebugNames = llvm::DWARFDebugNames; std::unique_ptr<DebugNames> m_debug_names_up; @@ -89,6 +91,7 @@ class DebugNamesDWARFIndex : public DWARFIndex { static llvm::DenseSet<dw_offset_t> GetUnits(const DebugNames &debug_names); }; -} // namespace lldb_private +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp index 90f18c96afa230e..d4a4cbcc0f5326f 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.cpp @@ -28,6 +28,7 @@ using namespace lldb_private; using namespace lldb; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; void ManualDWARFIndex::Index() { if (m_indexed) diff --git a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h index d95cf501face8e4..66caf967015069a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/ManualDWARFIndex.h @@ -13,13 +13,14 @@ #include "Plugins/SymbolFile/DWARF/NameToDIE.h" #include "llvm/ADT/DenseSet.h" +namespace lldb_plugin { +namespace dwarf { class DWARFDebugInfo; class SymbolFileDWARFDwo; -namespace lldb_private { class ManualDWARFIndex : public DWARFIndex { public: - ManualDWARFIndex(Module &module, SymbolFileDWARF &dwarf, + ManualDWARFIndex(lldb_private::Module &module, SymbolFileDWARF &dwarf, llvm::DenseSet<dw_offset_t> units_to_avoid = {}) : DWARFIndex(module), m_dwarf(&dwarf), m_units_to_avoid(std::move(units_to_avoid)) {} @@ -27,33 +28,33 @@ class ManualDWARFIndex : public DWARFIndex { void Preload() override { Index(); } void - GetGlobalVariables(ConstString basename, + GetGlobalVariables(lldb_private::ConstString basename, llvm::function_ref<bool(DWARFDIE die)> callback) override; void - GetGlobalVariables(const RegularExpression ®ex, + GetGlobalVariables(const lldb_private::RegularExpression ®ex, llvm::function_ref<bool(DWARFDIE die)> callback) override; void GetGlobalVariables(DWARFUnit &unit, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetObjCMethods(ConstString class_name, + void GetObjCMethods(lldb_private::ConstString class_name, llvm::function_ref<bool(DWARFDIE die)> callback) override; void GetCompleteObjCClass( - ConstString class_name, bool must_be_implementation, + lldb_private::ConstString class_name, bool must_be_implementation, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetTypes(ConstString name, + void GetTypes(lldb_private::ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) override; void GetTypes(const DWARFDeclContext &context, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetNamespaces(ConstString name, + void GetNamespaces(lldb_private::ConstString name, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetFunctions(const Module::LookupInfo &lookup_info, + void GetFunctions(const lldb_private::Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, - const CompilerDeclContext &parent_decl_ctx, + const lldb_private::CompilerDeclContext &parent_decl_ctx, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void GetFunctions(const RegularExpression ®ex, + void GetFunctions(const lldb_private::RegularExpression ®ex, llvm::function_ref<bool(DWARFDIE die)> callback) override; - void Dump(Stream &s) override; + void Dump(lldb_private::Stream &s) override; // Make IndexSet public so we can unit test the encoding and decoding logic. struct IndexSet { @@ -65,8 +66,9 @@ class ManualDWARFIndex : public DWARFIndex { NameToDIE globals; NameToDIE types; NameToDIE namespaces; - bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr); - void Encode(DataEncoder &encoder) const; + bool Decode(const lldb_private::DataExtractor &data, + lldb::offset_t *offset_ptr); + void Encode(lldb_private::DataEncoder &encoder) const; bool operator==(const IndexSet &rhs) const { return function_basenames == rhs.function_basenames && function_fullnames == rhs.function_fullnames && @@ -94,8 +96,8 @@ class ManualDWARFIndex : public DWARFIndex { /// All strings in cache files are put into string tables for efficiency /// and cache file size reduction. Strings are stored as uint32_t string /// table offsets in the cache data. - bool Decode(const DataExtractor &data, lldb::offset_t *offset_ptr, - bool &signature_mismatch); + bool Decode(const lldb_private::DataExtractor &data, + lldb::offset_t *offset_ptr, bool &signature_mismatch); /// Encode this object into a data encoder object. /// @@ -112,7 +114,7 @@ class ManualDWARFIndex : public DWARFIndex { /// \return /// True if the symbol table's object file can generate a valid signature /// and all data for the symbol table was encoded, false otherwise. - bool Encode(DataEncoder &encoder) const; + bool Encode(lldb_private::DataEncoder &encoder) const; /// Get the cache key string for this symbol table. /// @@ -173,6 +175,7 @@ class ManualDWARFIndex : public DWARFIndex { IndexSet m_set; bool m_indexed = false; }; -} // namespace lldb_private +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_MANUALDWARFINDEX_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp index 89e628f5eaf1c47..555c9ca2275a007 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.cpp @@ -20,6 +20,7 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; void NameToDIE::Finalize() { m_map.Sort(std::less<DIERef>()); diff --git a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h index 61df1a628ab5913..27cf345300f69e6 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/NameToDIE.h @@ -16,6 +16,8 @@ #include "lldb/Core/dwarf.h" #include "lldb/lldb-defines.h" +namespace lldb_plugin { +namespace dwarf { class DWARFUnit; class NameToDIE { @@ -45,8 +47,7 @@ class NameToDIE { void ForEach(std::function<bool(lldb_private::ConstString name, - const DIERef &die_ref)> const - &callback) const; + const DIERef &die_ref)> const &callback) const; /// Decode a serialized version of this object from data. /// @@ -89,5 +90,7 @@ class NameToDIE { protected: lldb_private::UniqueCStringMap<DIERef> m_map; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_NAMETODIE_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp index e472074545a6f07..c6574881e0576c2 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp @@ -97,6 +97,7 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; LLDB_PLUGIN_DEFINE(SymbolFileDWARF) @@ -136,9 +137,8 @@ static PluginProperties &GetGlobalPluginProperties() { } static const llvm::DWARFDebugLine::LineTable * -ParseLLVMLineTable(lldb_private::DWARFContext &context, - llvm::DWARFDebugLine &line, dw_offset_t line_offset, - dw_offset_t unit_offset) { +ParseLLVMLineTable(DWARFContext &context, llvm::DWARFDebugLine &line, + dw_offset_t line_offset, dw_offset_t unit_offset) { Log *log = GetLog(DWARFLog::DebugInfo); llvm::DWARFDataExtractor data = context.getOrLoadLineData().GetAsLLVMDWARF(); @@ -159,7 +159,7 @@ ParseLLVMLineTable(lldb_private::DWARFContext &context, return *line_table; } -static bool ParseLLVMLineTablePrologue(lldb_private::DWARFContext &context, +static bool ParseLLVMLineTablePrologue(DWARFContext &context, llvm::DWARFDebugLine::Prologue &prologue, dw_offset_t line_offset, dw_offset_t unit_offset) { @@ -2428,7 +2428,7 @@ bool SymbolFileDWARF::DIEInDeclContext(const CompilerDeclContext &decl_ctx, // ...But if we are only checking root decl contexts, confirm that the // 'die' is a top-level context. if (only_root_namespaces) - return die.GetParent().Tag() == dwarf::DW_TAG_compile_unit; + return die.GetParent().Tag() == llvm::dwarf::DW_TAG_compile_unit; return true; } diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h index 5aaf8bd270ef7b1..2ab9e7590a3ee75 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h @@ -38,6 +38,14 @@ #include "DWARFIndex.h" #include "UniqueDWARFASTType.h" +class DWARFASTParserClang; + +namespace llvm { +class DWARFDebugAbbrev; +} // namespace llvm + +namespace lldb_plugin { +namespace dwarf { // Forward Declarations for this DWARF plugin class DebugMapModule; class DWARFCompileUnit; @@ -54,10 +62,6 @@ class SymbolFileDWARFDwo; class SymbolFileDWARFDwp; class UserID; -namespace llvm { -class DWARFDebugAbbrev; -} - #define DIE_IS_BEING_PARSED ((lldb_private::Type *)1) class SymbolFileDWARF : public lldb_private::SymbolFileCommon { @@ -78,7 +82,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFileCommon { friend class DebugMapModule; friend class DWARFCompileUnit; friend class DWARFDIE; - friend class DWARFASTParserClang; + friend class ::DWARFASTParserClang; // Static Functions static void Initialize(); @@ -285,7 +289,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFileCommon { void DumpClangAST(lldb_private::Stream &s) override; - lldb_private::DWARFContext &GetDWARFContext() { return m_context; } + DWARFContext &GetDWARFContext() { return m_context; } const std::shared_ptr<SymbolFileDWARFDwo> &GetDwpSymbolFile(); @@ -342,7 +346,6 @@ class SymbolFileDWARF : public lldb_private::SymbolFileCommon { m_file_index = file_index; } -protected: typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb_private::Type *> DIEToTypePtr; typedef llvm::DenseMap<const DWARFDebugInfoEntry *, lldb::VariableSP> @@ -534,7 +537,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFileCommon { llvm::once_flag m_dwp_symfile_once_flag; std::shared_ptr<SymbolFileDWARFDwo> m_dwp_symfile; - lldb_private::DWARFContext m_context; + DWARFContext m_context; llvm::once_flag m_info_once_flag; std::unique_ptr<DWARFDebugInfo> m_info; @@ -547,7 +550,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFileCommon { DebugMacrosMap m_debug_macros_map; ExternalTypeModuleMap m_external_type_modules; - std::unique_ptr<lldb_private::DWARFIndex> m_index; + std::unique_ptr<DWARFIndex> m_index; bool m_fetched_external_modules : 1; lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type; @@ -578,5 +581,7 @@ class SymbolFileDWARF : public lldb_private::SymbolFileCommon { /// an index that identifies the .DWO or .o file. std::optional<uint64_t> m_file_index; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARF_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp index eadedd32e1a4aaf..02c5c08b9d61706 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -42,6 +42,7 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; char SymbolFileDWARFDebugMap::ID; @@ -166,6 +167,8 @@ SymbolFileDWARFDebugMap::CompileUnitInfo::GetFileRangeMap( return file_range_map; } +namespace lldb_plugin { +namespace dwarf { class DebugMapModule : public Module { public: DebugMapModule(const ModuleSP &exe_module_sp, uint32_t cu_idx, @@ -222,6 +225,8 @@ class DebugMapModule : public Module { ModuleWP m_exe_module_wp; const uint32_t m_cu_idx; }; +} // namespace dwarf +} // namespace lldb_plugin void SymbolFileDWARFDebugMap::Initialize() { PluginManager::RegisterPlugin(GetPluginNameStatic(), diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h index 881fd4c45ff05a0..eab0801ffc811ad 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h @@ -20,6 +20,10 @@ #include "UniqueDWARFASTType.h" +class DWARFASTParserClang; + +namespace lldb_plugin { +namespace dwarf { class SymbolFileDWARF; class DWARFCompileUnit; class DWARFDebugAranges; @@ -161,7 +165,7 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFileCommon { enum { kHaveInitializedOSOs = (1 << 0), kNumFlags }; friend class DebugMapModule; - friend class DWARFASTParserClang; + friend class ::DWARFASTParserClang; friend class DWARFCompileUnit; friend class SymbolFileDWARF; struct OSOInfo { @@ -296,9 +300,10 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFileCommon { bool Supports_DW_AT_APPLE_objc_complete_type(SymbolFileDWARF *skip_dwarf_oso); - lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE( - const DWARFDIE &die, lldb_private::ConstString type_name, - bool must_be_implementation); + lldb::TypeSP + FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, + lldb_private::ConstString type_name, + bool must_be_implementation); UniqueDWARFASTTypeMap &GetUniqueDWARFASTTypeMap() { return m_unique_ast_type_map; @@ -403,5 +408,7 @@ class SymbolFileDWARFDebugMap : public lldb_private::SymbolFileCommon { size_t AddOSOARanges(SymbolFileDWARF *dwarf2Data, DWARFDebugAranges *debug_aranges); }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDEBUGMAP_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp index 78c3c19684e116d..3d92a9c384fb491 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.cpp @@ -21,6 +21,7 @@ using namespace lldb; using namespace lldb_private; +using namespace lldb_plugin::dwarf; char SymbolFileDWARFDwo::ID; diff --git a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h index e98ea49d939baf0..89f81e022a0ec4a 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDwo.h @@ -12,6 +12,8 @@ #include "SymbolFileDWARF.h" #include <optional> +namespace lldb_plugin { +namespace dwarf { class SymbolFileDWARFDwo : public SymbolFileDWARF { /// LLVM RTTI support. static char ID; @@ -65,9 +67,10 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF { lldb::TypeSP FindDefinitionTypeForDWARFDeclContext(const DWARFDIE &die) override; - lldb::TypeSP FindCompleteObjCDefinitionTypeForDIE( - const DWARFDIE &die, lldb_private::ConstString type_name, - bool must_be_implementation) override; + lldb::TypeSP + FindCompleteObjCDefinitionTypeForDIE(const DWARFDIE &die, + lldb_private::ConstString type_name, + bool must_be_implementation) override; SymbolFileDWARF &GetBaseSymbolFile() const { return m_base_symbol_file; } @@ -77,5 +80,7 @@ class SymbolFileDWARFDwo : public SymbolFileDWARF { SymbolFileDWARF &m_base_symbol_file; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_SYMBOLFILEDWARFDWO_H diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp index 22a921cf61389bc..7378b2502dc9358 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp +++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.cpp @@ -11,6 +11,7 @@ #include "lldb/Core/Declaration.h" using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; bool UniqueDWARFASTTypeList::Find(const DWARFDIE &die, const lldb_private::Declaration &decl, diff --git a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h index 0947d1e581c5237..f09bfa2044a1b15 100644 --- a/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h +++ b/lldb/source/Plugins/SymbolFile/DWARF/UniqueDWARFASTType.h @@ -16,6 +16,8 @@ #include "DWARFDIE.h" #include "lldb/Core/Declaration.h" +namespace lldb_plugin { +namespace dwarf { class UniqueDWARFASTType { public: // Constructors and Destructors @@ -74,8 +76,7 @@ class UniqueDWARFASTTypeMap { ~UniqueDWARFASTTypeMap() = default; - void Insert(lldb_private::ConstString name, - const UniqueDWARFASTType &entry) { + void Insert(lldb_private::ConstString name, const UniqueDWARFASTType &entry) { m_collection[name.GetCString()].Append(entry); } @@ -95,5 +96,7 @@ class UniqueDWARFASTTypeMap { typedef llvm::DenseMap<const char *, UniqueDWARFASTTypeList> collection; collection m_collection; }; +} // namespace dwarf +} // namespace lldb_plugin #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_UNIQUEDWARFASTTYPE_H diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp index 69cff0f35ae4ab2..9ca735e5820db57 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp @@ -86,6 +86,7 @@ using namespace lldb; using namespace lldb_private; using namespace lldb_private::dwarf; +using namespace lldb_plugin::dwarf; using namespace clang; using llvm::StringSwitch; diff --git a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h index 0544de3cd33befb..b18a7b31cf7acc0 100644 --- a/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h +++ b/lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.h @@ -514,7 +514,7 @@ class TypeSystemClang : public TypeSystem { size_t bit_size); // TypeSystem methods - DWARFASTParser *GetDWARFParser() override; + lldb_plugin::dwarf::DWARFASTParser *GetDWARFParser() override; PDBASTParser *GetPDBParser() override; npdb::PdbAstBuilder *GetNativePDBParser() override; _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits