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