LLDB mainline
SymbolFile.h
Go to the documentation of this file.
1//===-- SymbolFile.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_SYMBOLFILE_H
10#define LLDB_SYMBOL_SYMBOLFILE_H
11
12#include "lldb/Core/Module.h"
22#include "lldb/Symbol/Type.h"
28#include "lldb/lldb-private.h"
29#include "llvm/ADT/DenseSet.h"
30#include "llvm/ADT/SmallSet.h"
31#include "llvm/Support/Errc.h"
32
33#include <mutex>
34#include <optional>
35#include <unordered_map>
36
37#if defined(LLDB_CONFIGURATION_DEBUG)
38#define ASSERT_MODULE_LOCK(expr) (expr->AssertModuleLock())
39#else
40#define ASSERT_MODULE_LOCK(expr) ((void)0)
41#endif
42
43namespace lldb_private {
44
45/// Provides public interface for all SymbolFiles. Any protected
46/// virtual members should go into SymbolFileCommon; most SymbolFile
47/// implementations should inherit from SymbolFileCommon to override
48/// the behaviors except SymbolFileOnDemand which inherits
49/// public interfaces from SymbolFile and forward to underlying concrete
50/// SymbolFile implementation.
52 /// LLVM RTTI support.
53 static char ID;
54
55public:
56 /// LLVM RTTI support.
57 /// \{
58 virtual bool isA(const void *ClassID) const { return ClassID == &ID; }
59 static bool classof(const SymbolFile *obj) { return obj->isA(&ID); }
60 /// \}
61
62 // Symbol file ability bits.
63 //
64 // Each symbol file can claim to support one or more symbol file abilities.
65 // These get returned from SymbolFile::GetAbilities(). These help us to
66 // determine which plug-in will be best to load the debug information found
67 // in files. Symbols is the least-significant bit so a plug-in reporting any
68 // other ability ranks ahead of one reporting only Symbols.
69 enum Abilities {
70 Symbols = (1u << 0),
71 CompileUnits = (1u << 1),
72 LineTables = (1u << 2),
73 Functions = (1u << 3),
74 Blocks = (1u << 4),
75 GlobalVariables = (1u << 5),
76 LocalVariables = (1u << 6),
77 VariableTypes = (1u << 7),
78 /// All detailed debug-information abilities. Symbols is excluded because
79 /// it describes information from the object file's symbol table.
82 };
83
84 static SymbolFile *FindPlugin(lldb::ObjectFileSP objfile_sp);
85
86 // Constructors and Destructors
87 SymbolFile() = default;
88
89 ~SymbolFile() override = default;
90
91 /// SymbolFileOnDemand class overrides this to return the underlying
92 /// backing SymbolFile implementation that loads on-demand.
93 virtual SymbolFile *GetBackingSymbolFile() { return this; }
94
95 /// Get a mask of what this symbol file supports for the object file
96 /// that it was constructed with.
97 ///
98 /// Each symbol file gets to respond with a mask of abilities that
99 /// it supports for each object file. This happens when we are
100 /// trying to figure out which symbol file plug-in will get used
101 /// for a given object file. The plug-in that responds with the
102 /// best mix of "SymbolFile::Abilities" bits set, will get chosen to
103 /// be the symbol file parser. This allows each plug-in to check for
104 /// sections that contain data a symbol file plug-in would need. For
105 /// example the DWARF plug-in requires DWARF sections in a file that
106 /// contain debug information. If the DWARF plug-in doesn't find
107 /// these sections, it won't respond with many ability bits set, and
108 /// we will probably fall back to the symbol table SymbolFile plug-in
109 /// which uses any information in the symbol table. Also, plug-ins
110 /// might check for some specific symbols in a symbol table in the
111 /// case where the symbol table contains debug information (STABS
112 /// and COFF). Not a lot of work should happen in these functions
113 /// as the plug-in might not get selected due to another plug-in
114 /// having more abilities. Any initialization work should be saved
115 /// for "void SymbolFile::InitializeObject()" which will get called
116 /// on the SymbolFile object with the best set of abilities.
117 ///
118 /// \return
119 /// A uint32_t mask containing bits from the SymbolFile::Abilities
120 /// enumeration. Any bits that are set represent an ability that
121 /// this symbol plug-in can parse from the object file.
122 virtual uint32_t GetAbilities() = 0;
123 virtual uint32_t CalculateAbilities() = 0;
124
125 /// Symbols file subclasses should override this to return the Module that
126 /// owns the TypeSystem that this symbol file modifies type information in.
127 virtual std::recursive_mutex &GetModuleMutex() const;
128
129 /// Initialize the SymbolFile object.
130 ///
131 /// The SymbolFile object with the best set of abilities (detected
132 /// in "uint32_t SymbolFile::GetAbilities()) will have this function
133 /// called if it is chosen to parse an object file. More complete
134 /// initialization can happen in this function which will get called
135 /// prior to any other functions in the SymbolFile protocol.
136 virtual void InitializeObject() {}
137
138 /// Whether debug info will be loaded or not.
139 ///
140 /// It will be true for most implementations except SymbolFileOnDemand.
141 virtual bool GetLoadDebugInfoEnabled() { return true; }
142
143 /// Specify debug info should be loaded.
144 ///
145 /// It will be no-op for most implementations except SymbolFileOnDemand.
146 virtual void SetLoadDebugInfoEnabled() {}
147
148 // Compile Unit function calls
149 // Approach 1 - iterator
150 virtual uint32_t GetNumCompileUnits() = 0;
151 virtual lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx) = 0;
152
153 virtual Symtab *GetSymtab(bool can_create = true) = 0;
154
156 /// Return the Xcode SDK comp_unit was compiled against.
158 return {};
159 }
160
161 /// This function exists because SymbolFileDWARFDebugMap may extra compile
162 /// units which aren't exposed as "real" compile units. In every other
163 /// case this function should behave identically as ParseLanguage.
164 virtual llvm::SmallSet<lldb::LanguageType, 4>
166 llvm::SmallSet<lldb::LanguageType, 4> langs;
167 langs.insert(ParseLanguage(comp_unit));
168 return langs;
169 }
170
171 virtual size_t ParseFunctions(CompileUnit &comp_unit) = 0;
172 virtual bool ParseLineTable(CompileUnit &comp_unit) = 0;
173 virtual bool ParseDebugMacros(CompileUnit &comp_unit) = 0;
174
175 /// Apply a lambda to each external lldb::Module referenced by this
176 /// \p comp_unit. Recursively also descends into the referenced external
177 /// modules of any encountered compilation unit.
178 ///
179 /// This function can be used to traverse Clang -gmodules debug
180 /// information, which is stored in DWARF files separate from the
181 /// object files.
182 ///
183 /// \param comp_unit
184 /// When this SymbolFile consists of multiple auxilliary
185 /// SymbolFiles, for example, a Darwin debug map that references
186 /// multiple .o files, comp_unit helps choose the auxilliary
187 /// file. In most other cases comp_unit's symbol file is
188 /// identical with *this.
189 ///
190 /// \param[in] lambda
191 /// The lambda that should be applied to every function. The lambda can
192 /// return true if the iteration should be aborted earlier.
193 ///
194 /// \param visited_symbol_files
195 /// A set of SymbolFiles that were already visited to avoid
196 /// visiting one file more than once.
197 ///
198 /// \return
199 /// If the lambda early-exited, this function returns true to
200 /// propagate the early exit.
202 lldb_private::CompileUnit &comp_unit,
203 llvm::DenseSet<lldb_private::SymbolFile *> &visited_symbol_files,
204 llvm::function_ref<bool(Module &)> lambda) {
205 return false;
206 }
207 virtual bool ParseSupportFiles(CompileUnit &comp_unit,
208 SupportFileList &support_files) = 0;
209 virtual size_t ParseTypes(CompileUnit &comp_unit) = 0;
210 virtual bool ParseIsOptimized(CompileUnit &comp_unit) { return false; }
211
212 virtual bool
214 std::vector<SourceModule> &imported_modules) = 0;
215 virtual size_t ParseBlocksRecursive(Function &func) = 0;
216 virtual size_t ParseVariablesForContext(const SymbolContext &sc) = 0;
217 virtual Type *ResolveTypeUID(lldb::user_id_t type_uid) = 0;
218
219 /// The characteristics of an array type.
220 struct ArrayInfo {
221 int64_t first_index = 0;
222
223 /// Each entry belongs to a distinct DW_TAG_subrange_type.
224 /// For multi-dimensional DW_TAG_array_types we would have
225 /// an entry for each dimension. An entry represents the
226 /// optional element count of the subrange.
227 ///
228 /// The order of entries follows the order of the DW_TAG_subrange_type
229 /// children of this DW_TAG_array_type.
230 llvm::SmallVector<std::optional<uint64_t>, 1> element_orders;
231 uint32_t byte_stride = 0;
232 uint32_t bit_stride = 0;
233 };
234 /// If \c type_uid points to an array type, return its characteristics.
235 /// To support variable-length array types, this function takes an
236 /// optional \p ExecutionContext. If \c exe_ctx is non-null, the
237 /// dynamic characteristics for that context are returned.
238 virtual std::optional<ArrayInfo>
240 const lldb_private::ExecutionContext *exe_ctx) = 0;
241
242 virtual bool CompleteType(CompilerType &compiler_type) = 0;
244 virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid) { return {}; }
246 return {};
247 }
251 virtual std::vector<CompilerContext>
253 return {};
254 }
255 virtual uint32_t ResolveSymbolContext(const Address &so_addr,
256 lldb::SymbolContextItem resolve_scope,
257 SymbolContext &sc) = 0;
258
259 /// Get an error that describes why variables might be missing for a given
260 /// symbol context.
261 ///
262 /// If there is an error in the debug information that prevents variables from
263 /// being fetched, this error will get filled in. If there is no debug
264 /// informaiton, no error should be returned. But if there is debug
265 /// information and something prevents the variables from being available a
266 /// valid error should be returned. Valid cases include:
267 /// - compiler option that removes variables (-gline-tables-only)
268 /// - missing external files
269 /// - .dwo files in fission are not accessible or missing
270 /// - .o files on darwin when not using dSYM files that are not accessible
271 /// or missing
272 /// - mismatched exteral files
273 /// - .dwo files in fission where the DWO ID doesn't match
274 /// - .o files on darwin when modification timestamp doesn't match
275 /// - corrupted debug info
276 ///
277 /// \param[in] frame
278 /// The stack frame to use as a basis for the context to check. The frame
279 /// address can be used if there is not debug info due to it not being able
280 /// to be loaded, or if there is a debug info context, like a compile unit,
281 /// or function, it can be used to track down more information on why
282 /// variables are missing.
283 ///
284 /// \returns
285 /// An error specifying why there should have been debug info with variable
286 /// information but the variables were not able to be resolved.
289 if (err.Fail())
291 return err;
292 }
293
294 /// Subclasses will override this function to for GetFrameVariableError().
295 ///
296 /// This allows GetFrameVariableError() to set the member variable
297 /// m_debug_info_had_variable_errors correctly without users having to do it
298 /// manually which is error prone.
300 return Status();
301 }
302 virtual uint32_t
303 ResolveSymbolContext(const SourceLocationSpec &src_location_spec,
304 lldb::SymbolContextItem resolve_scope,
305 SymbolContextList &sc_list);
306
307 virtual void DumpClangAST(Stream &s, llvm::StringRef filter,
308 bool show_colors) {}
309 virtual void FindGlobalVariables(ConstString name,
310 const CompilerDeclContext &parent_decl_ctx,
311 uint32_t max_matches,
312 VariableList &variables);
313 virtual void FindGlobalVariables(const RegularExpression &regex,
314 uint32_t max_matches,
315 VariableList &variables);
316 virtual void FindFunctions(const Module::LookupInfo &lookup_info,
317 const CompilerDeclContext &parent_decl_ctx,
318 bool include_inlines, SymbolContextList &sc_list);
319 virtual void FindFunctions(llvm::ArrayRef<Module::LookupInfo> lookup_infos,
320 const CompilerDeclContext &parent_decl_ctx,
321 bool include_inlines, SymbolContextList &sc_list);
322 virtual void FindFunctions(const RegularExpression &regex,
323 bool include_inlines, SymbolContextList &sc_list);
324
325 /// Find types using a type-matching object that contains all search
326 /// parameters.
327 ///
328 /// \see lldb_private::TypeQuery
329 ///
330 /// \param[in] query
331 /// A type matching object that contains all of the details of the type
332 /// search.
333 ///
334 /// \param[in] results
335 /// Any matching types will be populated into the \a results object using
336 /// TypeMap::InsertUnique(...).
337 virtual void FindTypes(const TypeQuery &query, TypeResults &results) {}
338
339 virtual void
340 GetMangledNamesForFunction(const std::string &scope_qualified_name,
341 std::vector<ConstString> &mangled_names);
342
343 /// Resolves the function corresponding to the specified LLDB function
344 /// call \c label.
345 ///
346 /// \param[in,out] label The FunctionCallLabel to be resolved.
347 ///
348 /// \returns An llvm::Error if the specified \c label couldn't be resolved.
349 /// Returns the resolved function (as a SymbolContext) otherwise.
350 virtual llvm::Expected<SymbolContext>
352 return llvm::createStringError("Not implemented");
353 }
354
356 lldb::TypeClass type_mask,
357 lldb_private::TypeList &type_list) = 0;
358
359 virtual void PreloadSymbols();
360
361 virtual llvm::Expected<lldb::TypeSystemSP>
363
364 /// Finds a namespace of name \ref name and whose parent
365 /// context is \ref parent_decl_ctx.
366 ///
367 /// If \code{.cpp} !parent_decl_ctx.IsValid() \endcode
368 /// then this function will consider all namespaces that
369 /// match the name. If \ref only_root_namespaces is
370 /// true, only consider in the search those DIEs that
371 /// represent top-level namespaces.
372 virtual CompilerDeclContext
373 FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx,
374 bool only_root_namespaces = false) {
375 return CompilerDeclContext();
376 }
377
378 virtual ObjectFile *GetObjectFile() = 0;
379 virtual const ObjectFile *GetObjectFile() const = 0;
381
382 virtual std::vector<std::unique_ptr<CallEdge>>
384 return {};
385 }
386
387 virtual void AddSymbols(Symtab &symtab) {}
388
389 /// Notify the SymbolFile that the file addresses in the Sections
390 /// for this module have been changed.
391 virtual void SectionFileAddressesChanged() = 0;
392
394 virtual ~RegisterInfoResolver(); // anchor
395
396 virtual const RegisterInfo *ResolveName(llvm::StringRef name) const = 0;
398 uint32_t number) const = 0;
399 };
400 virtual lldb::UnwindPlanSP
401 GetUnwindPlan(const Address &address, const RegisterInfoResolver &resolver) {
402 return nullptr;
403 }
404
405 /// Return the number of stack bytes taken up by the parameters to this
406 /// function.
407 virtual llvm::Expected<lldb::addr_t>
409 return llvm::createStringError(make_error_code(llvm::errc::not_supported),
410 "Operation not supported.");
411 }
412
413 virtual void Dump(Stream &s) = 0;
414
415 /// Metrics gathering functions
416
417 /// Return the size in bytes of all loaded debug information or total possible
418 /// debug info in the symbol file.
419 ///
420 /// If the debug information is contained in sections of an ObjectFile, then
421 /// this call should add the size of all sections that contain debug
422 /// information. Symbols the symbol tables are not considered debug
423 /// information for this call to make it easy and quick for this number to be
424 /// calculated. If the symbol file is all debug information, the size of the
425 /// entire file should be returned. The default implementation of this
426 /// function will iterate over all sections in a module and add up their
427 /// debug info only section byte sizes.
428 ///
429 /// \param load_all_debug_info
430 /// If true, force loading any symbol files if they are not yet loaded and
431 /// add to the total size. Default to false.
432 ///
433 /// \returns
434 /// Total currently loaded debug info size in bytes
435 virtual uint64_t GetDebugInfoSize(bool load_all_debug_info = false) = 0;
436
437 /// Return the time taken to parse the debug information.
438 ///
439 /// \returns 0.0 if no information has been parsed or if there is
440 /// no computational cost to parsing the debug information.
442
443 /// Return the time it took to index the debug information in the object
444 /// file.
445 ///
446 /// \returns 0.0 if the file doesn't need to be indexed or if it
447 /// hasn't been indexed yet, or a valid duration if it has.
449
450 /// Reset the statistics for the symbol file.
451 virtual void ResetStatistics() {}
452
453 /// Get the additional modules that this symbol file uses to parse debug info.
454 ///
455 /// Some debug info is stored in stand alone object files that are represented
456 /// by unique modules that will show up in the statistics module list. Return
457 /// a list of modules that are not in the target module list that this symbol
458 /// file is currently using so that they can be tracked and assoicated with
459 /// the module in the statistics.
461
462 /// Accessors for the bool that indicates if the debug info index was loaded
463 /// from, or saved to the module index cache.
464 ///
465 /// In statistics it is handy to know if a module's debug info was loaded from
466 /// or saved to the cache. When the debug info index is loaded from the cache
467 /// startup times can be faster. When the cache is enabled and the debug info
468 /// index is saved to the cache, debug sessions can be slower. These accessors
469 /// can be accessed by the statistics and emitted to help track these costs.
470 /// \{
471 virtual bool GetDebugInfoIndexWasLoadedFromCache() const = 0;
473 virtual bool GetDebugInfoIndexWasSavedToCache() const = 0;
475 /// \}
476
477 /// Accessors for the bool that indicates if there was debug info, but errors
478 /// stopped variables from being able to be displayed correctly. See
479 /// GetFrameVariableError() for details on what are considered errors.
480 virtual bool GetDebugInfoHadFrameVariableErrors() const = 0;
482
483 /// Return true if separate debug info files are supported and this function
484 /// succeeded, false otherwise.
485 ///
486 /// \param[out] d
487 /// If this function succeeded, then this will be a dictionary that
488 /// contains the keys "type", "symfile", and "separate-debug-info-files".
489 /// "type" can be used to assume the structure of each object in
490 /// "separate-debug-info-files".
491 /// \param errors_only
492 /// If true, then only return separate debug info files that encountered
493 /// errors during loading. If false, then return all expected separate
494 /// debug info files, regardless of whether they were successfully loaded.
495 /// \param load_all_debug_info
496 /// If true, force loading any symbol files if they are not yet loaded.
498 bool errors_only,
499 bool load_all_debug_info = false) {
500 return false;
501 };
502
503 /// Retrieves statistics about DWO files associated with this symbol file.
504 /// This function returns a DWOStats struct containing:
505 /// - The number of successfully loaded/parsed DWO files.
506 /// - The total number of DWO files encountered.
507 /// - The number of DWO CUs that failed to load due to errors.
508 /// If this symbol file does not support DWO files, all counts will be zero.
509 ///
510 /// \returns
511 /// A DWOStats struct with loaded, total, and error counts for DWO files.
512 virtual DWOStats GetDwoStats() { return {}; }
513
514 /// Return a map of separate debug info files that are loaded.
515 ///
516 /// Unlike GetSeparateDebugInfo(), this function will only return the list of
517 /// files, if there are errors they are simply ignored. This function will
518 /// always return a valid list, even if it is empty.
519 ///
520 /// \return
521 /// A unique list of all the filespecs, or an empty list.
525
526 virtual lldb::TypeSP
528 std::optional<uint64_t> byte_size, SymbolContextScope *context,
529 lldb::user_id_t encoding_uid,
530 Type::EncodingDataType encoding_uid_type, const Declaration &decl,
531 const CompilerType &compiler_qual_type,
532 Type::ResolveState compiler_type_resolve_state,
533 uint32_t opaque_payload = 0) = 0;
534
535 virtual lldb::TypeSP CopyType(const lldb::TypeSP &other_type) = 0;
536
537 /// Returns a map of compilation unit to the compile option arguments
538 /// associated with that compilation unit.
539 std::unordered_map<lldb::CompUnitSP, Args> GetCompileOptions() {
540 std::unordered_map<lldb::CompUnitSP, Args> args;
541 GetCompileOptions(args);
542 return args;
543 }
544
545 std::string GetObjectName() const;
546
547 /// Get the semantically innermost non-function type that encloses the
548 /// provided variable
550 return {};
551 }
552
553protected:
554 void AssertModuleLock();
555
556 virtual void GetCompileOptions(
557 std::unordered_map<lldb::CompUnitSP, lldb_private::Args> &args) {}
558
559private:
560 SymbolFile(const SymbolFile &) = delete;
561 const SymbolFile &operator=(const SymbolFile &) = delete;
562};
563
564/// Containing protected virtual methods for child classes to override.
565/// Most actual SymbolFile implementations should inherit from this class.
567 /// LLVM RTTI support.
568 static char ID;
569
570public:
571 /// LLVM RTTI support.
572 /// \{
573 bool isA(const void *ClassID) const override {
574 return ClassID == &ID || SymbolFile::isA(ClassID);
575 }
576 static bool classof(const SymbolFileCommon *obj) { return obj->isA(&ID); }
577 /// \}
578
579 // Constructors and Destructors
581 : m_objfile_sp(std::move(objfile_sp)) {}
582
583 ~SymbolFileCommon() override = default;
584
585 uint32_t GetAbilities() override {
589 }
590 return m_abilities;
591 }
592
593 Symtab *GetSymtab(bool can_create = true) override;
594
595 ObjectFile *GetObjectFile() override { return m_objfile_sp.get(); }
596 const ObjectFile *GetObjectFile() const override {
597 return m_objfile_sp.get();
598 }
599 ObjectFile *GetMainObjectFile() override;
600
601 /// Notify the SymbolFile that the file addresses in the Sections
602 /// for this module have been changed.
603 void SectionFileAddressesChanged() override;
604
605 // Compile Unit function calls
606 // Approach 1 - iterator
607 uint32_t GetNumCompileUnits() override;
608 lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx) override;
609
610 llvm::Expected<lldb::TypeSystemSP>
612
613 void Dump(Stream &s) override;
614
615 uint64_t GetDebugInfoSize(bool load_all_debug_info = false) override;
616
623 bool GetDebugInfoIndexWasSavedToCache() const override {
625 }
635
636 /// This function is used to create types that belong to a SymbolFile. The
637 /// symbol file will own a strong reference to the type in an internal type
638 /// list.
640 std::optional<uint64_t> byte_size,
641 SymbolContextScope *context,
642 lldb::user_id_t encoding_uid,
643 Type::EncodingDataType encoding_uid_type,
644 const Declaration &decl,
645 const CompilerType &compiler_qual_type,
646 Type::ResolveState compiler_type_resolve_state,
647 uint32_t opaque_payload = 0) override {
648 lldb::TypeSP type_sp (new Type(
649 uid, this, name, byte_size, context, encoding_uid,
650 encoding_uid_type, decl, compiler_qual_type,
651 compiler_type_resolve_state, opaque_payload));
652 m_type_list.Insert(type_sp);
653 return type_sp;
654 }
655
656 lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override {
657 // Make sure the real symbol file matches when copying types.
658 if (GetBackingSymbolFile() != other_type->GetSymbolFile())
659 return lldb::TypeSP();
660 lldb::TypeSP type_sp(new Type(*other_type));
661 m_type_list.Insert(type_sp);
662 return type_sp;
663 }
664
665protected:
666 virtual uint32_t CalculateNumCompileUnits() = 0;
667 virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t idx) = 0;
668 virtual TypeList &GetTypeList() { return m_type_list; }
669 void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp);
670
671 lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in
672 // case it isn't the same as the module
673 // object file (debug symbols in a separate
674 // file)
675 std::optional<std::vector<lldb::CompUnitSP>> m_compile_units;
677 uint32_t m_abilities = 0;
681 /// Set to true if any variable feteching errors have been found when calling
682 /// GetFrameVariableError(). This will be emitted in the "statistics dump"
683 /// information for a module.
685
686private:
689
690 /// Do not use m_symtab directly, as it may be freed. Use GetSymtab()
691 /// to access it instead.
692 Symtab *m_symtab = nullptr;
693};
694
695} // namespace lldb_private
696
697#endif // LLDB_SYMBOL_SYMBOLFILE_H
A section + offset based address class.
Definition Address.h:62
A class that describes a compilation unit.
Definition CompileUnit.h:43
Represents a generic declaration context in a program.
Represents a generic declaration such as a function declaration.
Generic representation of a type in a programming language.
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 class that describes a function.
Definition Function.h:386
A collection class for Module objects.
Definition ModuleList.h:128
A class that encapsulates name lookup information.
Definition Module.h:935
A class that describes an executable image and its associated object and symbol files.
Definition Module.h:91
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
"lldb/Core/SourceLocationSpec.h" A source location specifier class.
This base class provides an interface to stack frames.
Definition StackFrame.h:44
std::chrono::duration< double > Duration
Definition Statistics.h:37
An error handling class.
Definition Status.h:118
bool Fail() const
Test for error condition.
Definition Status.cpp:293
A stream class that can stream formatted output to a file.
Definition Stream.h:28
A list of support files for a CompileUnit.
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.
const SymbolFileCommon & operator=(const SymbolFileCommon &)=delete
~SymbolFileCommon() override=default
bool GetDebugInfoHadFrameVariableErrors() const override
Accessors for the bool that indicates if there was debug info, but errors stopped variables from bein...
Definition SymbolFile.h:629
void SetDebugInfoIndexWasLoadedFromCache() override
Definition SymbolFile.h:620
bool GetDebugInfoIndexWasSavedToCache() const override
Definition SymbolFile.h:623
lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx) override
ObjectFile * GetObjectFile() override
Definition SymbolFile.h:595
std::optional< std::vector< lldb::CompUnitSP > > m_compile_units
Definition SymbolFile.h:675
virtual TypeList & GetTypeList()
Definition SymbolFile.h:668
lldb::ObjectFileSP m_objfile_sp
Definition SymbolFile.h:671
bool isA(const void *ClassID) const override
LLVM RTTI support.
Definition SymbolFile.h:573
void SetDebugInfoIndexWasSavedToCache() override
Definition SymbolFile.h:626
virtual lldb::CompUnitSP ParseCompileUnitAtIndex(uint32_t idx)=0
ObjectFile * GetMainObjectFile() override
bool m_debug_info_had_variable_errors
Set to true if any variable feteching errors have been found when calling GetFrameVariableError().
Definition SymbolFile.h:684
Symtab * m_symtab
Do not use m_symtab directly, as it may be freed.
Definition SymbolFile.h:692
static char ID
LLVM RTTI support.
Definition SymbolFile.h:568
void SetCompileUnitAtIndex(uint32_t idx, const lldb::CompUnitSP &cu_sp)
SymbolFileCommon(lldb::ObjectFileSP objfile_sp)
Definition SymbolFile.h:580
void SetDebugInfoHadFrameVariableErrors() override
Definition SymbolFile.h:632
static bool classof(const SymbolFileCommon *obj)
Definition SymbolFile.h:576
const ObjectFile * GetObjectFile() const override
Definition SymbolFile.h:596
Symtab * GetSymtab(bool can_create=true) override
uint32_t GetAbilities() override
Get a mask of what this symbol file supports for the object file that it was constructed with.
Definition SymbolFile.h:585
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language) override
bool GetDebugInfoIndexWasLoadedFromCache() const override
Accessors for the bool that indicates if the debug info index was loaded from, or saved to the module...
Definition SymbolFile.h:617
uint32_t GetNumCompileUnits() override
SymbolFileCommon(const SymbolFileCommon &)=delete
lldb::TypeSP CopyType(const lldb::TypeSP &other_type) override
Definition SymbolFile.h:656
void SectionFileAddressesChanged() override
Notify the SymbolFile that the file addresses in the Sections for this module have been changed.
virtual uint32_t CalculateNumCompileUnits()=0
void Dump(Stream &s) override
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
This function is used to create types that belong to a SymbolFile.
Definition SymbolFile.h:639
uint64_t GetDebugInfoSize(bool load_all_debug_info=false) override
Metrics gathering functions.
Provides public interface for all SymbolFiles.
Definition SymbolFile.h:51
virtual lldb::TypeSP CopyType(const lldb::TypeSP &other_type)=0
virtual llvm::SmallSet< lldb::LanguageType, 4 > ParseAllLanguages(CompileUnit &comp_unit)
This function exists because SymbolFileDWARFDebugMap may extra compile units which aren't exposed as ...
Definition SymbolFile.h:165
virtual void ParseDeclsForContext(CompilerDeclContext decl_ctx)
Definition SymbolFile.h:243
virtual uint64_t GetDebugInfoSize(bool load_all_debug_info=false)=0
Metrics gathering functions.
virtual bool GetDebugInfoIndexWasLoadedFromCache() const =0
Accessors for the bool that indicates if the debug info index was loaded from, or saved to the module...
virtual void InitializeObject()
Initialize the SymbolFile object.
Definition SymbolFile.h:136
virtual bool CompleteType(CompilerType &compiler_type)=0
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)=0
virtual bool ParseIsOptimized(CompileUnit &comp_unit)
Definition SymbolFile.h:210
virtual bool isA(const void *ClassID) const
LLVM RTTI support.
Definition SymbolFile.h:58
virtual llvm::Expected< lldb::addr_t > GetParameterStackSize(const Symbol &symbol)
Return the number of stack bytes taken up by the parameters to this function.
Definition SymbolFile.h:408
~SymbolFile() override=default
virtual bool ForEachExternalModule(lldb_private::CompileUnit &comp_unit, llvm::DenseSet< lldb_private::SymbolFile * > &visited_symbol_files, llvm::function_ref< bool(Module &)> lambda)
Apply a lambda to each external lldb::Module referenced by this comp_unit.
Definition SymbolFile.h:201
virtual std::vector< CompilerContext > GetCompilerContextForUID(lldb::user_id_t uid)
Definition SymbolFile.h:252
virtual CompilerDeclContext GetDeclContextForUID(lldb::user_id_t uid)
Definition SymbolFile.h:245
virtual std::vector< std::unique_ptr< CallEdge > > ParseCallEdgesInFunction(UserID func_id)
Definition SymbolFile.h:383
virtual CompilerDeclContext GetDeclContextContainingUID(lldb::user_id_t uid)
Definition SymbolFile.h:248
virtual CompilerDecl GetDeclForUID(lldb::user_id_t uid)
Definition SymbolFile.h:244
virtual const ObjectFile * GetObjectFile() const =0
virtual size_t ParseTypes(CompileUnit &comp_unit)=0
virtual void SectionFileAddressesChanged()=0
Notify the SymbolFile that the file addresses in the Sections for this module have been changed.
virtual void SetLoadDebugInfoEnabled()
Specify debug info should be loaded.
Definition SymbolFile.h:146
virtual DWOStats GetDwoStats()
Retrieves statistics about DWO files associated with this symbol file.
Definition SymbolFile.h:512
virtual void PreloadSymbols()
virtual lldb::UnwindPlanSP GetUnwindPlan(const Address &address, const RegisterInfoResolver &resolver)
Definition SymbolFile.h:401
virtual SymbolFile * GetBackingSymbolFile()
SymbolFileOnDemand class overrides this to return the underlying backing SymbolFile implementation th...
Definition SymbolFile.h:93
virtual void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, uint32_t max_matches, VariableList &variables)
virtual Symtab * GetSymtab(bool can_create=true)=0
virtual bool GetDebugInfoIndexWasSavedToCache() const =0
virtual StatsDuration::Duration GetDebugInfoParseTime()
Return the time taken to parse the debug information.
Definition SymbolFile.h:441
virtual size_t ParseFunctions(CompileUnit &comp_unit)=0
virtual ObjectFile * GetMainObjectFile()=0
virtual size_t ParseBlocksRecursive(Function &func)=0
virtual uint32_t GetNumCompileUnits()=0
virtual bool ParseLineTable(CompileUnit &comp_unit)=0
virtual llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)=0
virtual bool ParseDebugMacros(CompileUnit &comp_unit)=0
static SymbolFile * FindPlugin(lldb::ObjectFileSP objfile_sp)
@ kAllAbilities
All detailed debug-information abilities.
Definition SymbolFile.h:80
virtual std::recursive_mutex & GetModuleMutex() const
Symbols file subclasses should override this to return the Module that owns the TypeSystem that this ...
virtual bool GetLoadDebugInfoEnabled()
Whether debug info will be loaded or not.
Definition SymbolFile.h:141
SymbolFile(const SymbolFile &)=delete
virtual 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)=0
Status GetFrameVariableError(StackFrame &frame)
Get an error that describes why variables might be missing for a given symbol context.
Definition SymbolFile.h:287
virtual bool GetDebugInfoHadFrameVariableErrors() const =0
Accessors for the bool that indicates if there was debug info, but errors stopped variables from bein...
virtual void GetTypes(lldb_private::SymbolContextScope *sc_scope, lldb::TypeClass type_mask, lldb_private::TypeList &type_list)=0
virtual std::optional< ArrayInfo > GetDynamicArrayInfoForUID(lldb::user_id_t type_uid, const lldb_private::ExecutionContext *exe_ctx)=0
If type_uid points to an array type, return its characteristics.
virtual void AddSymbols(Symtab &symtab)
Definition SymbolFile.h:387
virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit)=0
virtual lldb::TypeSP GetTypeEnclosingVariableUID(lldb::user_id_t uid)
Get the semantically innermost non-function type that encloses the provided variable.
Definition SymbolFile.h:549
virtual lldb::CompUnitSP GetCompileUnitAtIndex(uint32_t idx)=0
virtual CompilerDeclContext FindNamespace(ConstString name, const CompilerDeclContext &parent_decl_ctx, bool only_root_namespaces=false)
Finds a namespace of name name and whose parent context is parent_decl_ctx.
Definition SymbolFile.h:373
const SymbolFile & operator=(const SymbolFile &)=delete
virtual llvm::Expected< SymbolContext > ResolveFunctionCallLabel(FunctionCallLabel &label)
Resolves the function corresponding to the specified LLDB function call label.
Definition SymbolFile.h:351
virtual bool ParseImportedModules(const SymbolContext &sc, std::vector< SourceModule > &imported_modules)=0
virtual void SetDebugInfoIndexWasSavedToCache()=0
virtual void FindTypes(const TypeQuery &query, TypeResults &results)
Find types using a type-matching object that contains all search parameters.
Definition SymbolFile.h:337
static char ID
LLVM RTTI support.
Definition SymbolFile.h:53
virtual bool GetSeparateDebugInfo(StructuredData::Dictionary &d, bool errors_only, bool load_all_debug_info=false)
Return true if separate debug info files are supported and this function succeeded,...
Definition SymbolFile.h:497
virtual void FindFunctions(const Module::LookupInfo &lookup_info, const CompilerDeclContext &parent_decl_ctx, bool include_inlines, SymbolContextList &sc_list)
virtual void SetDebugInfoHadFrameVariableErrors()=0
virtual ModuleList GetDebugInfoModules()
Get the additional modules that this symbol file uses to parse debug info.
Definition SymbolFile.h:460
virtual StatsDuration::Duration GetDebugInfoIndexTime()
Return the time it took to index the debug information in the object file.
Definition SymbolFile.h:448
virtual size_t ParseVariablesForContext(const SymbolContext &sc)=0
virtual uint32_t GetAbilities()=0
Get a mask of what this symbol file supports for the object file that it was constructed with.
static bool classof(const SymbolFile *obj)
Definition SymbolFile.h:59
virtual uint32_t CalculateAbilities()=0
virtual void GetCompileOptions(std::unordered_map< lldb::CompUnitSP, lldb_private::Args > &args)
Definition SymbolFile.h:556
std::unordered_map< lldb::CompUnitSP, Args > GetCompileOptions()
Returns a map of compilation unit to the compile option arguments associated with that compilation un...
Definition SymbolFile.h:539
virtual Status CalculateFrameVariableError(StackFrame &frame)
Subclasses will override this function to for GetFrameVariableError().
Definition SymbolFile.h:299
virtual lldb_private::ModuleSpecList GetSeparateDebugInfoFiles()
Return a map of separate debug info files that are loaded.
Definition SymbolFile.h:522
virtual XcodeSDKAndSysroot ParseXcodeSDK(CompileUnit &comp_unit)
Return the Xcode SDK comp_unit was compiled against.
Definition SymbolFile.h:157
virtual void DumpClangAST(Stream &s, llvm::StringRef filter, bool show_colors)
Definition SymbolFile.h:307
virtual ObjectFile * GetObjectFile()=0
virtual void ResetStatistics()
Reset the statistics for the symbol file.
Definition SymbolFile.h:451
virtual uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc)=0
virtual void GetMangledNamesForFunction(const std::string &scope_qualified_name, std::vector< ConstString > &mangled_names)
virtual void Dump(Stream &s)=0
std::string GetObjectName() const
virtual void SetDebugInfoIndexWasLoadedFromCache()=0
virtual bool ParseSupportFiles(CompileUnit &comp_unit, SupportFileList &support_files)=0
A class that contains all state required for type lookups.
Definition Type.h:104
This class tracks the state and results of a TypeQuery.
Definition Type.h:344
An abstraction which groups an XcodeSDK with the sysroot it was used from.
Definition XcodeSDK.h:101
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
LanguageType
Programming language type.
std::shared_ptr< lldb_private::Type > TypeSP
std::shared_ptr< lldb_private::UnwindPlan > UnwindPlanSP
uint64_t user_id_t
Definition lldb-types.h:83
std::shared_ptr< lldb_private::CompileUnit > CompUnitSP
RegisterKind
Register numbering types.
Holds statistics about DWO (Debug With Object) files.
Definition Statistics.h:124
Holds parsed information about a function call label that LLDB attaches as an AsmLabel to function AS...
Definition Expression.h:110
Every register is described in detail including its name, alternate name (optional),...
The characteristics of an array type.
Definition SymbolFile.h:220
llvm::SmallVector< std::optional< uint64_t >, 1 > element_orders
Each entry belongs to a distinct DW_TAG_subrange_type.
Definition SymbolFile.h:230
virtual const RegisterInfo * ResolveNumber(lldb::RegisterKind kind, uint32_t number) const =0
virtual const RegisterInfo * ResolveName(llvm::StringRef name) const =0
A mix in class that contains a generic user ID.
Definition UserID.h:31