1 //===-- DebugNamesDWARFIndex.h ---------------------------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 #ifndef LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H 10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H 11 12 #include "Plugins/SymbolFile/DWARF/DWARFIndex.h" 13 #include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" 14 #include "Plugins/SymbolFile/DWARF/ManualDWARFIndex.h" 15 #include "Plugins/SymbolFile/DWARF/SymbolFileDWARF.h" 16 #include "lldb/Utility/ConstString.h" 17 #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" 18 19 namespace lldb_private { 20 class DebugNamesDWARFIndex : public DWARFIndex { 21 public: 22 static llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> 23 Create(Module &module, DWARFDataExtractor debug_names, 24 DWARFDataExtractor debug_str, SymbolFileDWARF &dwarf); 25 26 void Preload() override { m_fallback.Preload(); } 27 28 void GetGlobalVariables(ConstString basename, DIEArray &offsets) override; 29 void GetGlobalVariables(const RegularExpression ®ex, 30 DIEArray &offsets) override; 31 void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override; 32 void GetObjCMethods(ConstString class_name, DIEArray &offsets) override {} 33 void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, 34 DIEArray &offsets) override; 35 void GetTypes(ConstString name, DIEArray &offsets) override; 36 void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override; 37 void GetNamespaces(ConstString name, DIEArray &offsets) override; 38 void GetFunctions(ConstString name, SymbolFileDWARF &dwarf, 39 const CompilerDeclContext &parent_decl_ctx, 40 uint32_t name_type_mask, 41 std::vector<DWARFDIE> &dies) override; 42 void GetFunctions(const RegularExpression ®ex, 43 DIEArray &offsets) override; 44 45 void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override {} 46 void Dump(Stream &s) override; 47 48 private: 49 DebugNamesDWARFIndex(Module &module, 50 std::unique_ptr<llvm::DWARFDebugNames> debug_names_up, 51 DWARFDataExtractor debug_names_data, 52 DWARFDataExtractor debug_str_data, 53 SymbolFileDWARF &dwarf) 54 : DWARFIndex(module), m_debug_info(dwarf.DebugInfo()), 55 m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data), 56 m_debug_names_up(std::move(debug_names_up)), 57 m_fallback(module, dwarf, GetUnits(*m_debug_names_up)) {} 58 59 DWARFDebugInfo &m_debug_info; 60 61 // LLVM DWARFDebugNames will hold a non-owning reference to this data, so keep 62 // track of the ownership here. 63 DWARFDataExtractor m_debug_names_data; 64 DWARFDataExtractor m_debug_str_data; 65 66 using DebugNames = llvm::DWARFDebugNames; 67 std::unique_ptr<DebugNames> m_debug_names_up; 68 ManualDWARFIndex m_fallback; 69 70 llvm::Optional<DIERef> ToDIERef(const DebugNames::Entry &entry); 71 void Append(const DebugNames::Entry &entry, DIEArray &offsets); 72 73 static void MaybeLogLookupError(llvm::Error error, 74 const DebugNames::NameIndex &ni, 75 llvm::StringRef name); 76 77 static llvm::DenseSet<dw_offset_t> GetUnits(const DebugNames &debug_names); 78 }; 79 80 } // namespace lldb_private 81 82 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DEBUGNAMESDWARFINDEX_H 83