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 virtual void
69 const CompilerDeclContext &parent_decl_ctx,
70 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
71 virtual void
73 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
74
75 virtual void Dump(Stream &s) = 0;
76
78
79protected:
82
83 /// Helper function implementing common logic for processing function dies. If
84 /// the function given by "ref" matches search criteria given by
85 /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
86 /// vector.
87 bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DIERef ref,
89 const CompilerDeclContext &parent_decl_ctx,
90 llvm::function_ref<bool(DWARFDIE die)> callback);
91
93 public:
94 DIERefCallbackImpl(const DWARFIndex &index,
95 llvm::function_ref<bool(DWARFDIE die)> callback,
96 llvm::StringRef name);
97 bool operator()(DIERef ref) const;
98 bool operator()(const llvm::AppleAcceleratorTable::Entry &entry) const;
99
100 private:
103 const llvm::function_ref<bool(DWARFDIE die)> m_callback;
104 const llvm::StringRef m_name;
105 };
107 DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback,
108 llvm::StringRef name = {}) const {
109 return DIERefCallbackImpl(*this, callback, name);
110 }
111
112 void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;
113
114 /// Implementation of `GetFullyQualifiedType` to check a single entry,
115 /// shareable with derived classes.
116 bool
117 GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,
118 llvm::function_ref<bool(DWARFDIE die)> callback);
119};
120} // namespace dwarf
121} // namespace lldb_private::plugin
122
123#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:904
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
std::chrono::duration< double > Duration
Definition: Statistics.h:31
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Identifies a DWARF debug info entry within a given Module.
Definition: DIERef.h:30
const llvm::function_ref< bool(DWARFDIE die)> m_callback
Definition: DWARFIndex.h:103
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
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:77
bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DIERef ref, SymbolFileDWARF &dwarf, 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 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:107
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:118
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const
Definition: DWARFIndex.cpp:111
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:126