1336823Sdim//===-- DebugNamesDWARFIndex.h ---------------------------------*- C++ -*-===// 2336823Sdim// 3353358Sdim// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4353358Sdim// See https://llvm.org/LICENSE.txt for license information. 5353358Sdim// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6336823Sdim// 7336823Sdim//===----------------------------------------------------------------------===// 8336823Sdim 9336823Sdim#ifndef LLDB_DEBUGNAMESDWARFINDEX_H 10336823Sdim#define LLDB_DEBUGNAMESDWARFINDEX_H 11336823Sdim 12336823Sdim#include "Plugins/SymbolFile/DWARF/DWARFIndex.h" 13336823Sdim#include "Plugins/SymbolFile/DWARF/LogChannelDWARF.h" 14336823Sdim#include "Plugins/SymbolFile/DWARF/ManualDWARFIndex.h" 15336823Sdim#include "lldb/Utility/ConstString.h" 16336823Sdim#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" 17336823Sdim 18336823Sdimnamespace lldb_private { 19336823Sdimclass DebugNamesDWARFIndex : public DWARFIndex { 20336823Sdimpublic: 21336823Sdim static llvm::Expected<std::unique_ptr<DebugNamesDWARFIndex>> 22336823Sdim Create(Module &module, DWARFDataExtractor debug_names, 23336823Sdim DWARFDataExtractor debug_str, DWARFDebugInfo *debug_info); 24336823Sdim 25336823Sdim void Preload() override { m_fallback.Preload(); } 26336823Sdim 27336823Sdim void GetGlobalVariables(ConstString basename, DIEArray &offsets) override; 28336823Sdim void GetGlobalVariables(const RegularExpression ®ex, 29336823Sdim DIEArray &offsets) override; 30336823Sdim void GetGlobalVariables(const DWARFUnit &cu, DIEArray &offsets) override; 31336823Sdim void GetObjCMethods(ConstString class_name, DIEArray &offsets) override {} 32336823Sdim void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, 33336823Sdim DIEArray &offsets) override; 34336823Sdim void GetTypes(ConstString name, DIEArray &offsets) override; 35336823Sdim void GetTypes(const DWARFDeclContext &context, DIEArray &offsets) override; 36336823Sdim void GetNamespaces(ConstString name, DIEArray &offsets) override; 37353358Sdim void GetFunctions(ConstString name, SymbolFileDWARF &dwarf, 38336823Sdim const CompilerDeclContext &parent_decl_ctx, 39336823Sdim uint32_t name_type_mask, 40336823Sdim std::vector<DWARFDIE> &dies) override; 41336823Sdim void GetFunctions(const RegularExpression ®ex, 42336823Sdim DIEArray &offsets) override; 43336823Sdim 44353358Sdim void ReportInvalidDIERef(const DIERef &ref, llvm::StringRef name) override {} 45336823Sdim void Dump(Stream &s) override; 46336823Sdim 47336823Sdimprivate: 48336823Sdim DebugNamesDWARFIndex(Module &module, 49336823Sdim std::unique_ptr<llvm::DWARFDebugNames> debug_names_up, 50336823Sdim DWARFDataExtractor debug_names_data, 51336823Sdim DWARFDataExtractor debug_str_data, 52336823Sdim DWARFDebugInfo &debug_info) 53336823Sdim : DWARFIndex(module), m_debug_info(debug_info), 54336823Sdim m_debug_names_data(debug_names_data), m_debug_str_data(debug_str_data), 55336823Sdim m_debug_names_up(std::move(debug_names_up)), 56336823Sdim m_fallback(module, &debug_info, GetUnits(*m_debug_names_up)) {} 57336823Sdim 58336823Sdim DWARFDebugInfo &m_debug_info; 59336823Sdim 60336823Sdim // LLVM DWARFDebugNames will hold a non-owning reference to this data, so keep 61336823Sdim // track of the ownership here. 62336823Sdim DWARFDataExtractor m_debug_names_data; 63336823Sdim DWARFDataExtractor m_debug_str_data; 64336823Sdim 65336823Sdim using DebugNames = llvm::DWARFDebugNames; 66336823Sdim std::unique_ptr<DebugNames> m_debug_names_up; 67336823Sdim ManualDWARFIndex m_fallback; 68336823Sdim 69353358Sdim llvm::Optional<DIERef> ToDIERef(const DebugNames::Entry &entry); 70336823Sdim void Append(const DebugNames::Entry &entry, DIEArray &offsets); 71336823Sdim 72336823Sdim static void MaybeLogLookupError(llvm::Error error, 73336823Sdim const DebugNames::NameIndex &ni, 74336823Sdim llvm::StringRef name); 75336823Sdim 76336823Sdim static llvm::DenseSet<dw_offset_t> GetUnits(const DebugNames &debug_names); 77336823Sdim}; 78336823Sdim 79336823Sdim} // namespace lldb_private 80336823Sdim 81336823Sdim#endif // LLDB_DEBUGNAMESDWARFINDEX_H 82