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