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 virtual void
58 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
59 virtual void
61 const CompilerDeclContext &parent_decl_ctx,
62 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
63 virtual void
65 llvm::function_ref<bool(DWARFDIE die)> callback) = 0;
66
67 virtual void Dump(Stream &s) = 0;
68
70
71protected:
74
75 /// Helper function implementing common logic for processing function dies. If
76 /// the function given by "ref" matches search criteria given by
77 /// "parent_decl_ctx" and "name_type_mask", it is inserted into the "dies"
78 /// vector.
79 bool ProcessFunctionDIE(const Module::LookupInfo &lookup_info, DIERef ref,
81 const CompilerDeclContext &parent_decl_ctx,
82 llvm::function_ref<bool(DWARFDIE die)> callback);
83
85 public:
86 DIERefCallbackImpl(const DWARFIndex &index,
87 llvm::function_ref<bool(DWARFDIE die)> callback,
88 llvm::StringRef name);
89 bool operator()(DIERef ref) const;
90 bool operator()(const llvm::AppleAcceleratorTable::Entry &entry) const;
91
92 private:
95 const llvm::function_ref<bool(DWARFDIE die)> m_callback;
96 const llvm::StringRef m_name;
97 };
99 DIERefCallback(llvm::function_ref<bool(DWARFDIE die)> callback,
100 llvm::StringRef name = {}) const {
101 return DIERefCallbackImpl(*this, callback, name);
102 }
103
104 void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const;
105};
106} // namespace dwarf
107} // namespace lldb_private::plugin
108
109#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:949
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:95
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:69
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:24
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:99
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().
void ReportInvalidDIERef(DIERef ref, llvm::StringRef name) const
Definition: DWARFIndex.cpp:109
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.