| 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 | //---------------------------------------------------------------------- |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 80 | // Add a represention 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 | |
| 201 | size_t |
| 202 | SymbolVendor::ParseFunctionBlocks (const SymbolContext &sc) |
| 203 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 204 | ModuleSP module_sp(GetModule()); |
| 205 | if (module_sp) |
| 206 | { |
| 207 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 208 | if (m_sym_file_ap.get()) |
| 209 | return m_sym_file_ap->ParseFunctionBlocks(sc); |
| 210 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 211 | return 0; |
| 212 | } |
| 213 | |
| 214 | size_t |
| 215 | SymbolVendor::ParseTypes (const SymbolContext &sc) |
| 216 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 217 | ModuleSP module_sp(GetModule()); |
| 218 | if (module_sp) |
| 219 | { |
| 220 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 221 | if (m_sym_file_ap.get()) |
| 222 | return m_sym_file_ap->ParseTypes(sc); |
| 223 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 224 | return 0; |
| 225 | } |
| 226 | |
| 227 | size_t |
| 228 | SymbolVendor::ParseVariablesForContext (const SymbolContext& sc) |
| 229 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 230 | ModuleSP module_sp(GetModule()); |
| 231 | if (module_sp) |
| 232 | { |
| 233 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 234 | if (m_sym_file_ap.get()) |
| 235 | return m_sym_file_ap->ParseVariablesForContext(sc); |
| 236 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 237 | return 0; |
| 238 | } |
| 239 | |
| 240 | Type* |
| 241 | SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid) |
| 242 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 243 | ModuleSP module_sp(GetModule()); |
| 244 | if (module_sp) |
| 245 | { |
| 246 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 247 | if (m_sym_file_ap.get()) |
| 248 | return m_sym_file_ap->ResolveTypeUID(type_uid); |
| 249 | } |
| Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 250 | return nullptr; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | |
| 254 | uint32_t |
| 255 | SymbolVendor::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) |
| 256 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 257 | ModuleSP module_sp(GetModule()); |
| 258 | if (module_sp) |
| 259 | { |
| 260 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 261 | if (m_sym_file_ap.get()) |
| 262 | return m_sym_file_ap->ResolveSymbolContext(so_addr, resolve_scope, sc); |
| 263 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 264 | return 0; |
| 265 | } |
| 266 | |
| 267 | uint32_t |
| 268 | SymbolVendor::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) |
| 269 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 270 | ModuleSP module_sp(GetModule()); |
| 271 | if (module_sp) |
| 272 | { |
| 273 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 274 | if (m_sym_file_ap.get()) |
| 275 | return m_sym_file_ap->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list); |
| 276 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 277 | return 0; |
| 278 | } |
| 279 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 280 | size_t |
| 281 | SymbolVendor::FindGlobalVariables (const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, size_t max_matches, VariableList& variables) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 282 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 283 | ModuleSP module_sp(GetModule()); |
| 284 | if (module_sp) |
| 285 | { |
| 286 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 287 | if (m_sym_file_ap.get()) |
| 288 | return m_sym_file_ap->FindGlobalVariables(name, namespace_decl, append, max_matches, variables); |
| 289 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 290 | return 0; |
| 291 | } |
| 292 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 293 | size_t |
| 294 | 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] | 295 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 296 | ModuleSP module_sp(GetModule()); |
| 297 | if (module_sp) |
| 298 | { |
| 299 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 300 | if (m_sym_file_ap.get()) |
| 301 | return m_sym_file_ap->FindGlobalVariables(regex, append, max_matches, variables); |
| 302 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 303 | return 0; |
| 304 | } |
| 305 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 306 | size_t |
| Sean Callanan | 9df05fb | 2012-02-10 22:52:19 +0000 | [diff] [blame] | 307 | SymbolVendor::FindFunctions(const ConstString &name, const ClangNamespaceDecl *namespace_decl, 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] | 308 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 309 | ModuleSP module_sp(GetModule()); |
| 310 | if (module_sp) |
| 311 | { |
| 312 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 313 | if (m_sym_file_ap.get()) |
| 314 | return m_sym_file_ap->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list); |
| 315 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 316 | return 0; |
| 317 | } |
| 318 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 319 | size_t |
| Sean Callanan | 9df05fb | 2012-02-10 22:52:19 +0000 | [diff] [blame] | 320 | 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] | 321 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 322 | ModuleSP module_sp(GetModule()); |
| 323 | if (module_sp) |
| 324 | { |
| 325 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 326 | if (m_sym_file_ap.get()) |
| 327 | return m_sym_file_ap->FindFunctions(regex, include_inlines, append, sc_list); |
| 328 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 333 | size_t |
| 334 | SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *namespace_decl, bool append, size_t max_matches, TypeList& types) |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 335 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 336 | ModuleSP module_sp(GetModule()); |
| 337 | if (module_sp) |
| 338 | { |
| 339 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 340 | if (m_sym_file_ap.get()) |
| 341 | return m_sym_file_ap->FindTypes(sc, name, namespace_decl, append, max_matches, types); |
| 342 | } |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 343 | if (!append) |
| 344 | types.Clear(); |
| 345 | return 0; |
| 346 | } |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 347 | |
| Greg Clayton | f02500c | 2013-06-18 22:51:05 +0000 | [diff] [blame] | 348 | size_t |
| 349 | SymbolVendor::GetTypes (SymbolContextScope *sc_scope, |
| 350 | uint32_t type_mask, |
| 351 | lldb_private::TypeList &type_list) |
| 352 | { |
| 353 | ModuleSP module_sp(GetModule()); |
| 354 | if (module_sp) |
| 355 | { |
| 356 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 357 | if (m_sym_file_ap.get()) |
| 358 | return m_sym_file_ap->GetTypes (sc_scope, type_mask, type_list); |
| 359 | } |
| 360 | return 0; |
| 361 | } |
| 362 | |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 363 | ClangNamespaceDecl |
| Sean Callanan | 213fdb8 | 2011-10-13 01:49:10 +0000 | [diff] [blame] | 364 | SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const ClangNamespaceDecl *parent_namespace_decl) |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 365 | { |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 366 | ClangNamespaceDecl namespace_decl; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 367 | ModuleSP module_sp(GetModule()); |
| 368 | if (module_sp) |
| 369 | { |
| 370 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 371 | if (m_sym_file_ap.get()) |
| 372 | namespace_decl = m_sym_file_ap->FindNamespace (sc, name, parent_namespace_decl); |
| 373 | } |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 374 | return namespace_decl; |
| 375 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 376 | |
| 377 | void |
| 378 | SymbolVendor::Dump(Stream *s) |
| 379 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 380 | ModuleSP module_sp(GetModule()); |
| 381 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 382 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 383 | bool show_context = false; |
| 384 | |
| Saleem Abdulrasool | 324a103 | 2014-04-04 04:06:10 +0000 | [diff] [blame] | 385 | s->Printf("%p: ", static_cast<void*>(this)); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 386 | s->Indent(); |
| 387 | s->PutCString("SymbolVendor"); |
| 388 | if (m_sym_file_ap.get()) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 389 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 390 | ObjectFile *objfile = m_sym_file_ap->GetObjectFile(); |
| 391 | if (objfile) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 392 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 393 | const FileSpec &objfile_file_spec = objfile->GetFileSpec(); |
| 394 | if (objfile_file_spec) |
| 395 | { |
| 396 | s->PutCString(" ("); |
| 397 | objfile_file_spec.Dump(s); |
| 398 | s->PutChar(')'); |
| 399 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 400 | } |
| 401 | } |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 402 | s->EOL(); |
| 403 | s->IndentMore(); |
| 404 | m_type_list.Dump(s, show_context); |
| 405 | |
| 406 | CompileUnitConstIter cu_pos, cu_end; |
| 407 | cu_end = m_compile_units.end(); |
| 408 | for (cu_pos = m_compile_units.begin(); cu_pos != cu_end; ++cu_pos) |
| 409 | { |
| 410 | // We currently only dump the compile units that have been parsed |
| 411 | if (cu_pos->get()) |
| 412 | (*cu_pos)->Dump(s, show_context); |
| 413 | } |
| 414 | |
| 415 | s->IndentLess(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 416 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 417 | } |
| 418 | |
| 419 | CompUnitSP |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 420 | SymbolVendor::GetCompileUnitAtIndex(size_t idx) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 421 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 422 | CompUnitSP cu_sp; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 423 | ModuleSP module_sp(GetModule()); |
| 424 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 425 | { |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 426 | const size_t num_compile_units = GetNumCompileUnits(); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 427 | if (idx < num_compile_units) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 428 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 429 | cu_sp = m_compile_units[idx]; |
| Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 430 | if (cu_sp.get() == nullptr) |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 431 | { |
| 432 | m_compile_units[idx] = m_sym_file_ap->ParseCompileUnitAtIndex(idx); |
| 433 | cu_sp = m_compile_units[idx]; |
| 434 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 435 | } |
| 436 | } |
| 437 | return cu_sp; |
| 438 | } |
| 439 | |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 440 | Symtab * |
| 441 | SymbolVendor::GetSymtab () |
| 442 | { |
| 443 | ModuleSP module_sp(GetModule()); |
| 444 | if (module_sp) |
| 445 | { |
| 446 | ObjectFile *objfile = module_sp->GetObjectFile(); |
| 447 | if (objfile) |
| 448 | { |
| 449 | // Get symbol table from unified section list. |
| Greg Clayton | 3046e66 | 2013-07-10 01:23:25 +0000 | [diff] [blame] | 450 | return objfile->GetSymtab (); |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 451 | } |
| 452 | } |
| Ed Maste | d4612ad | 2014-04-20 13:17:36 +0000 | [diff] [blame] | 453 | return nullptr; |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | void |
| 457 | SymbolVendor::ClearSymtab() |
| 458 | { |
| 459 | ModuleSP module_sp(GetModule()); |
| 460 | if (module_sp) |
| 461 | { |
| 462 | ObjectFile *objfile = module_sp->GetObjectFile(); |
| 463 | if (objfile) |
| 464 | { |
| 465 | // Clear symbol table from unified section list. |
| Greg Clayton | 3046e66 | 2013-07-10 01:23:25 +0000 | [diff] [blame] | 466 | objfile->ClearSymtab (); |
| Michael Sartain | a7499c9 | 2013-07-01 19:45:50 +0000 | [diff] [blame] | 467 | } |
| 468 | } |
| 469 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 470 | |
| Jason Molenda | 05a09c6 | 2014-08-22 02:46:46 +0000 | [diff] [blame^] | 471 | void |
| 472 | SymbolVendor::SectionFileAddressesChanged () |
| 473 | { |
| 474 | ModuleSP module_sp(GetModule()); |
| 475 | if (module_sp) |
| 476 | { |
| 477 | ObjectFile *module_objfile = module_sp->GetObjectFile (); |
| 478 | if (m_sym_file_ap.get()) |
| 479 | { |
| 480 | ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile (); |
| 481 | if (symfile_objfile != module_objfile) |
| 482 | symfile_objfile->SectionFileAddressesChanged (); |
| 483 | } |
| 484 | Symtab *symtab = GetSymtab (); |
| 485 | if (symtab) |
| 486 | { |
| 487 | symtab->SectionFileAddressesChanged (); |
| 488 | } |
| 489 | } |
| 490 | } |
| 491 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 492 | //------------------------------------------------------------------ |
| 493 | // PluginInterface protocol |
| 494 | //------------------------------------------------------------------ |
| Greg Clayton | 57abc5d | 2013-05-10 21:47:16 +0000 | [diff] [blame] | 495 | lldb_private::ConstString |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 496 | SymbolVendor::GetPluginName() |
| 497 | { |
| Greg Clayton | 57abc5d | 2013-05-10 21:47:16 +0000 | [diff] [blame] | 498 | static ConstString g_name("vendor-default"); |
| 499 | return g_name; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | uint32_t |
| 503 | SymbolVendor::GetPluginVersion() |
| 504 | { |
| 505 | return 1; |
| 506 | } |
| 507 | |