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