LLDB  mainline
SymbolVendor.h
Go to the documentation of this file.
1 //===-- SymbolVendor.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 liblldb_SymbolVendor_h_
10 #define liblldb_SymbolVendor_h_
11 
12 #include <vector>
13 
14 #include "lldb/Core/ModuleChild.h"
17 #include "lldb/Symbol/TypeList.h"
18 #include "lldb/Symbol/TypeMap.h"
19 #include "lldb/lldb-private.h"
20 #include "llvm/ADT/DenseSet.h"
21 
22 namespace lldb_private {
23 
24 // The symbol vendor class is designed to abstract the process of searching for
25 // debug information for a given module. Platforms can subclass this class and
26 // provide extra ways to find debug information. Examples would be a subclass
27 // that would allow for locating a stand alone debug file, parsing debug maps,
28 // or runtime data in the object files. A symbol vendor can use multiple
29 // sources (SymbolFile objects) to provide the information and only parse as
30 // deep as needed in order to provide the information that is requested.
31 class SymbolVendor : public ModuleChild, public PluginInterface {
32 public:
33  static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp,
34  Stream *feedback_strm);
35 
36  // Constructors and Destructors
37  SymbolVendor(const lldb::ModuleSP &module_sp);
38 
39  ~SymbolVendor() override;
40 
41  void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
42 
43  virtual void Dump(Stream *s);
44 
45  virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit);
46 
47  virtual size_t ParseFunctions(CompileUnit &comp_unit);
48 
49  virtual bool ParseLineTable(CompileUnit &comp_unit);
50 
51  virtual bool ParseDebugMacros(CompileUnit &comp_unit);
52 
53  virtual bool ParseSupportFiles(CompileUnit &comp_unit,
54  FileSpecList &support_files);
55 
56  virtual bool ParseIsOptimized(CompileUnit &comp_unit);
57 
58  virtual size_t ParseTypes(CompileUnit &comp_unit);
59 
60  virtual bool
62  std::vector<SourceModule> &imported_modules);
63 
64  virtual size_t ParseBlocksRecursive(Function &func);
65 
66  virtual size_t ParseVariablesForContext(const SymbolContext &sc);
67 
68  virtual Type *ResolveTypeUID(lldb::user_id_t type_uid);
69 
70  virtual uint32_t ResolveSymbolContext(const Address &so_addr,
71  lldb::SymbolContextItem resolve_scope,
72  SymbolContext &sc);
73 
74  virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec,
75  uint32_t line, bool check_inlines,
76  lldb::SymbolContextItem resolve_scope,
77  SymbolContextList &sc_list);
78 
79  virtual size_t FindGlobalVariables(ConstString name,
80  const CompilerDeclContext *parent_decl_ctx,
81  size_t max_matches,
82  VariableList &variables);
83 
84  virtual size_t FindGlobalVariables(const RegularExpression &regex,
85  size_t max_matches,
86  VariableList &variables);
87 
88  virtual size_t FindFunctions(ConstString name,
89  const CompilerDeclContext *parent_decl_ctx,
90  lldb::FunctionNameType name_type_mask,
91  bool include_inlines, bool append,
92  SymbolContextList &sc_list);
93 
94  virtual size_t FindFunctions(const RegularExpression &regex,
95  bool include_inlines, bool append,
96  SymbolContextList &sc_list);
97 
98  virtual size_t
99  FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx,
100  bool append, size_t max_matches,
101  llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
102  TypeMap &types);
103 
104  virtual size_t FindTypes(const std::vector<CompilerContext> &context,
105  bool append, TypeMap &types);
106 
107  virtual CompilerDeclContext
109  const CompilerDeclContext *parent_decl_ctx);
110 
111  virtual size_t GetNumCompileUnits();
112 
113  virtual bool SetCompileUnitAtIndex(size_t cu_idx,
114  const lldb::CompUnitSP &cu_sp);
115 
116  virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
117 
119 
120  const TypeList &GetTypeList() const { return m_type_list; }
121 
122  virtual size_t GetTypes(SymbolContextScope *sc_scope,
123  lldb::TypeClass type_mask, TypeList &type_list);
124 
126 
127  FileSpec GetMainFileSpec() const;
128 
129  // Get module unified section list symbol table.
130  virtual Symtab *GetSymtab();
131 
132  // Clear module unified section list symbol table.
133  virtual void ClearSymtab();
134 
135  /// Notify the SymbolVendor that the file addresses in the Sections
136  /// for this module have been changed.
137  virtual void SectionFileAddressesChanged();
138 
139  // PluginInterface protocol
140  ConstString GetPluginName() override;
141 
142  uint32_t GetPluginVersion() override;
143 
144 protected:
145  // Classes that inherit from SymbolVendor can see and modify these
146  typedef std::vector<lldb::CompUnitSP> CompileUnits;
147  typedef CompileUnits::iterator CompileUnitIter;
148  typedef CompileUnits::const_iterator CompileUnitConstIter;
149 
150  TypeList m_type_list; // Uniqued types for all parsers owned by this module
151  CompileUnits m_compile_units; // The current compile units
152  lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in
153  // case it isn't the same as the module
154  // object file (debug symbols in a separate
155  // file)
156  std::unique_ptr<SymbolFile> m_sym_file_up; // A single symbol file. Subclasses
157  // can add more of these if needed.
158  Symtab *m_symtab; // Save a symtab once to not pass it through `AddSymbols` of
159  // the symbol file each time when it is needed
160 
161 private:
162  // For SymbolVendor only
163  DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
164 };
165 
166 } // namespace lldb_private
167 
168 #endif // liblldb_SymbolVendor_h_
Defines a list of symbol context objects.
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
lldb::ObjectFileSP m_objfile_sp
Definition: SymbolVendor.h:152
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
FileSpec GetMainFileSpec() const
Defines a symbol context baton that can be handed other debug core functions.
Definition: SymbolContext.h:33
virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx)
SymbolFile * GetSymbolFile()
Definition: SymbolVendor.h:125
A file utility class.
Definition: FileSpec.h:55
"lldb/Utility/RegularExpression.h" A C++ wrapper class for regex.
A class that describes a function.
Definition: Function.h:323
virtual void Dump(Stream *s)
CompileUnits::iterator CompileUnitIter
Definition: SymbolVendor.h:147
virtual size_t FindGlobalVariables(ConstString name, const CompilerDeclContext *parent_decl_ctx, size_t max_matches, VariableList &variables)
virtual bool ParseLineTable(CompileUnit &comp_unit)
virtual size_t ParseTypes(CompileUnit &comp_unit)
virtual bool SetCompileUnitAtIndex(size_t cu_idx, const lldb::CompUnitSP &cu_sp)
CompileUnits::const_iterator CompileUnitConstIter
Definition: SymbolVendor.h:148
A class that describes a compilation unit.
Definition: CompileUnit.h:35
virtual bool ParseSupportFiles(CompileUnit &comp_unit, FileSpecList &support_files)
virtual size_t ParseVariablesForContext(const SymbolContext &sc)
virtual CompilerDeclContext FindNamespace(ConstString name, const CompilerDeclContext *parent_decl_ctx)
void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp)
virtual uint32_t ResolveSymbolContext(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc)
uint64_t user_id_t
Definition: lldb-types.h:84
LanguageType
Programming language type.
virtual lldb::LanguageType ParseLanguage(CompileUnit &comp_unit)
virtual size_t GetNumCompileUnits()
virtual bool ParseDebugMacros(CompileUnit &comp_unit)
virtual bool ParseImportedModules(const SymbolContext &sc, std::vector< SourceModule > &imported_modules)
const TypeList & GetTypeList() const
Definition: SymbolVendor.h:120
virtual size_t FindFunctions(ConstString name, const CompilerDeclContext *parent_decl_ctx, lldb::FunctionNameType name_type_mask, bool include_inlines, bool append, SymbolContextList &sc_list)
virtual size_t ParseFunctions(CompileUnit &comp_unit)
A section + offset based address class.
Definition: Address.h:80
virtual bool ParseIsOptimized(CompileUnit &comp_unit)
virtual Type * ResolveTypeUID(lldb::user_id_t type_uid)
virtual void SectionFileAddressesChanged()
Notify the SymbolVendor that the file addresses in the Sections for this module have been changed...
virtual size_t FindTypes(ConstString name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, llvm::DenseSet< lldb_private::SymbolFile *> &searched_symbol_files, TypeMap &types)
SymbolVendor(const lldb::ModuleSP &module_sp)
A uniqued constant string class.
Definition: ConstString.h:38
virtual size_t GetTypes(SymbolContextScope *sc_scope, lldb::TypeClass type_mask, TypeList &type_list)
virtual size_t ParseBlocksRecursive(Function &func)
std::vector< lldb::CompUnitSP > CompileUnits
Definition: SymbolVendor.h:146
A mix in class that contains a pointer back to the module that owns the object which inherits from it...
Definition: ModuleChild.h:19
ConstString GetPluginName() override
uint32_t GetPluginVersion() override
static SymbolVendor * FindPlugin(const lldb::ModuleSP &module_sp, Stream *feedback_strm)
std::unique_ptr< SymbolFile > m_sym_file_up
Definition: SymbolVendor.h:156
"lldb/Symbol/SymbolContextScope.h" Inherit from this if your object is part of a symbol context and c...
virtual Symtab * GetSymtab()