SymbolVendor.h revision 341825
1254721Semaste//===-- SymbolVendor.h ------------------------------------------*- C++ -*-===//
2254721Semaste//
3254721Semaste//                     The LLVM Compiler Infrastructure
4254721Semaste//
5254721Semaste// This file is distributed under the University of Illinois Open Source
6254721Semaste// License. See LICENSE.TXT for details.
7254721Semaste//
8254721Semaste//===----------------------------------------------------------------------===//
9254721Semaste
10254721Semaste#ifndef liblldb_SymbolVendor_h_
11254721Semaste#define liblldb_SymbolVendor_h_
12254721Semaste
13254721Semaste#include <vector>
14254721Semaste
15254721Semaste#include "lldb/Core/ModuleChild.h"
16254721Semaste#include "lldb/Core/PluginInterface.h"
17254721Semaste#include "lldb/Symbol/TypeList.h"
18296417Sdim#include "lldb/Symbol/TypeMap.h"
19314564Sdim#include "lldb/lldb-private.h"
20309124Sdim#include "llvm/ADT/DenseSet.h"
21254721Semaste
22254721Semastenamespace lldb_private {
23254721Semaste
24254721Semaste//----------------------------------------------------------------------
25341825Sdim// The symbol vendor class is designed to abstract the process of searching for
26341825Sdim// debug information for a given module. Platforms can subclass this class and
27341825Sdim// provide extra ways to find debug information. Examples would be a subclass
28341825Sdim// that would allow for locating a stand alone debug file, parsing debug maps,
29341825Sdim// or runtime data in the object files. A symbol vendor can use multiple
30341825Sdim// sources (SymbolFile objects) to provide the information and only parse as
31341825Sdim// deep as needed in order to provide the information that is requested.
32254721Semaste//----------------------------------------------------------------------
33314564Sdimclass SymbolVendor : public ModuleChild, public PluginInterface {
34254721Semastepublic:
35314564Sdim  static SymbolVendor *FindPlugin(const lldb::ModuleSP &module_sp,
36314564Sdim                                  Stream *feedback_strm);
37254721Semaste
38314564Sdim  //------------------------------------------------------------------
39314564Sdim  // Constructors and Destructors
40314564Sdim  //------------------------------------------------------------------
41314564Sdim  SymbolVendor(const lldb::ModuleSP &module_sp);
42254721Semaste
43314564Sdim  ~SymbolVendor() override;
44254721Semaste
45314564Sdim  void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
46254721Semaste
47314564Sdim  virtual void Dump(Stream *s);
48254721Semaste
49314564Sdim  virtual lldb::LanguageType ParseCompileUnitLanguage(const SymbolContext &sc);
50254721Semaste
51314564Sdim  virtual size_t ParseCompileUnitFunctions(const SymbolContext &sc);
52254721Semaste
53314564Sdim  virtual bool ParseCompileUnitLineTable(const SymbolContext &sc);
54296417Sdim
55314564Sdim  virtual bool ParseCompileUnitDebugMacros(const SymbolContext &sc);
56309124Sdim
57314564Sdim  virtual bool ParseCompileUnitSupportFiles(const SymbolContext &sc,
58314564Sdim                                            FileSpecList &support_files);
59309124Sdim
60314564Sdim  virtual bool ParseCompileUnitIsOptimized(const SymbolContext &sc);
61254721Semaste
62314564Sdim  virtual bool ParseImportedModules(const SymbolContext &sc,
63314564Sdim                                    std::vector<ConstString> &imported_modules);
64254721Semaste
65314564Sdim  virtual size_t ParseFunctionBlocks(const SymbolContext &sc);
66254721Semaste
67314564Sdim  virtual size_t ParseTypes(const SymbolContext &sc);
68254721Semaste
69314564Sdim  virtual size_t ParseVariablesForContext(const SymbolContext &sc);
70254721Semaste
71314564Sdim  virtual Type *ResolveTypeUID(lldb::user_id_t type_uid);
72254721Semaste
73314564Sdim  virtual uint32_t ResolveSymbolContext(const Address &so_addr,
74314564Sdim                                        uint32_t resolve_scope,
75314564Sdim                                        SymbolContext &sc);
76254721Semaste
77314564Sdim  virtual uint32_t ResolveSymbolContext(const FileSpec &file_spec,
78314564Sdim                                        uint32_t line, bool check_inlines,
79314564Sdim                                        uint32_t resolve_scope,
80314564Sdim                                        SymbolContextList &sc_list);
81254721Semaste
82314564Sdim  virtual size_t FindGlobalVariables(const ConstString &name,
83314564Sdim                                     const CompilerDeclContext *parent_decl_ctx,
84341825Sdim                                     size_t max_matches,
85314564Sdim                                     VariableList &variables);
86254721Semaste
87314564Sdim  virtual size_t FindGlobalVariables(const RegularExpression &regex,
88341825Sdim                                     size_t max_matches,
89314564Sdim                                     VariableList &variables);
90254721Semaste
91314564Sdim  virtual size_t FindFunctions(const ConstString &name,
92314564Sdim                               const CompilerDeclContext *parent_decl_ctx,
93314564Sdim                               uint32_t name_type_mask, bool include_inlines,
94314564Sdim                               bool append, SymbolContextList &sc_list);
95254721Semaste
96314564Sdim  virtual size_t FindFunctions(const RegularExpression &regex,
97314564Sdim                               bool include_inlines, bool append,
98314564Sdim                               SymbolContextList &sc_list);
99254721Semaste
100314564Sdim  virtual size_t
101314564Sdim  FindTypes(const SymbolContext &sc, const ConstString &name,
102314564Sdim            const CompilerDeclContext *parent_decl_ctx, bool append,
103314564Sdim            size_t max_matches,
104314564Sdim            llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
105314564Sdim            TypeMap &types);
106296417Sdim
107314564Sdim  virtual size_t FindTypes(const std::vector<CompilerContext> &context,
108314564Sdim                           bool append, TypeMap &types);
109254721Semaste
110314564Sdim  virtual CompilerDeclContext
111314564Sdim  FindNamespace(const SymbolContext &sc, const ConstString &name,
112314564Sdim                const CompilerDeclContext *parent_decl_ctx);
113254721Semaste
114314564Sdim  virtual size_t GetNumCompileUnits();
115254721Semaste
116314564Sdim  virtual bool SetCompileUnitAtIndex(size_t cu_idx,
117314564Sdim                                     const lldb::CompUnitSP &cu_sp);
118254721Semaste
119314564Sdim  virtual lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
120254721Semaste
121314564Sdim  TypeList &GetTypeList() { return m_type_list; }
122254721Semaste
123314564Sdim  const TypeList &GetTypeList() const { return m_type_list; }
124254721Semaste
125314564Sdim  virtual size_t GetTypes(SymbolContextScope *sc_scope, uint32_t type_mask,
126314564Sdim                          TypeList &type_list);
127288943Sdim
128314564Sdim  SymbolFile *GetSymbolFile() { return m_sym_file_ap.get(); }
129254721Semaste
130314564Sdim  FileSpec GetMainFileSpec() const;
131254721Semaste
132314564Sdim  // Get module unified section list symbol table.
133314564Sdim  virtual Symtab *GetSymtab();
134276479Sdim
135314564Sdim  // Clear module unified section list symbol table.
136314564Sdim  virtual void ClearSymtab();
137254721Semaste
138314564Sdim  //------------------------------------------------------------------
139314564Sdim  /// Notify the SymbolVendor that the file addresses in the Sections
140314564Sdim  /// for this module have been changed.
141314564Sdim  //------------------------------------------------------------------
142314564Sdim  virtual void SectionFileAddressesChanged();
143254721Semaste
144314564Sdim  //------------------------------------------------------------------
145314564Sdim  // PluginInterface protocol
146314564Sdim  //------------------------------------------------------------------
147314564Sdim  ConstString GetPluginName() override;
148314564Sdim
149314564Sdim  uint32_t GetPluginVersion() override;
150314564Sdim
151254721Semasteprotected:
152314564Sdim  //------------------------------------------------------------------
153314564Sdim  // Classes that inherit from SymbolVendor can see and modify these
154314564Sdim  //------------------------------------------------------------------
155314564Sdim  typedef std::vector<lldb::CompUnitSP> CompileUnits;
156314564Sdim  typedef CompileUnits::iterator CompileUnitIter;
157314564Sdim  typedef CompileUnits::const_iterator CompileUnitConstIter;
158254721Semaste
159314564Sdim  TypeList m_type_list; // Uniqued types for all parsers owned by this module
160314564Sdim  CompileUnits m_compile_units;    // The current compile units
161314564Sdim  lldb::ObjectFileSP m_objfile_sp; // Keep a reference to the object file in
162314564Sdim                                   // case it isn't the same as the module
163314564Sdim                                   // object file (debug symbols in a separate
164314564Sdim                                   // file)
165314564Sdim  std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses
166314564Sdim                                             // can add more of these if needed.
167254721Semaste
168254721Semasteprivate:
169314564Sdim  //------------------------------------------------------------------
170314564Sdim  // For SymbolVendor only
171314564Sdim  //------------------------------------------------------------------
172314564Sdim  DISALLOW_COPY_AND_ASSIGN(SymbolVendor);
173254721Semaste};
174254721Semaste
175254721Semaste} // namespace lldb_private
176254721Semaste
177296417Sdim#endif // liblldb_SymbolVendor_h_
178