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