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 | 213fdb8 | 2011-10-13 01:49:10 +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 append, lldb_private::SymbolContextList& sc_list); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 80 | virtual uint32_t FindFunctions (const lldb_private::RegularExpression& regex, 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; |
| 144 | lldb::SharedPtr<lldb_private::SectionList>::Type debug_map_sections_sp; |
| 145 | |
| 146 | CompileUnitInfo() : |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 147 | so_file (), |
| 148 | so_symbol (NULL), |
| 149 | oso_symbol (NULL), |
| 150 | last_symbol (NULL), |
| 151 | first_symbol_index (UINT32_MAX), |
| 152 | last_symbol_index (UINT32_MAX), |
| 153 | oso_module_sp (), |
| 154 | oso_compile_unit_sp (), |
| 155 | oso_symbol_vendor (NULL), |
| 156 | function_indexes (), |
| 157 | static_indexes (), |
| 158 | debug_map_sections_sp () |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 159 | { |
| 160 | } |
| 161 | }; |
| 162 | |
| 163 | //------------------------------------------------------------------ |
| 164 | // Protected Member Functions |
| 165 | //------------------------------------------------------------------ |
| 166 | void |
| 167 | InitOSO (); |
| 168 | |
Greg Clayton | 81c22f6 | 2011-10-19 18:09:39 +0000 | [diff] [blame] | 169 | static uint32_t |
| 170 | GetOSOIndexFromUserID (lldb::user_id_t uid) |
| 171 | { |
| 172 | return (uint32_t)((uid >> 32ull) - 1ull); |
| 173 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 174 | bool |
| 175 | GetFileSpecForSO (uint32_t oso_idx, lldb_private::FileSpec &file_spec); |
| 176 | |
| 177 | CompileUnitInfo * |
| 178 | GetCompUnitInfo (const lldb_private::SymbolContext& sc); |
| 179 | |
| 180 | lldb_private::Module * |
| 181 | GetModuleByCompUnitInfo (CompileUnitInfo *comp_unit_info); |
| 182 | |
| 183 | lldb_private::Module * |
| 184 | GetModuleByOSOIndex (uint32_t oso_idx); |
| 185 | |
| 186 | lldb_private::ObjectFile * |
| 187 | GetObjectFileByCompUnitInfo (CompileUnitInfo *comp_unit_info); |
| 188 | |
| 189 | lldb_private::ObjectFile * |
| 190 | GetObjectFileByOSOIndex (uint32_t oso_idx); |
| 191 | |
Greg Clayton | 81c22f6 | 2011-10-19 18:09:39 +0000 | [diff] [blame] | 192 | uint32_t |
| 193 | GetCompUnitInfoIndex (const CompileUnitInfo *comp_unit_info); |
| 194 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 195 | SymbolFileDWARF * |
| 196 | GetSymbolFile (const lldb_private::SymbolContext& sc); |
| 197 | |
| 198 | SymbolFileDWARF * |
| 199 | GetSymbolFileByCompUnitInfo (CompileUnitInfo *comp_unit_info); |
| 200 | |
| 201 | SymbolFileDWARF * |
| 202 | GetSymbolFileByOSOIndex (uint32_t oso_idx); |
| 203 | |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 204 | CompileUnitInfo * |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 205 | GetCompileUnitInfoForSymbolWithIndex (uint32_t symbol_idx, uint32_t *oso_idx_ptr); |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 206 | |
| 207 | CompileUnitInfo * |
| 208 | GetCompileUnitInfoForSymbolWithID (lldb::user_id_t symbol_id, uint32_t *oso_idx_ptr); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 209 | |
| 210 | static int |
Greg Clayton | bcf2cfb | 2010-09-11 03:13:28 +0000 | [diff] [blame] | 211 | SymbolContainsSymbolWithIndex (uint32_t *symbol_idx_ptr, const CompileUnitInfo *comp_unit_info); |
| 212 | |
| 213 | static int |
| 214 | 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] | 215 | |
| 216 | uint32_t |
| 217 | PrivateFindGlobalVariables (const lldb_private::ConstString &name, |
Sean Callanan | 213fdb8 | 2011-10-13 01:49:10 +0000 | [diff] [blame] | 218 | const lldb_private::ClangNamespaceDecl *namespace_decl, |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 219 | const std::vector<uint32_t> &name_symbol_indexes, |
| 220 | uint32_t max_matches, |
| 221 | lldb_private::VariableList& variables); |
| 222 | |
Greg Clayton | 450e3f3 | 2010-10-12 02:24:53 +0000 | [diff] [blame] | 223 | |
| 224 | void |
| 225 | SetCompileUnit (SymbolFileDWARF *oso_dwarf, const lldb::CompUnitSP &cu_sp); |
| 226 | |
Greg Clayton | 2ccf8cf | 2010-11-07 21:02:03 +0000 | [diff] [blame] | 227 | lldb::TypeSP |
| 228 | FindDefinitionTypeForDIE (DWARFCompileUnit* cu, |
| 229 | const DWARFDebugInfoEntry *die, |
| 230 | const lldb_private::ConstString &type_name); |
| 231 | |
Greg Clayton | c7f03b6 | 2012-01-12 04:33:28 +0000 | [diff] [blame] | 232 | bool |
| 233 | Supports_DW_AT_APPLE_objc_complete_type (SymbolFileDWARF *skip_dwarf_oso); |
| 234 | |
Greg Clayton | 901c5ca | 2011-12-03 04:40:03 +0000 | [diff] [blame] | 235 | lldb::TypeSP |
Greg Clayton | c7f03b6 | 2012-01-12 04:33:28 +0000 | [diff] [blame] | 236 | FindCompleteObjCDefinitionTypeForDIE (const DWARFDebugInfoEntry *die, |
| 237 | const lldb_private::ConstString &type_name, |
| 238 | bool must_be_implementation); |
Greg Clayton | 901c5ca | 2011-12-03 04:40:03 +0000 | [diff] [blame] | 239 | |
| 240 | |
Greg Clayton | e576ab2 | 2011-02-15 00:19:15 +0000 | [diff] [blame] | 241 | UniqueDWARFASTTypeMap & |
| 242 | GetUniqueDWARFASTTypeMap () |
| 243 | { |
| 244 | return m_unique_ast_type_map; |
| 245 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 246 | //------------------------------------------------------------------ |
| 247 | // Member Variables |
| 248 | //------------------------------------------------------------------ |
| 249 | std::bitset<kNumFlags> m_flags; |
| 250 | std::vector<CompileUnitInfo> m_compile_unit_infos; |
| 251 | std::vector<uint32_t> m_func_indexes; // Sorted by address |
| 252 | std::vector<uint32_t> m_glob_indexes; |
Greg Clayton | e576ab2 | 2011-02-15 00:19:15 +0000 | [diff] [blame] | 253 | UniqueDWARFASTTypeMap m_unique_ast_type_map; |
Greg Clayton | c7f03b6 | 2012-01-12 04:33:28 +0000 | [diff] [blame] | 254 | lldb_private::LazyBool m_supports_DW_AT_APPLE_objc_complete_type; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 255 | }; |
| 256 | |
Greg Clayton | a76dd62 | 2011-09-12 04:20:38 +0000 | [diff] [blame] | 257 | #endif // #ifndef SymbolFileDWARF_SymbolFileDWARFDebugMap_h_ |