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#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
16
17#include "lldb/Core/Module.h"
19
20namespace lldb_private::plugin {
21namespace dwarf {
22class DWARFDeclContext;
23class DWARFDIE;
24
26public:
27 DWARFIndex(Module &module) : m_module(module) {}
28 virtual ~DWARFIndex();
29
30 virtual void Preload() = 0;
31
32 /// Finds global variables with the given base name. Any additional filtering
33 /// (e.g., to only retrieve variables from a given context) should be done by
34 /// the consumer.
35 virtual void
37 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
38
39 virtual void
41 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
42 /// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
43 virtual void
45 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
46 virtual void
48 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
49 virtual void
50 GetCompleteObjCClass(ConstString class_name, bool must_be_implementation,
51 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
52 virtual void GetTypes(ConstString name,
53 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
54 virtual void GetTypes(const DWARFDeclContext &context,
55 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
56
57 /// Finds all DIEs whose fully qualified name matches `context`. A base
58 /// implementation is provided, and it uses the entire CU to check the DIE
59 /// parent hierarchy. Specializations should override this if they are able
60 /// to provide a faster implementation.
61 virtual void
63 llvm::function_ref<bool(DWARFDIE die)> callback);
64 virtual void
66 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
67 /// Get type DIEs meeting requires of \a query.
68 /// in its decl parent chain as subset. A base implementation is provided,
69 /// Specializations should override this if they are able to provide a faster
70 /// implementation.
71 virtual void
73 llvm::function_ref<bool(DWARFDIE die)> callback);
74 /// Get namespace DIEs whose base name match \param name with \param
75 /// parent_decl_ctx in its decl parent chain. A base implementation
76 /// is provided. Specializations should override this if they are able to
77 /// provide a faster implementation.
78 virtual void
80 const CompilerDeclContext &parent_decl_ctx,
81 llvm::function_ref<bool(DWARFDIE die)> callback);
82 virtual void
84 const CompilerDeclContext &parent_decl_ctx,
85 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
86 virtual void
88 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
89
90 virtual void Dump(Stream &s) = 0;
91
93
95
96protected:
99
100 /// Helper function implementing common logic for processing function dies. If
101 /// the function given by "die" matches search criteria given by
102 /// "parent_decl_ctx" and "name_type_mask", it calls the callback with the
103 /// given die.
104 bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DWARFDIE die,
105 const CompilerDeclContext &parent_decl_ctx,
106 llvm::function_ref<bool(DWARFDIE die)> callback);
107
109 public:
110 DIERefCallbackImpl(const DWARFIndex &index,
111 llvm::function_ref<bool(DWARFDIE die)> callback,
112 llvm::StringRef name);
113 bool operator()(DIERef ref) const;
114 bool operator()(const llvm::AppleAcceleratorTable::Entry &entry) const;
115
116 private:
119 const llvm::function_ref<bool(DWARFDIE die)> m_callback;
120 const llvm::StringRef m_name;
121 };
123 DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback,
124 llvm::StringRef name = {}) const {
125 return DIERefCallbackImpl(*this, callback, name);
126 }
127
128 void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;
129
130 /// Implementation of `GetFullyQualifiedType` to check a single entry,
131 /// shareable with derived classes.
132 bool
133 GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,
134 llvm::function_ref<bool(DWARFDIE die)> callback);
135
136 /// Check if the type \a die can meet the requirements of \a query.
137 bool
138 ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die,
139 llvm::function_ref<bool(DWARFDIE die)> callback);
141 const CompilerDeclContext &parent_decl_ctx, DWARFDIE die,
142 llvm::function_ref<bool(DWARFDIE die)> callback);
143};
144} // namespace dwarf
145} // namespace lldb_private::plugin
146
147#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H
Represents a generic declaration context in a program.
A uniqued constant string class.
Definition: ConstString.h:40
A class that encapsulates name lookup information.
Definition: Module.h:907
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:89
std::chrono::duration< double > Duration
Definition: Statistics.h:37
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
A class that contains all state required for type lookups.
Definition: Type.h:104
Identifies a DWARF debug info entry within a given Module.
Definition: DIERef.h:31
const llvm::function_ref< bool(DWARFDIE die)> m_callback
Definition: DWARFIndex.h:119
virtual void GetTypes(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
virtual void GetTypes(const DWARFDeclContext &context, llvm::function_ref< bool(DWARFDIE die)> callback)=0
bool ProcessTypeDIEMatchQuery(TypeQuery &query, DWARFDIE die, llvm::function_ref< bool(DWARFDIE die)> callback)
Check if the type die can meet the requirements of query.
Definition: DWARFIndex.cpp:137
bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DWARFDIE die, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)
Helper function implementing common logic for processing function dies.
Definition: DWARFIndex.cpp:26
virtual void GetObjCMethods(ConstString class_name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
virtual void GetCompleteObjCClass(ConstString class_name, bool must_be_implementation, llvm::function_ref< bool(DWARFDIE die)> callback)=0
virtual void GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)=0
StatsDuration::Duration GetIndexTime()
Definition: DWARFIndex.h:92
virtual void GetFunctions(const RegularExpression &regex, llvm::function_ref< bool(DWARFDIE die)> callback)=0
DIERefCallbackImpl DIERefCallback(llvm::function_ref< bool(DWARFDIE die)> callback, llvm::StringRef name={}) const
Definition: DWARFIndex.h:123
virtual void GetNamespacesWithParents(ConstString name, const CompilerDeclContext &parent_decl_ctx, llvm::function_ref< bool(DWARFDIE die)> callback)
Get namespace DIEs whose base name match.
Definition: DWARFIndex.cpp:165
virtual void GetGlobalVariables(const RegularExpression &regex, llvm::function_ref< bool(DWARFDIE die)> callback)=0
virtual void Dump(Stream &s)=0
virtual void GetGlobalVariables(DWARFUnit &cu, llvm::function_ref< bool(DWARFDIE die)> callback)=0
cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
virtual void GetFullyQualifiedType(const DWARFDeclContext &context, llvm::function_ref< bool(DWARFDIE die)> callback)
Finds all DIEs whose fully qualified name matches context.
Definition: DWARFIndex.cpp:113
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const
Definition: DWARFIndex.cpp:106
bool ProcessNamespaceDieMatchParents(const CompilerDeclContext &parent_decl_ctx, DWARFDIE die, llvm::function_ref< bool(DWARFDIE die)> callback)
Definition: DWARFIndex.cpp:173
virtual void GetTypesWithQuery(TypeQuery &query, llvm::function_ref< bool(DWARFDIE die)> callback)
Get type DIEs meeting requires of query.
Definition: DWARFIndex.cpp:130
virtual void GetNamespaces(ConstString name, llvm::function_ref< bool(DWARFDIE die)> callback)=0
virtual void GetGlobalVariables(ConstString basename, llvm::function_ref< bool(DWARFDIE die)> callback)=0
Finds global variables with the given base name.
bool GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die, llvm::function_ref< bool(DWARFDIE die)> callback)
Implementation of GetFullyQualifiedType to check a single entry, shareable with derived classes.
Definition: DWARFIndex.cpp:121