Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SymbolFile.cpp ------------------------------------------*- 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 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 10 | #include "lldb/Symbol/SymbolFile.h" |
Greg Clayton | c982b3d | 2011-11-28 01:45:00 +0000 | [diff] [blame] | 11 | |
| 12 | #include "lldb/lldb-private.h" |
| 13 | #include "lldb/Core/Log.h" |
Greg Clayton | 2d95dc9b | 2010-11-10 04:57:04 +0000 | [diff] [blame] | 14 | #include "lldb/Core/Module.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #include "lldb/Core/PluginManager.h" |
Greg Clayton | c982b3d | 2011-11-28 01:45:00 +0000 | [diff] [blame] | 16 | #include "lldb/Core/StreamString.h" |
Greg Clayton | 2d95dc9b | 2010-11-10 04:57:04 +0000 | [diff] [blame] | 17 | #include "lldb/Symbol/ObjectFile.h" |
Ravitheja Addepally | 4069730 | 2015-10-08 09:45:41 +0000 | [diff] [blame^] | 18 | #include "lldb/Symbol/TypeMap.h" |
Greg Clayton | 56939cb | 2015-09-17 22:23:34 +0000 | [diff] [blame] | 19 | #include "lldb/Symbol/TypeSystem.h" |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 20 | #include "lldb/Symbol/VariableList.h" |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | |
| 22 | using namespace lldb_private; |
| 23 | |
| 24 | SymbolFile* |
| 25 | SymbolFile::FindPlugin (ObjectFile* obj_file) |
| 26 | { |
Greg Clayton | 7b0992d | 2013-04-18 22:45:39 +0000 | [diff] [blame] | 27 | std::unique_ptr<SymbolFile> best_symfile_ap; |
Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 28 | if (obj_file != nullptr) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 29 | { |
Greg Clayton | 3046e66 | 2013-07-10 01:23:25 +0000 | [diff] [blame] | 30 | |
| 31 | // We need to test the abilities of this section list. So create what it would |
| 32 | // be with this new obj_file. |
| 33 | lldb::ModuleSP module_sp(obj_file->GetModule()); |
| 34 | if (module_sp) |
| 35 | { |
| 36 | // Default to the main module section list. |
| 37 | ObjectFile *module_obj_file = module_sp->GetObjectFile(); |
| 38 | if (module_obj_file != obj_file) |
| 39 | { |
| 40 | // Make sure the main object file's sections are created |
| 41 | module_obj_file->GetSectionList(); |
| 42 | obj_file->CreateSections (*module_sp->GetUnifiedSectionList()); |
| 43 | } |
| 44 | } |
| 45 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 46 | // TODO: Load any plug-ins in the appropriate plug-in search paths and |
| 47 | // iterate over all of them to find the best one for the job. |
| 48 | |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | uint32_t best_symfile_abilities = 0; |
| 50 | |
| 51 | SymbolFileCreateInstance create_callback; |
Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 52 | for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != nullptr; ++idx) |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 53 | { |
Greg Clayton | 7b0992d | 2013-04-18 22:45:39 +0000 | [diff] [blame] | 54 | std::unique_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file)); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 55 | |
| 56 | if (curr_symfile_ap.get()) |
| 57 | { |
Greg Clayton | 9efa076 | 2012-04-26 16:53:42 +0000 | [diff] [blame] | 58 | const uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 59 | if (sym_file_abilities > best_symfile_abilities) |
| 60 | { |
| 61 | best_symfile_abilities = sym_file_abilities; |
Greg Clayton | e01e07b | 2013-04-18 18:10:51 +0000 | [diff] [blame] | 62 | best_symfile_ap.reset (curr_symfile_ap.release()); |
Greg Clayton | 9efa076 | 2012-04-26 16:53:42 +0000 | [diff] [blame] | 63 | // If any symbol file parser has all of the abilities, then |
| 64 | // we should just stop looking. |
| 65 | if ((kAllAbilities & sym_file_abilities) == kAllAbilities) |
| 66 | break; |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 67 | } |
| 68 | } |
| 69 | } |
Greg Clayton | 6beaaa6 | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 70 | if (best_symfile_ap.get()) |
| 71 | { |
| 72 | // Let the winning symbol file parser initialize itself more |
| 73 | // completely now that it has been chosen |
| 74 | best_symfile_ap->InitializeObject(); |
| 75 | } |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 76 | } |
Greg Clayton | 6beaaa6 | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 77 | return best_symfile_ap.release(); |
Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 78 | } |
| 79 | |
Greg Clayton | 2d95dc9b | 2010-11-10 04:57:04 +0000 | [diff] [blame] | 80 | TypeList * |
| 81 | SymbolFile::GetTypeList () |
| 82 | { |
Greg Clayton | 6beaaa6 | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 83 | if (m_obj_file) |
| 84 | return m_obj_file->GetModule()->GetTypeList(); |
Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 85 | return nullptr; |
Greg Clayton | 2d95dc9b | 2010-11-10 04:57:04 +0000 | [diff] [blame] | 86 | } |
Greg Clayton | 6beaaa6 | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 87 | |
Greg Clayton | 8b4edba | 2015-08-14 20:02:05 +0000 | [diff] [blame] | 88 | TypeSystem * |
| 89 | SymbolFile::GetTypeSystemForLanguage (lldb::LanguageType language) |
| 90 | { |
Ryan Brown | 57bee1e | 2015-09-14 22:45:11 +0000 | [diff] [blame] | 91 | TypeSystem *type_system = m_obj_file->GetModule()->GetTypeSystemForLanguage(language); |
| 92 | if (type_system) |
| 93 | type_system->SetSymbolFile(this); |
| 94 | return type_system; |
Greg Clayton | 8b4edba | 2015-08-14 20:02:05 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 97 | uint32_t |
| 98 | SymbolFile::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) |
| 99 | { |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 100 | return 0; |
| 101 | } |
| 102 | |
| 103 | |
| 104 | uint32_t |
| 105 | SymbolFile::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, VariableList& variables) |
| 106 | { |
| 107 | if (!append) |
| 108 | variables.Clear(); |
| 109 | return 0; |
| 110 | } |
| 111 | |
| 112 | |
| 113 | uint32_t |
| 114 | SymbolFile::FindGlobalVariables (const RegularExpression& regex, bool append, uint32_t max_matches, VariableList& variables) |
| 115 | { |
| 116 | if (!append) |
| 117 | variables.Clear(); |
| 118 | return 0; |
| 119 | } |
| 120 | |
| 121 | uint32_t |
| 122 | SymbolFile::FindFunctions (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list) |
| 123 | { |
| 124 | if (!append) |
| 125 | sc_list.Clear(); |
| 126 | return 0; |
| 127 | } |
| 128 | |
| 129 | uint32_t |
| 130 | SymbolFile::FindFunctions (const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list) |
| 131 | { |
| 132 | if (!append) |
| 133 | sc_list.Clear(); |
| 134 | return 0; |
| 135 | } |
| 136 | |
| 137 | uint32_t |
Ravitheja Addepally | 4069730 | 2015-10-08 09:45:41 +0000 | [diff] [blame^] | 138 | SymbolFile::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, uint32_t max_matches, TypeMap& types) |
Greg Clayton | 99558cc4 | 2015-08-24 23:46:31 +0000 | [diff] [blame] | 139 | { |
| 140 | if (!append) |
| 141 | types.Clear(); |
| 142 | return 0; |
| 143 | } |
| 144 | |