Home | History | Annotate | Download | only in Symbol
      1 //===-- SymbolVendor.h ------------------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef liblldb_SymbolVendor_h_
     11 #define liblldb_SymbolVendor_h_
     12 
     13 #include <vector>
     14 
     15 #include "lldb/lldb-private.h"
     16 #include "lldb/Core/ModuleChild.h"
     17 #include "lldb/Core/PluginInterface.h"
     18 #include "lldb/Symbol/ClangNamespaceDecl.h"
     19 #include "lldb/Symbol/TypeList.h"
     20 
     21 
     22 namespace lldb_private {
     23 
     24 //----------------------------------------------------------------------
     25 // The symbol vendor class is designed to abstract the process of
     26 // searching for debug information for a given module. Platforms can
     27 // subclass this class and provide extra ways to find debug information.
     28 // Examples would be a subclass that would allow for locating a stand
     29 // alone debug file, parsing debug maps, or runtime data in the object
     30 // files. A symbol vendor can use multiple sources (SymbolFile
     31 // objects) to provide the information and only parse as deep as needed
     32 // in order to provide the information that is requested.
     33 //----------------------------------------------------------------------
     34 class SymbolVendor :
     35     public ModuleChild,
     36     public PluginInterface
     37 {
     38 public:
     39     static SymbolVendor*
     40     FindPlugin (const lldb::ModuleSP &module_sp,
     41                 Stream *feedback_strm);
     42 
     43     //------------------------------------------------------------------
     44     // Constructors and Destructors
     45     //------------------------------------------------------------------
     46     SymbolVendor(const lldb::ModuleSP &module_sp);
     47 
     48     virtual
     49     ~SymbolVendor();
     50 
     51     void
     52     AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp);
     53 
     54     virtual void
     55     Dump(Stream *s);
     56 
     57     virtual lldb::LanguageType
     58     ParseCompileUnitLanguage (const SymbolContext& sc);
     59 
     60     virtual size_t
     61     ParseCompileUnitFunctions (const SymbolContext& sc);
     62 
     63     virtual bool
     64     ParseCompileUnitLineTable (const SymbolContext& sc);
     65 
     66     virtual bool
     67     ParseCompileUnitSupportFiles (const SymbolContext& sc,
     68                                   FileSpecList& support_files);
     69 
     70     virtual size_t
     71     ParseFunctionBlocks (const SymbolContext& sc);
     72 
     73     virtual size_t
     74     ParseTypes (const SymbolContext& sc);
     75 
     76     virtual size_t
     77     ParseVariablesForContext (const SymbolContext& sc);
     78 
     79     virtual Type*
     80     ResolveTypeUID(lldb::user_id_t type_uid);
     81 
     82     virtual uint32_t
     83     ResolveSymbolContext (const Address& so_addr,
     84                           uint32_t resolve_scope,
     85                           SymbolContext& sc);
     86 
     87     virtual uint32_t
     88     ResolveSymbolContext (const FileSpec& file_spec,
     89                           uint32_t line,
     90                           bool check_inlines,
     91                           uint32_t resolve_scope,
     92                           SymbolContextList& sc_list);
     93 
     94     virtual size_t
     95     FindGlobalVariables (const ConstString &name,
     96                          const ClangNamespaceDecl *namespace_decl,
     97                          bool append,
     98                          size_t max_matches,
     99                          VariableList& variables);
    100 
    101     virtual size_t
    102     FindGlobalVariables (const RegularExpression& regex,
    103                          bool append,
    104                          size_t max_matches,
    105                          VariableList& variables);
    106 
    107     virtual size_t
    108     FindFunctions (const ConstString &name,
    109                    const ClangNamespaceDecl *namespace_decl,
    110                    uint32_t name_type_mask,
    111                    bool include_inlines,
    112                    bool append,
    113                    SymbolContextList& sc_list);
    114 
    115     virtual size_t
    116     FindFunctions (const RegularExpression& regex,
    117                    bool include_inlines,
    118                    bool append,
    119                    SymbolContextList& sc_list);
    120 
    121     virtual size_t
    122     FindTypes (const SymbolContext& sc,
    123                const ConstString &name,
    124                const ClangNamespaceDecl *namespace_decl,
    125                bool append,
    126                size_t max_matches,
    127                TypeList& types);
    128 
    129     virtual ClangNamespaceDecl
    130     FindNamespace (const SymbolContext& sc,
    131                    const ConstString &name,
    132                    const ClangNamespaceDecl *parent_namespace_decl);
    133 
    134     virtual size_t
    135     GetNumCompileUnits();
    136 
    137     virtual bool
    138     SetCompileUnitAtIndex (size_t cu_idx,
    139                            const lldb::CompUnitSP &cu_sp);
    140 
    141     virtual lldb::CompUnitSP
    142     GetCompileUnitAtIndex(size_t idx);
    143 
    144     TypeList&
    145     GetTypeList()
    146     {
    147         return m_type_list;
    148     }
    149 
    150     const TypeList&
    151     GetTypeList() const
    152     {
    153         return m_type_list;
    154     }
    155 
    156     virtual size_t
    157     GetTypes (SymbolContextScope *sc_scope,
    158               uint32_t type_mask,
    159               TypeList &type_list);
    160 
    161     SymbolFile *
    162     GetSymbolFile()
    163     {
    164         return m_sym_file_ap.get();
    165     }
    166 
    167     // Get module unified section list symbol table.
    168     virtual Symtab *
    169     GetSymtab ();
    170 
    171     // Clear module unified section list symbol table.
    172     virtual void
    173     ClearSymtab ();
    174 
    175     //------------------------------------------------------------------
    176     // PluginInterface protocol
    177     //------------------------------------------------------------------
    178     virtual ConstString
    179     GetPluginName();
    180 
    181     virtual uint32_t
    182     GetPluginVersion();
    183 
    184 protected:
    185     //------------------------------------------------------------------
    186     // Classes that inherit from SymbolVendor can see and modify these
    187     //------------------------------------------------------------------
    188     typedef std::vector<lldb::CompUnitSP> CompileUnits;
    189     typedef CompileUnits::iterator CompileUnitIter;
    190     typedef CompileUnits::const_iterator CompileUnitConstIter;
    191 
    192     TypeList m_type_list; // Uniqued types for all parsers owned by this module
    193     CompileUnits m_compile_units; // The current compile units
    194     lldb::ObjectFileSP m_objfile_sp;    // Keep a reference to the object file in case it isn't the same as the module object file (debug symbols in a separate file)
    195     std::unique_ptr<SymbolFile> m_sym_file_ap; // A single symbol file. Subclasses can add more of these if needed.
    196 
    197 private:
    198     //------------------------------------------------------------------
    199     // For SymbolVendor only
    200     //------------------------------------------------------------------
    201     DISALLOW_COPY_AND_ASSIGN (SymbolVendor);
    202 };
    203 
    204 
    205 } // namespace lldb_private
    206 
    207 #endif  // liblldb_SymbolVendor_h_
    208