LLDB mainline
SymbolFileOnDemand.h
Go to the documentation of this file.
1//===-- SymbolFileOnDemand.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_SYMBOL_SYMBOLFILEONDEMAND_H
10#define LLDB_SYMBOL_SYMBOLFILEONDEMAND_H
11
12#include <mutex>
13#include <optional>
14#include <vector>
15
21#include "lldb/Utility/Flags.h"
23#include "lldb/Utility/Log.h"
24#include "lldb/lldb-private.h"
25
26namespace lldb_private {
27
28/// SymbolFileOnDemand wraps an actual SymbolFile by providing
29/// on demand symbol parsing/indexing to improve performance.
30/// By default SymbolFileOnDemand will skip load the underlying
31/// symbols. Any client can on demand hydrate the underlying
32/// SymbolFile via SymbolFile::SetLoadDebugInfoEnabled().
34 /// LLVM RTTI support.
35 static char ID;
36
37public:
38 /// LLVM RTTI support.
39 /// \{
40 bool isA(const void *ClassID) const override {
41 return ClassID == &ID || SymbolFile::isA(ClassID);
42 }
43 static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
44 /// \}
45
46 SymbolFileOnDemand(std::unique_ptr<SymbolFile> &&symbol_file);
48
49 // PluginInterface protocol
50 llvm::StringRef GetPluginName() override { return "ondemand"; }
51
53
54 void SetLoadDebugInfoEnabled() override;
55
57 lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx) override;
58
59 SymbolFile *GetBackingSymbolFile() override { return m_sym_file_impl.get(); }
60
62
63 std::recursive_mutex &GetModuleMutex() const override;
64
66 ParseLanguage(lldb_private::CompileUnit &comp_unit) override;
67
69 ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override;
70
71 void InitializeObject() override;
72
73 size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override;
74
75 bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override;
76
77 bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override;
78
80 lldb_private::CompileUnit &, llvm::DenseSet<lldb_private::SymbolFile *> &,
81 llvm::function_ref<bool(lldb_private::Module &)>) override;
82
84 lldb_private::FileSpecList &support_files) override;
85
86 bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override;
87
88 size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override;
89
92 std::vector<lldb_private::SourceModule> &imported_modules) override;
93
94 size_t ParseBlocksRecursive(lldb_private::Function &func) override;
95
96 size_t
98
100 std::optional<ArrayInfo> GetDynamicArrayInfoForUID(
101 lldb::user_id_t type_uid,
102 const lldb_private::ExecutionContext *exe_ctx) override;
103
104 bool CompleteType(lldb_private::CompilerType &compiler_type) override;
105
107
110
113
114 void
116
118 lldb::SymbolContextItem resolve_scope,
119 lldb_private::SymbolContext &sc) override;
120
123
125 const lldb_private::SourceLocationSpec &src_location_spec,
126 lldb::SymbolContextItem resolve_scope,
127 lldb_private::SymbolContextList &sc_list) override;
128
129 void Dump(lldb_private::Stream &s) override;
130 void DumpClangAST(lldb_private::Stream &s) override;
131
132 void
134 const lldb_private::CompilerDeclContext &parent_decl_ctx,
135 uint32_t max_matches,
136 lldb_private::VariableList &variables) override;
137
139 uint32_t max_matches,
140 lldb_private::VariableList &variables) override;
141
142 void FindFunctions(const lldb_private::Module::LookupInfo &lookup_info,
143 const lldb_private::CompilerDeclContext &parent_decl_ctx,
144 bool include_inlines,
145 lldb_private::SymbolContextList &sc_list) override;
146
148 bool include_inlines,
149 lldb_private::SymbolContextList &sc_list) override;
150
152 const std::string &scope_qualified_name,
153 std::vector<lldb_private::ConstString> &mangled_names) override;
154
155 void
157 const lldb_private::CompilerDeclContext &parent_decl_ctx,
158 uint32_t max_matches,
159 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
160 lldb_private::TypeMap &types) override;
161
162 void FindTypes(llvm::ArrayRef<lldb_private::CompilerContext> pattern,
164 llvm::DenseSet<SymbolFile *> &searched_symbol_files,
165 lldb_private::TypeMap &types) override;
166
168 lldb::TypeClass type_mask,
169 lldb_private::TypeList &type_list) override;
170
171 llvm::Expected<lldb::TypeSystemSP>
173
176 const lldb_private::CompilerDeclContext &parent_decl_ctx,
177 bool only_root_namespaces) override;
178
179 std::vector<std::unique_ptr<lldb_private::CallEdge>>
180 ParseCallEdgesInFunction(UserID func_id) override;
181
182 lldb::UnwindPlanSP
183 GetUnwindPlan(const Address &address,
184 const RegisterInfoResolver &resolver) override;
185
186 llvm::Expected<lldb::addr_t> GetParameterStackSize(Symbol &symbol) override;
187
188 void PreloadSymbols() override;
189
190 uint64_t GetDebugInfoSize() override;
193
194 uint32_t GetAbilities() override;
195
196 Symtab *GetSymtab() override { return m_sym_file_impl->GetSymtab(); }
197
199 return m_sym_file_impl->GetObjectFile();
200 }
201 const ObjectFile *GetObjectFile() const override {
202 return m_sym_file_impl->GetObjectFile();
203 }
205 return m_sym_file_impl->GetMainObjectFile();
206 }
207
209 return m_sym_file_impl->SectionFileAddressesChanged();
210 }
211
213 return m_sym_file_impl->GetDebugInfoIndexWasLoadedFromCache();
214 }
216 m_sym_file_impl->SetDebugInfoIndexWasLoadedFromCache();
217 }
218 bool GetDebugInfoIndexWasSavedToCache() const override {
219 return m_sym_file_impl->GetDebugInfoIndexWasSavedToCache();
220 }
222 m_sym_file_impl->SetDebugInfoIndexWasSavedToCache();
223 }
225 return m_sym_file_impl->GetDebugInfoHadFrameVariableErrors();
226 }
228 return m_sym_file_impl->SetDebugInfoHadFrameVariableErrors();
229 }
230
231 lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name,
232 std::optional<uint64_t> byte_size,
233 SymbolContextScope *context,
234 lldb::user_id_t encoding_uid,
235 Type::EncodingDataType encoding_uid_type,
236 const Declaration &decl,
237 const CompilerType &compiler_qual_type,
238 Type::ResolveState compiler_type_resolve_state,
239 uint32_t opaque_payload = 0) override {
240 return m_sym_file_impl->MakeType(
241 uid, name, byte_size, context, encoding_uid, encoding_uid_type, decl,
242 compiler_qual_type, compiler_type_resolve_state, opaque_payload);
243 }
244
245 lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override {
246 return m_sym_file_impl->CopyType(other_type);
247 }
248
249private:
250 Log *GetLog() const { return ::lldb_private::GetLog(LLDBLog::OnDemand); }
251
254 }
255
256private:
258 bool m_preload_symbols = false;
259 std::unique_ptr<SymbolFile> m_sym_file_impl;
260};
261} // namespace lldb_private
262
263#endif // LLDB_SYMBOL_SYMBOLFILEONDEMAND_H
A section + offset based address class.
Definition: Address.h:59
A class that describes a compilation unit.
Definition: CompileUnit.h:41
Represents a generic declaration context in a program.
Represents a generic declaration such as a function declaration.
Definition: CompilerDecl.h:28
Generic representation of a type in a programming language.
Definition: CompilerType.h:36
A uniqued constant string class.
Definition: ConstString.h:40
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
A file collection class.
Definition: FileSpecList.h:24
const ConstString & GetFilename() const
Filename string const get accessor.
Definition: FileSpec.h:240
A class that describes a function.
Definition: Function.h:409
A class that encapsulates name lookup information.
Definition: Module.h:950
A class that describes an executable image and its associated object and symbol files.
Definition: Module.h:88
A plug-in interface definition class for object file parsers.
Definition: ObjectFile.h:43
virtual FileSpec & GetFileSpec()
Get accessor to the object file specification.
Definition: ObjectFile.h:273
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
This base class provides an interface to stack frames.
Definition: StackFrame.h:41
std::chrono::duration< double > Duration
Definition: Statistics.h:31
An error handling class.
Definition: Status.h:44
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Defines a list of symbol context objects.
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
SymbolFileOnDemand wraps an actual SymbolFile by providing on demand symbol parsing/indexing to impro...
void FindTypes(llvm::ArrayRef< lldb_private::CompilerContext > pattern, lldb_private::LanguageSet languages, llvm::DenseSet< SymbolFile * > &searched_symbol_files, lldb_private::TypeMap &types) override
uint32_t GetAbilities() override
Get a mask of what this symbol file supports for the object file that it was constructed with.
llvm::StringRef GetPluginName() override
ObjectFile * GetObjectFile() override
void SetDebugInfoHadFrameVariableErrors() override
void GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector< lldb_private::ConstString > &mangled_names) override
size_t ParseTypes(lldb_private::CompileUnit &comp_unit) override
size_t ParseBlocksRecursive(lldb_private::Function &func) override
bool ParseLineTable(lldb_private::CompileUnit &comp_unit) override
std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx) override
If type_uid points to an array type, return its characteristics.
bool ParseImportedModules(const lldb_private::SymbolContext &sc, std::vector< lldb_private::SourceModule > &imported_modules) override
lldb_private::Type * ResolveTypeUID(lldb::user_id_t type_uid) override
uint32_t ResolveSymbolContext(const lldb_private::Address &so_addr, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContext &sc) override
uint32_t ResolveSymbolContext(const lldb_private::SourceLocationSpec &src_location_spec, lldb::SymbolContextItem resolve_scope, lldb_private::SymbolContextList &sc_list) override
static bool classof(const SymbolFile *obj)
bool isA(const void *ClassID) const override
LLVM RTTI support.
bool GetDebugInfoIndexWasSavedToCache() const override
void DumpClangAST(lldb_private::Stream &s) override
lldb::UnwindPlanSP GetUnwindPlan(const Address &address, const RegisterInfoResolver &resolver) override
ObjectFile * GetMainObjectFile() override
void SectionFileAddressesChanged() override
Notify the SymbolFile that the file addresses in the Sections for this module have been changed.
void FindGlobalVariables(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, lldb_private::VariableList &variables) override
bool GetDebugInfoHadFrameVariableErrors() const override
Accessors for the bool that indicates if there was debug info, but errors stopped variables from bein...
lldb_private::CompilerDeclContext FindNamespace(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, bool only_root_namespaces) override
Finds a namespace of name name and whose parent context is parent_decl_ctx.
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language) override
std::recursive_mutex & GetModuleMutex() const override
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
llvm::Expected< lldb::addr_t > GetParameterStackSize(Symbol &symbol) override
Return the number of stack bytes taken up by the parameters to this function.
lldb_private::XcodeSDK ParseXcodeSDK(lldb_private::CompileUnit &comp_unit) override
Return the Xcode SDK comp_unit was compiled against.
bool CompleteType(lldb_private::CompilerType &compiler_type) override
bool ForEachExternalModule(lldb_private::CompileUnit &, llvm::DenseSet< lldb_private::SymbolFile * > &, llvm::function_ref< bool(lldb_private::Module &)>) override
bool GetLoadDebugInfoEnabled() override
Whether debug info will be loaded or not.
lldb_private::StatsDuration::Duration GetDebugInfoParseTime() override
Return the time taken to parse the debug information.
lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx) override
bool ParseSupportFiles(lldb_private::CompileUnit &comp_unit, lldb_private::FileSpecList &support_files) override
const ObjectFile * GetObjectFile() const override
void Dump(lldb_private::Stream &s) override
uint64_t GetDebugInfoSize() override
Metrics gathering functions.
void SetLoadDebugInfoEnabled() override
Specify debug info should be loaded.
std::unique_ptr< SymbolFile > m_sym_file_impl
bool ParseIsOptimized(lldb_private::CompileUnit &comp_unit) override
lldb_private::CompilerDecl GetDeclForUID(lldb::user_id_t uid) override
void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list) override
size_t ParseFunctions(lldb_private::CompileUnit &comp_unit) override
bool GetDebugInfoIndexWasLoadedFromCache() const override
Accessors for the bool that indicates if the debug info index was loaded from, or saved to the module...
lldb_private::CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid) override
lldb_private::CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid) override
std::vector< std::unique_ptr< lldb_private::CallEdge > > ParseCallEdgesInFunction(UserID func_id) override
lldb_private::StatsDuration::Duration GetDebugInfoIndexTime() override
Return the time it took to index the debug information in the object file.
lldb::TypeSP MakeType(lldb::user_id_t uid, ConstString name, std::optional< uint64_t > byte_size, SymbolContextScope *context, lldb::user_id_t encoding_uid, Type::EncodingDataType encoding_uid_type, const Declaration &decl, const CompilerType &compiler_qual_type, Type::ResolveState compiler_type_resolve_state, uint32_t opaque_payload=0) override
void SetDebugInfoIndexWasLoadedFromCache() override
void FindFunctions(const lldb_private::Module::LookupInfo &lookup_info, const lldb_private::CompilerDeclContext &parent_decl_ctx, bool include_inlines, lldb_private::SymbolContextList &sc_list) override
void FindTypes(lldb_private::ConstString name, const lldb_private::CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, lldb_private::TypeMap &types) override
bool ParseDebugMacros(lldb_private::CompileUnit &comp_unit) override
size_t ParseVariablesForContext(const lldb_private::SymbolContext &sc) override
static char ID
LLVM RTTI support.
lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override
void ParseDeclsForContext(lldb_private::CompilerDeclContext decl_ctx) override
SymbolFile * GetBackingSymbolFile() override
SymbolFileOnDemand class overrides this to return the underlying backing SymbolFile implementation th...
void SetDebugInfoIndexWasSavedToCache() override
lldb_private::Status CalculateFrameVariableError(lldb_private::StackFrame &frame) override
Subclasses will override this function to for GetFrameVariableError().
lldb::LanguageType ParseLanguage(lldb_private::CompileUnit &comp_unit) override
void InitializeObject() override
Initialize the SymbolFile object.
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:49
virtual bool isA(const void *ClassID) const
LLVM RTTI support.
Definition: SymbolFile.h:56
An abstraction for Xcode-style SDKs that works like ArchSpec.
Definition: XcodeSDK.h:24
A class that represents a running process on the host machine.
Definition: SBAttachInfo.h:14
LanguageType
Programming language type.
uint64_t user_id_t
Definition: lldb-types.h:80
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:45
A mix in class that contains a generic user ID.
Definition: UserID.h:31