| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SymbolVendor.mm -----------------------------------------*- 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 | #include "lldb/Symbol/SymbolVendor.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
| 16 | #include "lldb/Core/Module.h" |
| 17 | #include "lldb/Core/PluginManager.h" |
| Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Stream.h" |
| 19 | #include "lldb/Symbol/CompileUnit.h" |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | #include "lldb/Symbol/ObjectFile.h" |
| 21 | #include "lldb/Symbol/SymbolFile.h" |
| 22 | |
| 23 | using namespace lldb; |
| 24 | using namespace lldb_private; |
| 25 | |
| 26 | |
| 27 | //---------------------------------------------------------------------- |
| 28 | // FindPlugin |
| 29 | // |
| 30 | // Platforms can register a callback to use when creating symbol |
| 31 | // vendors to allow for complex debug information file setups, and to |
| 32 | // also allow for finding separate debug information files. |
| 33 | //---------------------------------------------------------------------- |
| 34 | SymbolVendor* |
| Greg Clayton | 136dff8 | 2012-12-14 02:15:00 +0000 | [diff] [blame] | 35 | SymbolVendor::FindPlugin (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 36 | { |
| Greg Clayton | 7b0992d | 2013-04-18 22:45:39 +0000 | [diff] [blame] | 37 | std::unique_ptr<SymbolVendor> instance_ap; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 38 | SymbolVendorCreateInstance create_callback; |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 39 | |
| Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 40 | for (size_t idx = 0; (create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(idx)) != nullptr; ++idx) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 41 | { |
| Greg Clayton | 136dff8 | 2012-12-14 02:15:00 +0000 | [diff] [blame] | 42 | instance_ap.reset(create_callback(module_sp, feedback_strm)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 43 | |
| 44 | if (instance_ap.get()) |
| 45 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 46 | return instance_ap.release(); |
| 47 | } |
| 48 | } |
| 49 | // The default implementation just tries to create debug information using the |
| 50 | // file representation for the module. |
| Greg Clayton | e72dfb3 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 51 | instance_ap.reset(new SymbolVendor(module_sp)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 52 | if (instance_ap.get()) |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 53 | { |
| Greg Clayton | e72dfb3 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 54 | ObjectFile *objfile = module_sp->GetObjectFile(); |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 55 | if (objfile) |
| Greg Clayton | e1cd1be | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 56 | instance_ap->AddSymbolFileRepresentation(objfile->shared_from_this()); |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 57 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 58 | return instance_ap.release(); |
| 59 | } |
| 60 | |
| 61 | //---------------------------------------------------------------------- |
| 62 | // SymbolVendor constructor |
| 63 | //---------------------------------------------------------------------- |
| Greg Clayton | e72dfb3 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 64 | SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp) : |
| 65 | ModuleChild (module_sp), |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 66 | m_type_list(), |
| 67 | m_compile_units(), |
| 68 | m_sym_file_ap() |
| 69 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | //---------------------------------------------------------------------- |
| 73 | // Destructor |
| 74 | //---------------------------------------------------------------------- |
| 75 | SymbolVendor::~SymbolVendor() |
| 76 | { |
| 77 | } |
| 78 | |
| 79 | //---------------------------------------------------------------------- |
| Bruce Mitchener | e171da5 | 2015-07-22 00:16:02 +0000 | [diff] [blame] | 80 | // Add a representation given an object file. |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 81 | //---------------------------------------------------------------------- |
| 82 | void |
| Jim Ingham | 7d1c115 | 2011-12-06 01:07:22 +0000 | [diff] [blame] | 83 | SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 84 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 85 | ModuleSP module_sp(GetModule()); |
| 86 | if (module_sp) |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 87 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 88 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 89 | if (objfile_sp) |
| 90 | { |
| 91 | m_objfile_sp = objfile_sp; |
| 92 | m_sym_file_ap.reset(SymbolFile::FindPlugin(objfile_sp.get())); |
| 93 | } |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 94 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | bool |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 98 | SymbolVendor::SetCompileUnitAtIndex (size_t idx, const CompUnitSP &cu_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 99 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 100 | ModuleSP module_sp(GetModule()); |
| 101 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 102 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 103 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 104 | const size_t num_compile_units = GetNumCompileUnits(); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 105 | if (idx < num_compile_units) |
| 106 | { |
| 107 | // Fire off an assertion if this compile unit already exists for now. |
| 108 | // The partial parsing should take care of only setting the compile |
| 109 | // unit once, so if this assertion fails, we need to make sure that |
| 110 | // we don't have a race condition, or have a second parse of the same |
| 111 | // compile unit. |
| Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 112 | assert(m_compile_units[idx].get() == nullptr); |
| Greg Clayton | 53eb1c2 | 2012-04-02 22:59:12 +0000 | [diff] [blame] | 113 | m_compile_units[idx] = cu_sp; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 114 | return true; |
| 115 | } |
| Greg Clayton | 53eb1c2 | 2012-04-02 22:59:12 +0000 | [diff] [blame] | 116 | else |
| 117 | { |
| 118 | // This should NOT happen, and if it does, we want to crash and know |
| 119 | // about it |
| 120 | assert (idx < num_compile_units); |
| 121 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 122 | } |
| 123 | return false; |
| 124 | } |
| 125 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 126 | size_t |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 127 | SymbolVendor::GetNumCompileUnits() |
| 128 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 129 | ModuleSP module_sp(GetModule()); |
| 130 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 131 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 132 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 133 | if (m_compile_units.empty()) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 134 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 135 | if (m_sym_file_ap.get()) |
| 136 | { |
| 137 | // Resize our array of compile unit shared pointers -- which will |
| 138 | // each remain NULL until someone asks for the actual compile unit |
| 139 | // information. When this happens, the symbol file will be asked |
| 140 | // to parse this compile unit information. |
| 141 | m_compile_units.resize(m_sym_file_ap->GetNumCompileUnits()); |
| 142 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 143 | } |
| 144 | } |
| 145 | return m_compile_units.size(); |
| 146 | } |
| 147 | |
| Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 148 | lldb::LanguageType |
| 149 | SymbolVendor::ParseCompileUnitLanguage (const SymbolContext& sc) |
| 150 | { |
| 151 | ModuleSP module_sp(GetModule()); |
| 152 | if (module_sp) |
| 153 | { |
| 154 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 155 | if (m_sym_file_ap.get()) |
| 156 | return m_sym_file_ap->ParseCompileUnitLanguage(sc); |
| 157 | } |
| 158 | return eLanguageTypeUnknown; |
| 159 | } |
| 160 | |
| 161 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 162 | size_t |
| 163 | SymbolVendor::ParseCompileUnitFunctions (const SymbolContext &sc) |
| 164 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 165 | ModuleSP module_sp(GetModule()); |
| 166 | if (module_sp) |
| 167 | { |
| 168 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 169 | if (m_sym_file_ap.get()) |
| 170 | return m_sym_file_ap->ParseCompileUnitFunctions(sc); |
| 171 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | bool |
| 176 | SymbolVendor::ParseCompileUnitLineTable (const SymbolContext &sc) |
| 177 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 178 | ModuleSP module_sp(GetModule()); |
| 179 | if (module_sp) |
| 180 | { |
| 181 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 182 | if (m_sym_file_ap.get()) |
| 183 | return m_sym_file_ap->ParseCompileUnitLineTable(sc); |
| 184 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 185 | return false; |
| 186 | } |
| 187 | |
| 188 | bool |
| 189 | SymbolVendor::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files) |
| 190 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 191 | ModuleSP module_sp(GetModule()); |
| 192 | if (module_sp) |
| 193 | { |
| 194 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 195 | if (m_sym_file_ap.get()) |
| 196 | return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files); |
| 197 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 198 | return false; |
| 199 | } |
| 200 | |
| Sean Callanan | f0c5aeb | 2015-04-20 16:31:29 +0000 | [diff] [blame] | 201 | bool |
| 202 | SymbolVendor::ParseImportedModules (const SymbolContext &sc, |
| 203 | std::vector<ConstString> &imported_modules) |
| 204 | { |
| 205 | ModuleSP module_sp(GetModule()); |
| 206 | if (module_sp) |
| 207 | { |
| 208 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 209 | if (m_sym_file_ap.get()) |
| 210 | return m_sym_file_ap->ParseImportedModules(sc, imported_modules); |
| 211 | } |
| 212 | return false; |
| 213 | |
| 214 | } |
| 215 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 216 | size_t |
| 217 | SymbolVendor::ParseFunctionBlocks (const SymbolContext &sc) |
| 218 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 219 | ModuleSP module_sp(GetModule()); |
| 220 | if (module_sp) |
| 221 | { |
| 222 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 223 | if (m_sym_file_ap.get()) |
| 224 | return m_sym_file_ap->ParseFunctionBlocks(sc); |
| 225 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 226 | return 0; |
| 227 | } |
| 228 | |
| 229 | size_t |
| 230 | SymbolVendor::ParseTypes (const SymbolContext &sc) |
| 231 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 232 | ModuleSP module_sp(GetModule()); |
| 233 | if (module_sp) |
| 234 | { |
| 235 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 236 | if (m_sym_file_ap.get()) |
| 237 | return m_sym_file_ap->ParseTypes(sc); |
| 238 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 239 | return 0; |
| 240 | } |
| 241 | |
| 242 | size_t |
| 243 | SymbolVendor::ParseVariablesForContext (const SymbolContext& sc) |
| 244 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 245 | ModuleSP module_sp(GetModule()); |
| 246 | if (module_sp) |
| 247 | { |
| 248 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 249 | if (m_sym_file_ap.get()) |
| 250 | return m_sym_file_ap->ParseVariablesForContext(sc); |
| 251 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 252 | return 0; |
| 253 | } |
| 254 | |
| 255 | Type* |
| 256 | SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid) |
| 257 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 258 | ModuleSP module_sp(GetModule()); |
| 259 | if (module_sp) |
| 260 | { |
| 261 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 262 | if (m_sym_file_ap.get()) |
| 263 | return m_sym_file_ap->ResolveTypeUID(type_uid); |
| 264 | } |
| Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 265 | return nullptr; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | |
| 269 | uint32_t |
| 270 | SymbolVendor::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) |
| 271 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 272 | ModuleSP module_sp(GetModule()); |
| 273 | if (module_sp) |
| 274 | { |
| 275 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 276 | if (m_sym_file_ap.get()) |
| 277 | return m_sym_file_ap->ResolveSymbolContext(so_addr, resolve_scope, sc); |
| 278 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 279 | return 0; |
| 280 | } |
| 281 | |
| 282 | uint32_t |
| 283 | SymbolVendor::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) |
| 284 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 285 | ModuleSP module_sp(GetModule()); |
| 286 | if (module_sp) |
| 287 | { |
| 288 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 289 | if (m_sym_file_ap.get()) |
| 290 | return m_sym_file_ap->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list); |
| 291 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 292 | return 0; |
| 293 | } |
| 294 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 295 | size_t |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 296 | SymbolVendor::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variables) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 297 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 298 | ModuleSP module_sp(GetModule()); |
| 299 | if (module_sp) |
| 300 | { |
| 301 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 302 | if (m_sym_file_ap.get()) |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 303 | return m_sym_file_ap->FindGlobalVariables(name, parent_decl_ctx, append, max_matches, variables); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 304 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 305 | return 0; |
| 306 | } |
| 307 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 308 | size_t |
| 309 | SymbolVendor::FindGlobalVariables (const RegularExpression& regex, bool append, size_t max_matches, VariableList& variables) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 310 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 311 | ModuleSP module_sp(GetModule()); |
| 312 | if (module_sp) |
| 313 | { |
| 314 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 315 | if (m_sym_file_ap.get()) |
| 316 | return m_sym_file_ap->FindGlobalVariables(regex, append, max_matches, variables); |
| 317 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 318 | return 0; |
| 319 | } |
| 320 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 321 | size_t |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 322 | SymbolVendor::FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 323 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 324 | ModuleSP module_sp(GetModule()); |
| 325 | if (module_sp) |
| 326 | { |
| 327 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 328 | if (m_sym_file_ap.get()) |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 329 | return m_sym_file_ap->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, append, sc_list); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 330 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 331 | return 0; |
| 332 | } |
| 333 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 334 | size_t |
| Sean Callanan | 9df05fb | 2012-02-10 22:52:19 +0000 | [diff] [blame] | 335 | SymbolVendor::FindFunctions(const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 336 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 337 | ModuleSP module_sp(GetModule()); |
| 338 | if (module_sp) |
| 339 | { |
| 340 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 341 | if (m_sym_file_ap.get()) |
| 342 | return m_sym_file_ap->FindFunctions(regex, include_inlines, append, sc_list); |
| 343 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 344 | return 0; |
| 345 | } |
| 346 | |
| 347 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 348 | size_t |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 349 | SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, TypeList& types) |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 350 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 351 | ModuleSP module_sp(GetModule()); |
| 352 | if (module_sp) |
| 353 | { |
| 354 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 355 | if (m_sym_file_ap.get()) |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 356 | return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append, max_matches, types); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 357 | } |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 358 | if (!append) |
| 359 | types.Clear(); |
| 360 | return 0; |
| 361 | } |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 362 | |
| Greg Clayton | f02500c | 2013-06-18 22:51:05 +0000 | [diff] [blame] | 363 | size_t |
| 364 | SymbolVendor::GetTypes (SymbolContextScope *sc_scope, |
| 365 | uint32_t type_mask, |
| 366 | lldb_private::TypeList &type_list) |
| 367 | { |
| 368 | ModuleSP module_sp(GetModule()); |
| 369 | if (module_sp) |
| 370 | { |
| 371 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 372 | if (m_sym_file_ap.get()) |
| 373 | return m_sym_file_ap->GetTypes (sc_scope, type_mask, type_list); |
| 374 | } |
| 375 | return 0; |
| 376 | } |
| 377 | |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 378 | CompilerDeclContext |
| 379 | SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx) |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 380 | { |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 381 | CompilerDeclContext namespace_decl_ctx; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 382 | ModuleSP module_sp(GetModule()); |
| 383 | if (module_sp) |
| 384 | { |
| 385 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 386 | if (m_sym_file_ap.get()) |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 387 | namespace_decl_ctx = m_sym_file_ap->FindNamespace (sc, name, parent_decl_ctx); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 388 | } |
| Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame^] | 389 | return namespace_decl_ctx; |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 390 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 391 | |
| 392 | void |
| 393 | SymbolVendor::Dump(Stream *s) |
| 394 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 395 | ModuleSP module_sp(GetModule()); |
| 396 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 397 | { |
| Greg Clayton | 50bd5a2 | 2015-04-14 22:34:00 +0000 | [diff] [blame] | 398 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 399 | |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 400 | bool show_context = false; |
| 401 | |
| Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 402 | s->Printf("%p: ", static_cast<void*>(this)); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 403 | s->Indent(); |
| 404 | s->PutCString("SymbolVendor"); |
| 405 | if (m_sym_file_ap.get()) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 406 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 407 | ObjectFile *objfile = m_sym_file_ap->GetObjectFile(); |
| 408 | if (objfile) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 409 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 410 | const FileSpec &objfile_file_spec = objfile->GetFileSpec(); |
| 411 | if (objfile_file_spec) |
| 412 | { |
| 413 | s->PutCString(" ("); |
| 414 | objfile_file_spec.Dump(s); |
| 415 | s->PutChar(')'); |
| 416 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 417 | } |
| 418 | } |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 419 | s->EOL(); |
| 420 | s->IndentMore(); |
| 421 | m_type_list.Dump(s, show_context); |
| 422 | |
| 423 | CompileUnitConstIter cu_pos, cu_end; |
| 424 | cu_end = m_compile_units.end(); |
| 425 | for (cu_pos = m_compile_units.begin(); cu_pos != cu_end; ++cu_pos) |
| 426 | { |
| 427 | // We currently only dump the compile units that have been parsed |
| 428 | if (cu_pos->get()) |
| 429 | (*cu_pos)->Dump(s, show_context); |
| 430 | } |
| 431 | |
| 432 | s->IndentLess(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 433 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 434 | } |
| 435 | |
| 436 | CompUnitSP |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 437 | SymbolVendor::GetCompileUnitAtIndex(size_t idx) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 438 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 439 | CompUnitSP cu_sp; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 440 | ModuleSP module_sp(GetModule()); |
| 441 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 442 | { |
| Greg Clayton | 50bd5a2 | 2015-04-14 22:34:00 +0000 | [diff] [blame] | 443 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 444 | const size_t num_compile_units = GetNumCompileUnits(); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 445 | if (idx < num_compile_units) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 446 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 447 | cu_sp = m_compile_units[idx]; |
| Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 448 | if (cu_sp.get() == nullptr) |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 449 | { |
| 450 | m_compile_units[idx] = m_sym_file_ap->ParseCompileUnitAtIndex(idx); |
| 451 | cu_sp = m_compile_units[idx]; |
| 452 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 453 | } |
| 454 | } |
| 455 | return cu_sp; |
| 456 | } |
| 457 | |
| Ilia K | e912e3e | 2015-03-10 21:18:59 +0000 | [diff] [blame] | 458 | FileSpec |
| 459 | SymbolVendor::GetMainFileSpec() const |
| 460 | { |
| 461 | if (m_sym_file_ap.get()) |
| 462 | { |
| 463 | const ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile(); |
| 464 | if (symfile_objfile) |
| 465 | return symfile_objfile->GetFileSpec(); |
| 466 | } |
| 467 | |
| 468 | return FileSpec(); |
| 469 | } |
| 470 | |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 471 | Symtab * |
| 472 | SymbolVendor::GetSymtab () |
| 473 | { |
| 474 | ModuleSP module_sp(GetModule()); |
| 475 | if (module_sp) |
| 476 | { |
| 477 | ObjectFile *objfile = module_sp->GetObjectFile(); |
| 478 | if (objfile) |
| 479 | { |
| 480 | // Get symbol table from unified section list. |
| Greg Clayton | 3046e66 | 2013-07-10 01:23:25 +0000 | [diff] [blame] | 481 | return objfile->GetSymtab (); |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 482 | } |
| 483 | } |
| Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 484 | return nullptr; |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 485 | } |
| 486 | |
| 487 | void |
| 488 | SymbolVendor::ClearSymtab() |
| 489 | { |
| 490 | ModuleSP module_sp(GetModule()); |
| 491 | if (module_sp) |
| 492 | { |
| 493 | ObjectFile *objfile = module_sp->GetObjectFile(); |
| 494 | if (objfile) |
| 495 | { |
| 496 | // Clear symbol table from unified section list. |
| Greg Clayton | 3046e66 | 2013-07-10 01:23:25 +0000 | [diff] [blame] | 497 | objfile->ClearSymtab (); |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 498 | } |
| 499 | } |
| 500 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 501 | |
| Jason Molenda | 05a09c6 | 2014-08-22 02:46:46 +0000 | [diff] [blame] | 502 | void |
| 503 | SymbolVendor::SectionFileAddressesChanged () |
| 504 | { |
| 505 | ModuleSP module_sp(GetModule()); |
| 506 | if (module_sp) |
| 507 | { |
| 508 | ObjectFile *module_objfile = module_sp->GetObjectFile (); |
| 509 | if (m_sym_file_ap.get()) |
| 510 | { |
| 511 | ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile (); |
| 512 | if (symfile_objfile != module_objfile) |
| 513 | symfile_objfile->SectionFileAddressesChanged (); |
| 514 | } |
| 515 | Symtab *symtab = GetSymtab (); |
| 516 | if (symtab) |
| 517 | { |
| 518 | symtab->SectionFileAddressesChanged (); |
| 519 | } |
| 520 | } |
| 521 | } |
| 522 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 523 | //------------------------------------------------------------------ |
| 524 | // PluginInterface protocol |
| 525 | //------------------------------------------------------------------ |
| Greg Clayton | 57abc5d | 2013-05-10 21:47:16 +0000 | [diff] [blame] | 526 | lldb_private::ConstString |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 527 | SymbolVendor::GetPluginName() |
| 528 | { |
| Greg Clayton | 57abc5d | 2013-05-10 21:47:16 +0000 | [diff] [blame] | 529 | static ConstString g_name("vendor-default"); |
| 530 | return g_name; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 531 | } |
| 532 | |
| 533 | uint32_t |
| 534 | SymbolVendor::GetPluginVersion() |
| 535 | { |
| 536 | return 1; |
| 537 | } |
| 538 | |