LLDB  mainline
DWARFIndex.h
Go to the documentation of this file.
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 
15 
16 class DWARFDeclContext;
17 class DWARFDIE;
18 
19 namespace lldb_private {
20 class DWARFIndex {
21 public:
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
32  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
33 
34  virtual void
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
52  llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
53  virtual void
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:
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 
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:
87  const llvm::function_ref<bool(DWARFDIE die)> m_callback;
88  const llvm::StringRef m_name;
89  };
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
A class that represents a running process on the host machine.
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Represents a generic declaration context in a program.
virtual void GetFunctions(ConstString name, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, llvm::function_ref< bool(DWARFDIE die)> callback)=0
virtual void GetTypes(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
DIERefCallbackImpl DIERefCallback(llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name={}) const
Definition: DWARFIndex.h:91
Identifies a DWARF debug info entry within a given Module.
Definition: DIERef.h:26
DIERefCallbackImpl(const DWARFIndex &index, llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name)
Definition: DWARFIndex.cpp:67
const llvm::function_ref< bool(DWARFDIE die)> m_callback
Definition: DWARFIndex.h:87
virtual void GetGlobalVariables(ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback)=0
Finds global variables with the given base name.
bool ProcessFunctionDIE(llvm::StringRef name, DIERef ref, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, uint32_t name_type_mask, llvm::function_ref< bool(DWARFDIE die)> callback)
Helper function implementing common logic for processing function dies.
Definition: DWARFIndex.cpp:21
virtual void Preload()=0
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:75
virtual void GetObjCMethods(ConstString class_name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
virtual void Dump(Stream &s)=0
virtual void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback)=0
A uniqued constant string class.
Definition: ConstString.h:40
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const
Definition: DWARFIndex.cpp:81
virtual void GetNamespaces(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
DWARFIndex(Module &module)
Definition: DWARFIndex.h:22