Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/lldb/source/Plugins/SymbolFile/DWARF/DWARFIndex.h
39645 views
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
#include "llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h"
16
17
#include "lldb/Core/Module.h"
18
#include "lldb/Target/Statistics.h"
19
20
namespace lldb_private::plugin {
21
namespace dwarf {
22
class DWARFDeclContext;
23
class DWARFDIE;
24
25
class DWARFIndex {
26
public:
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
36
GetGlobalVariables(ConstString basename,
37
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
38
39
virtual void
40
GetGlobalVariables(const RegularExpression &regex,
41
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
42
/// \a cu must be the skeleton unit if possible, not GetNonSkeletonUnit().
43
virtual void
44
GetGlobalVariables(DWARFUnit &cu,
45
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
46
virtual void
47
GetObjCMethods(ConstString class_name,
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
62
GetFullyQualifiedType(const DWARFDeclContext &context,
63
llvm::function_ref<bool(DWARFDIE die)> callback);
64
virtual void
65
GetNamespaces(ConstString name,
66
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
67
virtual void
68
GetFunctions(const Module::LookupInfo &lookup_info, SymbolFileDWARF &dwarf,
69
const CompilerDeclContext &parent_decl_ctx,
70
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
71
virtual void
72
GetFunctions(const RegularExpression &regex,
73
llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
74
75
virtual void Dump(Stream &s) = 0;
76
77
StatsDuration::Duration GetIndexTime() { return m_index_time; }
78
79
protected:
80
Module &m_module;
81
StatsDuration m_index_time;
82
83
/// Helper function implementing common logic for processing function dies. If
84
/// the function given by "die" matches search criteria given by
85
/// "parent_decl_ctx" and "name_type_mask", it calls the callback with the
86
/// given die.
87
bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DWARFDIE die,
88
const CompilerDeclContext &parent_decl_ctx,
89
llvm::function_ref<bool(DWARFDIE die)> callback);
90
91
class DIERefCallbackImpl {
92
public:
93
DIERefCallbackImpl(const DWARFIndex &index,
94
llvm::function_ref<bool(DWARFDIE die)> callback,
95
llvm::StringRef name);
96
bool operator()(DIERef ref) const;
97
bool operator()(const llvm::AppleAcceleratorTable::Entry &entry) const;
98
99
private:
100
const DWARFIndex &m_index;
101
SymbolFileDWARF &m_dwarf;
102
const llvm::function_ref<bool(DWARFDIE die)> m_callback;
103
const llvm::StringRef m_name;
104
};
105
DIERefCallbackImpl
106
DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback,
107
llvm::StringRef name = {}) const {
108
return DIERefCallbackImpl(*this, callback, name);
109
}
110
111
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;
112
113
/// Implementation of `GetFullyQualifiedType` to check a single entry,
114
/// shareable with derived classes.
115
bool
116
GetFullyQualifiedTypeImpl(const DWARFDeclContext &context, DWARFDIE die,
117
llvm::function_ref<bool(DWARFDIE die)> callback);
118
};
119
} // namespace dwarf
120
} // namespace lldb_private::plugin
121
122
#endif // LLDB_SOURCE_PLUGINS_SYMBOLFILE_DWARF_DWARFINDEX_H
123
124