| 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 | //---------------------------------------------------------------------- |
| 39 | // We currently only have one debug symbol parser... |
| 40 | //---------------------------------------------------------------------- |
| 41 | SymbolVendorCreateInstance create_callback; |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 42 | for (size_t idx = 0; (create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(idx)) != NULL; ++idx) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 43 | { |
| Greg Clayton | 136dff8 | 2012-12-14 02:15:00 +0000 | [diff] [blame] | 44 | instance_ap.reset(create_callback(module_sp, feedback_strm)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 45 | |
| 46 | if (instance_ap.get()) |
| 47 | { |
| 48 | // TODO: make sure this symbol vendor is what we want. We |
| 49 | // currently are just returning the first one we find, but |
| 50 | // we may want to call this function only when we have our |
| 51 | // main executable module and then give all symbol vendor |
| 52 | // plug-ins a chance to compete for who wins. |
| 53 | return instance_ap.release(); |
| 54 | } |
| 55 | } |
| 56 | // The default implementation just tries to create debug information using the |
| 57 | // file representation for the module. |
| Greg Clayton | e72dfb3 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 58 | instance_ap.reset(new SymbolVendor(module_sp)); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 59 | if (instance_ap.get()) |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 60 | { |
| Greg Clayton | e72dfb3 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 61 | ObjectFile *objfile = module_sp->GetObjectFile(); |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 62 | if (objfile) |
| Greg Clayton | e1cd1be | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 63 | instance_ap->AddSymbolFileRepresentation(objfile->shared_from_this()); |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 64 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 65 | return instance_ap.release(); |
| 66 | } |
| 67 | |
| 68 | //---------------------------------------------------------------------- |
| 69 | // SymbolVendor constructor |
| 70 | //---------------------------------------------------------------------- |
| Greg Clayton | e72dfb3 | 2012-02-24 01:59:29 +0000 | [diff] [blame] | 71 | SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp) : |
| 72 | ModuleChild (module_sp), |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 73 | m_type_list(), |
| 74 | m_compile_units(), |
| 75 | m_sym_file_ap() |
| 76 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | //---------------------------------------------------------------------- |
| 80 | // Destructor |
| 81 | //---------------------------------------------------------------------- |
| 82 | SymbolVendor::~SymbolVendor() |
| 83 | { |
| 84 | } |
| 85 | |
| 86 | //---------------------------------------------------------------------- |
| 87 | // Add a represantion given an object file. |
| 88 | //---------------------------------------------------------------------- |
| 89 | void |
| Jim Ingham | 7d1c115 | 2011-12-06 01:07:22 +0000 | [diff] [blame] | 90 | SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 91 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 92 | ModuleSP module_sp(GetModule()); |
| 93 | if (module_sp) |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 94 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 95 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 96 | if (objfile_sp) |
| 97 | { |
| 98 | m_objfile_sp = objfile_sp; |
| 99 | m_sym_file_ap.reset(SymbolFile::FindPlugin(objfile_sp.get())); |
| 100 | } |
| Greg Clayton | 762f713 | 2011-09-18 18:59:15 +0000 | [diff] [blame] | 101 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | bool |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 105 | SymbolVendor::SetCompileUnitAtIndex (size_t idx, const CompUnitSP &cu_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 106 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 107 | ModuleSP module_sp(GetModule()); |
| 108 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 109 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 110 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 111 | const size_t num_compile_units = GetNumCompileUnits(); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 112 | if (idx < num_compile_units) |
| 113 | { |
| 114 | // Fire off an assertion if this compile unit already exists for now. |
| 115 | // The partial parsing should take care of only setting the compile |
| 116 | // unit once, so if this assertion fails, we need to make sure that |
| 117 | // we don't have a race condition, or have a second parse of the same |
| 118 | // compile unit. |
| 119 | assert(m_compile_units[idx].get() == NULL); |
| Greg Clayton | 53eb1c2 | 2012-04-02 22:59:12 +0000 | [diff] [blame] | 120 | m_compile_units[idx] = cu_sp; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 121 | return true; |
| 122 | } |
| Greg Clayton | 53eb1c2 | 2012-04-02 22:59:12 +0000 | [diff] [blame] | 123 | else |
| 124 | { |
| 125 | // This should NOT happen, and if it does, we want to crash and know |
| 126 | // about it |
| 127 | assert (idx < num_compile_units); |
| 128 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 129 | } |
| 130 | return false; |
| 131 | } |
| 132 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 133 | size_t |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 134 | SymbolVendor::GetNumCompileUnits() |
| 135 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 136 | ModuleSP module_sp(GetModule()); |
| 137 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 138 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 139 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 140 | if (m_compile_units.empty()) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 141 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 142 | if (m_sym_file_ap.get()) |
| 143 | { |
| 144 | // Resize our array of compile unit shared pointers -- which will |
| 145 | // each remain NULL until someone asks for the actual compile unit |
| 146 | // information. When this happens, the symbol file will be asked |
| 147 | // to parse this compile unit information. |
| 148 | m_compile_units.resize(m_sym_file_ap->GetNumCompileUnits()); |
| 149 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 150 | } |
| 151 | } |
| 152 | return m_compile_units.size(); |
| 153 | } |
| 154 | |
| Greg Clayton | 1f74607 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 155 | lldb::LanguageType |
| 156 | SymbolVendor::ParseCompileUnitLanguage (const SymbolContext& sc) |
| 157 | { |
| 158 | ModuleSP module_sp(GetModule()); |
| 159 | if (module_sp) |
| 160 | { |
| 161 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 162 | if (m_sym_file_ap.get()) |
| 163 | return m_sym_file_ap->ParseCompileUnitLanguage(sc); |
| 164 | } |
| 165 | return eLanguageTypeUnknown; |
| 166 | } |
| 167 | |
| 168 | |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 169 | size_t |
| 170 | SymbolVendor::ParseCompileUnitFunctions (const SymbolContext &sc) |
| 171 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 172 | ModuleSP module_sp(GetModule()); |
| 173 | if (module_sp) |
| 174 | { |
| 175 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 176 | if (m_sym_file_ap.get()) |
| 177 | return m_sym_file_ap->ParseCompileUnitFunctions(sc); |
| 178 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 179 | return 0; |
| 180 | } |
| 181 | |
| 182 | bool |
| 183 | SymbolVendor::ParseCompileUnitLineTable (const SymbolContext &sc) |
| 184 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 185 | ModuleSP module_sp(GetModule()); |
| 186 | if (module_sp) |
| 187 | { |
| 188 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 189 | if (m_sym_file_ap.get()) |
| 190 | return m_sym_file_ap->ParseCompileUnitLineTable(sc); |
| 191 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 192 | return false; |
| 193 | } |
| 194 | |
| 195 | bool |
| 196 | SymbolVendor::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files) |
| 197 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 198 | ModuleSP module_sp(GetModule()); |
| 199 | if (module_sp) |
| 200 | { |
| 201 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 202 | if (m_sym_file_ap.get()) |
| 203 | return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files); |
| 204 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 205 | return false; |
| 206 | } |
| 207 | |
| 208 | size_t |
| 209 | SymbolVendor::ParseFunctionBlocks (const SymbolContext &sc) |
| 210 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 211 | ModuleSP module_sp(GetModule()); |
| 212 | if (module_sp) |
| 213 | { |
| 214 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 215 | if (m_sym_file_ap.get()) |
| 216 | return m_sym_file_ap->ParseFunctionBlocks(sc); |
| 217 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 218 | return 0; |
| 219 | } |
| 220 | |
| 221 | size_t |
| 222 | SymbolVendor::ParseTypes (const SymbolContext &sc) |
| 223 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 224 | ModuleSP module_sp(GetModule()); |
| 225 | if (module_sp) |
| 226 | { |
| 227 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 228 | if (m_sym_file_ap.get()) |
| 229 | return m_sym_file_ap->ParseTypes(sc); |
| 230 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 231 | return 0; |
| 232 | } |
| 233 | |
| 234 | size_t |
| 235 | SymbolVendor::ParseVariablesForContext (const SymbolContext& sc) |
| 236 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 237 | ModuleSP module_sp(GetModule()); |
| 238 | if (module_sp) |
| 239 | { |
| 240 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 241 | if (m_sym_file_ap.get()) |
| 242 | return m_sym_file_ap->ParseVariablesForContext(sc); |
| 243 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 244 | return 0; |
| 245 | } |
| 246 | |
| 247 | Type* |
| 248 | SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid) |
| 249 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 250 | ModuleSP module_sp(GetModule()); |
| 251 | if (module_sp) |
| 252 | { |
| 253 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 254 | if (m_sym_file_ap.get()) |
| 255 | return m_sym_file_ap->ResolveTypeUID(type_uid); |
| 256 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 257 | return NULL; |
| 258 | } |
| 259 | |
| 260 | |
| 261 | uint32_t |
| 262 | SymbolVendor::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc) |
| 263 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 264 | ModuleSP module_sp(GetModule()); |
| 265 | if (module_sp) |
| 266 | { |
| 267 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 268 | if (m_sym_file_ap.get()) |
| 269 | return m_sym_file_ap->ResolveSymbolContext(so_addr, resolve_scope, sc); |
| 270 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 271 | return 0; |
| 272 | } |
| 273 | |
| 274 | uint32_t |
| 275 | SymbolVendor::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list) |
| 276 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 277 | ModuleSP module_sp(GetModule()); |
| 278 | if (module_sp) |
| 279 | { |
| 280 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 281 | if (m_sym_file_ap.get()) |
| 282 | return m_sym_file_ap->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list); |
| 283 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 284 | return 0; |
| 285 | } |
| 286 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 287 | size_t |
| 288 | 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] | 289 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 290 | ModuleSP module_sp(GetModule()); |
| 291 | if (module_sp) |
| 292 | { |
| 293 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 294 | if (m_sym_file_ap.get()) |
| 295 | return m_sym_file_ap->FindGlobalVariables(name, namespace_decl, append, max_matches, variables); |
| 296 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 297 | return 0; |
| 298 | } |
| 299 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 300 | size_t |
| 301 | 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] | 302 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 303 | ModuleSP module_sp(GetModule()); |
| 304 | if (module_sp) |
| 305 | { |
| 306 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 307 | if (m_sym_file_ap.get()) |
| 308 | return m_sym_file_ap->FindGlobalVariables(regex, append, max_matches, variables); |
| 309 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 310 | return 0; |
| 311 | } |
| 312 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 313 | size_t |
| Sean Callanan | 9df05fb | 2012-02-10 22:52:19 +0000 | [diff] [blame] | 314 | 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] | 315 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 316 | ModuleSP module_sp(GetModule()); |
| 317 | if (module_sp) |
| 318 | { |
| 319 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 320 | if (m_sym_file_ap.get()) |
| 321 | return m_sym_file_ap->FindFunctions(name, namespace_decl, name_type_mask, include_inlines, append, sc_list); |
| 322 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 323 | return 0; |
| 324 | } |
| 325 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 326 | size_t |
| Sean Callanan | 9df05fb | 2012-02-10 22:52:19 +0000 | [diff] [blame] | 327 | 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] | 328 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 329 | ModuleSP module_sp(GetModule()); |
| 330 | if (module_sp) |
| 331 | { |
| 332 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 333 | if (m_sym_file_ap.get()) |
| 334 | return m_sym_file_ap->FindFunctions(regex, include_inlines, append, sc_list); |
| 335 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 336 | return 0; |
| 337 | } |
| 338 | |
| 339 | |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 340 | size_t |
| 341 | 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] | 342 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 343 | ModuleSP module_sp(GetModule()); |
| 344 | if (module_sp) |
| 345 | { |
| 346 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 347 | if (m_sym_file_ap.get()) |
| 348 | return m_sym_file_ap->FindTypes(sc, name, namespace_decl, append, max_matches, types); |
| 349 | } |
| Greg Clayton | b0b9fe6 | 2010-08-03 00:35:52 +0000 | [diff] [blame] | 350 | if (!append) |
| 351 | types.Clear(); |
| 352 | return 0; |
| 353 | } |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 354 | |
| Greg Clayton | f02500c | 2013-06-18 22:51:05 +0000 | [diff] [blame^] | 355 | size_t |
| 356 | SymbolVendor::GetTypes (SymbolContextScope *sc_scope, |
| 357 | uint32_t type_mask, |
| 358 | lldb_private::TypeList &type_list) |
| 359 | { |
| 360 | ModuleSP module_sp(GetModule()); |
| 361 | if (module_sp) |
| 362 | { |
| 363 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 364 | if (m_sym_file_ap.get()) |
| 365 | return m_sym_file_ap->GetTypes (sc_scope, type_mask, type_list); |
| 366 | } |
| 367 | return 0; |
| 368 | } |
| 369 | |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 370 | ClangNamespaceDecl |
| Sean Callanan | 213fdb8 | 2011-10-13 01:49:10 +0000 | [diff] [blame] | 371 | 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] | 372 | { |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 373 | ClangNamespaceDecl namespace_decl; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 374 | ModuleSP module_sp(GetModule()); |
| 375 | if (module_sp) |
| 376 | { |
| 377 | lldb_private::Mutex::Locker locker(module_sp->GetMutex()); |
| 378 | if (m_sym_file_ap.get()) |
| 379 | namespace_decl = m_sym_file_ap->FindNamespace (sc, name, parent_namespace_decl); |
| 380 | } |
| Greg Clayton | 526e5af | 2010-11-13 03:52:47 +0000 | [diff] [blame] | 381 | return namespace_decl; |
| 382 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 383 | |
| 384 | void |
| 385 | SymbolVendor::Dump(Stream *s) |
| 386 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 387 | ModuleSP module_sp(GetModule()); |
| 388 | if (module_sp) |
| 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 | bool show_context = false; |
| 391 | |
| 392 | s->Printf("%p: ", this); |
| 393 | s->Indent(); |
| 394 | s->PutCString("SymbolVendor"); |
| 395 | if (m_sym_file_ap.get()) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 396 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 397 | ObjectFile *objfile = m_sym_file_ap->GetObjectFile(); |
| 398 | if (objfile) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 399 | { |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 400 | const FileSpec &objfile_file_spec = objfile->GetFileSpec(); |
| 401 | if (objfile_file_spec) |
| 402 | { |
| 403 | s->PutCString(" ("); |
| 404 | objfile_file_spec.Dump(s); |
| 405 | s->PutChar(')'); |
| 406 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 407 | } |
| 408 | } |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 409 | s->EOL(); |
| 410 | s->IndentMore(); |
| 411 | m_type_list.Dump(s, show_context); |
| 412 | |
| 413 | CompileUnitConstIter cu_pos, cu_end; |
| 414 | cu_end = m_compile_units.end(); |
| 415 | for (cu_pos = m_compile_units.begin(); cu_pos != cu_end; ++cu_pos) |
| 416 | { |
| 417 | // We currently only dump the compile units that have been parsed |
| 418 | if (cu_pos->get()) |
| 419 | (*cu_pos)->Dump(s, show_context); |
| 420 | } |
| 421 | |
| 422 | s->IndentLess(); |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 423 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 424 | } |
| 425 | |
| 426 | CompUnitSP |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 427 | SymbolVendor::GetCompileUnitAtIndex(size_t idx) |
| 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 | CompUnitSP cu_sp; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 430 | ModuleSP module_sp(GetModule()); |
| 431 | if (module_sp) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 432 | { |
| Greg Clayton | c7bece56 | 2013-01-25 18:06:21 +0000 | [diff] [blame] | 433 | const size_t num_compile_units = GetNumCompileUnits(); |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 434 | if (idx < num_compile_units) |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 435 | { |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 436 | cu_sp = m_compile_units[idx]; |
| Greg Clayton | a174349 | 2012-03-13 23:14:29 +0000 | [diff] [blame] | 437 | if (cu_sp.get() == NULL) |
| 438 | { |
| 439 | m_compile_units[idx] = m_sym_file_ap->ParseCompileUnitAtIndex(idx); |
| 440 | cu_sp = m_compile_units[idx]; |
| 441 | } |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 442 | } |
| 443 | } |
| 444 | return cu_sp; |
| 445 | } |
| 446 | |
| 447 | |
| 448 | //------------------------------------------------------------------ |
| 449 | // PluginInterface protocol |
| 450 | //------------------------------------------------------------------ |
| Greg Clayton | 57abc5d | 2013-05-10 21:47:16 +0000 | [diff] [blame] | 451 | lldb_private::ConstString |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 452 | SymbolVendor::GetPluginName() |
| 453 | { |
| Greg Clayton | 57abc5d | 2013-05-10 21:47:16 +0000 | [diff] [blame] | 454 | static ConstString g_name("vendor-default"); |
| 455 | return g_name; |
| Chris Lattner | 30fdc8d | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | uint32_t |
| 459 | SymbolVendor::GetPluginVersion() |
| 460 | { |
| 461 | return 1; |
| 462 | } |
| 463 | |