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