Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SymbolFileDWARFDebugMap.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_SymbolFileDWARFDebugMap_h_ |
| 11 | #define liblldb_SymbolFileDWARFDebugMap_h_ |
| 12 | |
| 13 | |
| 14 | #include <vector> |
| 15 | #include <bitset> |
| 16 | #include "lldb/Symbol/SymbolFile.h" |
| 17 | |
Greg Clayton | e576ab2 | 2011-02-15 00:19:15 +0000 | [diff] [blame^] | 18 | #include "UniqueDWARFASTType.h" |
| 19 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | class SymbolFileDWARF; |
Greg Clayton | 2ccf8cf | 2010-11-07 21:02:03 +0000 | [diff] [blame] | 21 | class DWARFCompileUnit; |
| 22 | class DWARFDebugInfoEntry; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | |
| 24 | class SymbolFileDWARFDebugMap : public lldb_private::SymbolFile |
| 25 | { |
| 26 | public: |
| 27 | //------------------------------------------------------------------ |
| 28 | // Static Functions |
| 29 | //------------------------------------------------------------------ |
| 30 | static void |
| 31 | Initialize(); |
| 32 | |
| 33 | static void |
| 34 | Terminate(); |
| 35 | |
| 36 | static const char * |
| 37 | GetPluginNameStatic(); |
| 38 | |
| 39 | static const char * |
| 40 | GetPluginDescriptionStatic(); |
| 41 | |
| 42 | static lldb_private::SymbolFile * |
| 43 | CreateInstance (lldb_private::ObjectFile* obj_file); |
| 44 | |
| 45 | //------------------------------------------------------------------ |
| 46 | // Constructors and Destructors |
| 47 | //------------------------------------------------------------------ |
| 48 | SymbolFileDWARFDebugMap (lldb_private::ObjectFile* ofile); |
| 49 | virtual ~ SymbolFileDWARFDebugMap (); |
| 50 | |
| 51 | virtual uint32_t GetAbilities (); |
| 52 | |
Greg Clayton | 6beaaa6 | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 53 | virtual void InitializeObject(); |
| 54 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 55 | //------------------------------------------------------------------ |
| 56 | // Compile Unit function calls |
| 57 | //------------------------------------------------------------------ |
| 58 | virtual uint32_t GetNumCompileUnits (); |
| 59 | virtual lldb::CompUnitSP ParseCompileUnitAtIndex (uint32_t index); |
| 60 | |
| 61 | virtual size_t ParseCompileUnitFunctions (const lldb_private::SymbolContext& sc); |
| 62 | virtual bool ParseCompileUnitLineTable (const lldb_private::SymbolContext& sc); |
| 63 | virtual bool ParseCompileUnitSupportFiles (const lldb_private::SymbolContext& sc, lldb_private::FileSpecList &support_files); |
| 64 | virtual size_t ParseFunctionBlocks (const lldb_private::SymbolContext& sc); |
| 65 | virtual size_t ParseTypes (const lldb_private::SymbolContext& sc); |
| 66 | virtual size_t ParseVariablesForContext (const lldb_private::SymbolContext& sc); |
| 67 | |
Greg Clayton | 1be10fc | 2010-09-29 01:12:09 +0000 | [diff] [blame] | 68 | virtual lldb_private::Type* ResolveTypeUID (lldb::user_id_t type_uid); |
| 69 | virtual lldb::clang_type_t ResolveClangOpaqueTypeDefinition (lldb::clang_type_t clang_Type); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 70 | virtual uint32_t ResolveSymbolContext (const lldb_private::Address& so_addr, uint32_t resolve_scope, lldb_private::SymbolContext& sc); |
| 71 | virtual uint32_t ResolveSymbolContext (const lldb_private::FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, lldb_private::SymbolContextList& sc_list); |
| 72 | virtual uint32_t FindGlobalVariables (const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::VariableList& variables); |
| 73 | virtual uint32_t FindGlobalVariables (const lldb_private::RegularExpression& regex, bool append, uint32_t max_matches, lldb_private::VariableList& variables); |
Greg Clayton | 0c5cd90 | 2010-06-28 21:30:43 +0000 | [diff] [blame] | 74 | virtual uint32_t FindFunctions (const lldb_private::ConstString &name, uint32_t name_type_mask, bool append, lldb_private::SymbolContextList& sc_list); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 75 | virtual uint32_t FindFunctions (const lldb_private::RegularExpression& regex, bool append, lldb_private::SymbolContextList& sc_list); |
Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 76 | virtual uint32_t FindTypes (const lldb_private::SymbolContext& sc, const lldb_private::ConstString &name, bool append, uint32_t max_matches, lldb_private::TypeList& types); |
Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 77 | virtual lldb_private::ClangNamespaceDecl |
Greg Clayton | 96d7d74 | 2010-11-10 23:42:09 +0000 | [diff] [blame] | 78 | FindNamespace (const lldb_private::SymbolContext& sc, |
| 79 | const lldb_private::ConstString &name); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 80 | |
Greg Clayton | 6beaaa6 | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 81 | |
| 82 | //------------------------------------------------------------------ |
| 83 | // ClangASTContext callbacks for external source lookups. |
| 84 | //------------------------------------------------------------------ |
| 85 | static void |
| 86 | CompleteTagDecl (void *baton, clang::TagDecl *); |
| 87 | |
| 88 | static void |
| 89 | CompleteObjCInterfaceDecl (void *baton, clang::ObjCInterfaceDecl *); |
| 90 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 91 | //------------------------------------------------------------------ |
| 92 | // PluginInterface protocol |
| 93 | //------------------------------------------------------------------ |
| 94 | virtual const char * |
| 95 | GetPluginName(); |
| 96 | |
| 97 | virtual const char * |
| 98 | GetShortPluginName(); |
| 99 | |
| 100 | virtual uint32_t |
| 101 | GetPluginVersion(); |
| 102 | |
| 103 | virtual void |
| 104 | GetPluginCommandHelp (const char *command, lldb_private::Stream *strm); |
| 105 | |
| 106 | virtual lldb_private::Error |
| 107 | ExecutePluginCommand (lldb_private::Args &command, lldb_private::Stream *strm); |
| 108 | |
| 109 | virtual lldb_private::Log * |
| 110 | EnablePluginLogging (lldb_private::Stream *strm, lldb_private::Args &command); |
| 111 | |
| 112 | protected: |
| 113 | enum |
| 114 | { |
| 115 | kHaveInitializedOSOs = (1 << 0), |
| 116 | kNumFlags |
| 117 | }; |
| 118 | |
Greg Clayton | 450e3f3 | 2010-10-12 02:24:53 +0000 | [diff] [blame] | 119 | friend class SymbolFileDWARF; |
| 120 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 121 | //------------------------------------------------------------------ |
| 122 | // Class specific types |
| 123 | //------------------------------------------------------------------ |
| 124 | struct CompileUnitInfo |
| 125 | { |
| 126 | lldb_private::FileSpec so_file; |
| 127 | lldb_private::Symbol *so_symbol; |
| 128 | lldb_private::Symbol *oso_symbol; |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 129 | lldb_private::Symbol *last_symbol; |
| 130 | uint32_t first_symbol_index; |
| 131 | uint32_t last_symbol_index; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 132 | lldb::ModuleSP oso_module_sp; |
| 133 | lldb::CompUnitSP oso_compile_unit_sp; |
| 134 | lldb_private::SymbolVendor *oso_symbol_vendor; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 135 | std::vector<uint32_t> function_indexes; |
| 136 | std::vector<uint32_t> static_indexes; |
| 137 | lldb::SharedPtr<lldb_private::SectionList>::Type debug_map_sections_sp; |
| 138 | |
| 139 | CompileUnitInfo() : |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 140 | so_file (), |
| 141 | so_symbol (NULL), |
| 142 | oso_symbol (NULL), |
| 143 | last_symbol (NULL), |
| 144 | first_symbol_index (UINT32_MAX), |
| 145 | last_symbol_index (UINT32_MAX), |
| 146 | oso_module_sp (), |
| 147 | oso_compile_unit_sp (), |
| 148 | oso_symbol_vendor (NULL), |
| 149 | function_indexes (), |
| 150 | static_indexes (), |
| 151 | debug_map_sections_sp () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 152 | { |
| 153 | } |
| 154 | }; |
| 155 | |
| 156 | //------------------------------------------------------------------ |
| 157 | // Protected Member Functions |
| 158 | //------------------------------------------------------------------ |
| 159 | void |
| 160 | InitOSO (); |
| 161 | |
| 162 | bool |
| 163 | GetFileSpecForSO (uint32_t oso_idx, lldb_private::FileSpec &file_spec); |
| 164 | |
| 165 | CompileUnitInfo * |
| 166 | GetCompUnitInfo (const lldb_private::SymbolContext& sc); |
| 167 | |
| 168 | lldb_private::Module * |
| 169 | GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_info); |
| 170 | |
| 171 | lldb_private::Module * |
| 172 | GetModuleByOSOIndex (uint32_t oso_idx); |
| 173 | |
| 174 | lldb_private::ObjectFile * |
| 175 | GetObjectFileByCompUnitInfo (CompileUnitInfo *comp_unit_info); |
| 176 | |
| 177 | lldb_private::ObjectFile * |
| 178 | GetObjectFileByOSOIndex (uint32_t oso_idx); |
| 179 | |
| 180 | SymbolFileDWARF * |
| 181 | GetSymbolFile (const lldb_private::SymbolContext& sc); |
| 182 | |
| 183 | SymbolFileDWARF * |
| 184 | GetSymbolFileByCompUnitInfo (CompileUnitInfo *comp_unit_info); |
| 185 | |
| 186 | SymbolFileDWARF * |
| 187 | GetSymbolFileByOSOIndex (uint32_t oso_idx); |
| 188 | |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 189 | CompileUnitInfo * |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 190 | GetCompileUnitInfoForSymbolWithIndex (uint32_t symbol_idx, uint32_t *oso_idx_ptr); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 191 | |
| 192 | CompileUnitInfo * |
| 193 | GetCompileUnitInfoForSymbolWithID (lldb::user_id_t symbol_id, uint32_t *oso_idx_ptr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 194 | |
| 195 | static int |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 196 | SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info); |
| 197 | |
| 198 | static int |
| 199 | SymbolContainsSymbolWithID (lldb::user_id_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 200 | |
| 201 | uint32_t |
| 202 | PrivateFindGlobalVariables (const lldb_private::ConstString &name, |
| 203 | const std::vector<uint32_t> &name_symbol_indexes, |
| 204 | uint32_t max_matches, |
| 205 | lldb_private::VariableList& variables); |
| 206 | |
Greg Clayton | 450e3f3 | 2010-10-12 02:24:53 +0000 | [diff] [blame] | 207 | |
| 208 | void |
| 209 | SetCompileUnit (SymbolFileDWARF *oso_dwarf, const lldb::CompUnitSP &cu_sp); |
| 210 | |
Greg Clayton | 2ccf8cf | 2010-11-07 21:02:03 +0000 | [diff] [blame] | 211 | lldb::TypeSP |
| 212 | FindDefinitionTypeForDIE (DWARFCompileUnit* cu, |
| 213 | const DWARFDebugInfoEntry *die, |
| 214 | const lldb_private::ConstString &type_name); |
| 215 | |
Greg Clayton | e576ab2 | 2011-02-15 00:19:15 +0000 | [diff] [blame^] | 216 | UniqueDWARFASTTypeMap & |
| 217 | GetUniqueDWARFASTTypeMap () |
| 218 | { |
| 219 | return m_unique_ast_type_map; |
| 220 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 221 | //------------------------------------------------------------------ |
| 222 | // Member Variables |
| 223 | //------------------------------------------------------------------ |
| 224 | std::bitset<kNumFlags> m_flags; |
| 225 | std::vector<CompileUnitInfo> m_compile_unit_infos; |
| 226 | std::vector<uint32_t> m_func_indexes; // Sorted by address |
| 227 | std::vector<uint32_t> m_glob_indexes; |
Greg Clayton | e576ab2 | 2011-02-15 00:19:15 +0000 | [diff] [blame^] | 228 | UniqueDWARFASTTypeMap m_unique_ast_type_map; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 229 | }; |
| 230 | |
| 231 | #endif // #ifndef liblldb_SymbolFileDWARFDebugMap_h_ |