1 //===-- DWARFIndex.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_DWARFINDEX_H 10 #define LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H 11 12 #include "Plugins/SymbolFile/DWARF/DIERef.h" 13 #include "Plugins/SymbolFile/DWARF/DWARFDIE.h" 14 #include "Plugins/SymbolFile/DWARF/DWARFFormValue.h" 15 #include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h" 16 17 #include "lldb/Core/Module.h" 18 #include "lldb/Target/Statistics.h" 19 20 class DWARFDeclContext; 21 class DWARFDIE; 22 23 namespace lldb_private { 24 class DWARFIndex { 25 public: 26 DWARFIndex(Module &module) : m_module(module) {} 27 virtual ~DWARFIndex(); 28 29 virtual void Preload() = 0; 30 31 /// Finds global variables with the given base name. Any additional filtering 32 /// (e.g., to only retrieve variables from a given context) should be done by 33 /// the consumer. 34 virtual void 35 GetGlobalVariables(ConstString basename, 36 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 37 38 virtual void 39 GetGlobalVariables(const RegularExpression ®ex, 40 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 41 /// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit(). 42 virtual void 43 GetGlobalVariables(DWARFUnit &cu, 44 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 45 virtual void 46 GetObjCMethods(ConstString class_name, 47 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 48 virtual void 49 GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, 50 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 51 virtual void GetTypes(ConstString name, 52 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 53 virtual void GetTypes(const DWARFDeclContext &context, 54 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 55 virtual void 56 GetNamespaces(ConstString name, 57 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 58 virtual void 59 GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, 60 const CompilerDeclContext &parent_decl_ctx, 61 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 62 virtual void 63 GetFunctions(const RegularExpression ®ex, 64 llvm::function_ref<bool(DWARFDIE die)> callback) = 0; 65 66 virtual void Dump(Stream &s) = 0; 67 68 StatsDuration::Duration GetIndexTime() { return m_index_time; } 69 70 protected: 71 Module &m_module; 72 StatsDuration m_index_time; 73 74 /// Helper function implementing common logic for processing function dies. If 75 /// the function given by "ref" matches search criteria given by 76 /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies" 77 /// vector. 78 bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DIERef ref, 79 SymbolFileDWARF &dwarf, 80 const CompilerDeclContext &parent_decl_ctx, 81 llvm::function_ref<bool(DWARFDIE die)> callback); 82 83 class DIERefCallbackImpl { 84 public: 85 DIERefCallbackImpl(const DWARFIndex &index, 86 llvm::function_ref<bool(DWARFDIE die)> callback, 87 llvm::StringRef name); 88 bool operator()(DIERef ref) const; 89 bool operator()(const llvm::AppleAcceleratorTable::Entry &entry) const; 90 91 private: 92 const DWARFIndex &m_index; 93 SymbolFileDWARF &m_dwarf; 94 const llvm::function_ref<bool(DWARFDIE die)> m_callback; 95 const llvm::StringRef m_name; 96 }; 97 DIERefCallbackImpl 98 DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback, 99 llvm::StringRef name = {}) const { 100 return DIERefCallbackImpl(*this, callback, name); 101 } 102 103 void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const; 104 }; 105 } // namespace lldb_private 106 107 #endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H 108