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