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 10 #include "lldb/Symbol/SymbolFile.h" 11 12 #include "lldb/lldb-private.h" 13 #include "lldb/Core/Log.h" 14 #include "lldb/Core/Module.h" 15 #include "lldb/Core/PluginManager.h" 16 #include "lldb/Core/StreamString.h" 17 #include "lldb/Symbol/ObjectFile.h" 18 19 using namespace lldb_private; 20 21 SymbolFile* 22 SymbolFile::FindPlugin (ObjectFile* obj_file) 23 { 24 std::auto_ptr<SymbolFile> best_symfile_ap; 25 if (obj_file != NULL) 26 { 27 // TODO: Load any plug-ins in the appropriate plug-in search paths and 28 // iterate over all of them to find the best one for the job. 29 30 //---------------------------------------------------------------------- 31 // We currently only have one debug symbol parser... 32 //---------------------------------------------------------------------- 33 uint32_t best_symfile_abilities = 0; 34 35 SymbolFileCreateInstance create_callback; 36 for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != NULL; ++idx) 37 { 38 std::auto_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file)); 39 40 if (curr_symfile_ap.get()) 41 { 42 uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities(); 43 if (sym_file_abilities > best_symfile_abilities) 44 { 45 best_symfile_abilities = sym_file_abilities; 46 best_symfile_ap = curr_symfile_ap; 47 } 48 } 49 } 50 if (best_symfile_ap.get()) 51 { 52 // Let the winning symbol file parser initialize itself more 53 // completely now that it has been chosen 54 best_symfile_ap->InitializeObject(); 55 } 56 } 57 return best_symfile_ap.release(); 58 } 59 60 TypeList * 61 SymbolFile::GetTypeList () 62 { 63 if (m_obj_file) 64 return m_obj_file->GetModule()->GetTypeList(); 65 return NULL; 66 } 67 68 lldb_private::ClangASTContext & 69 SymbolFile::GetClangASTContext () 70 { 71 return m_obj_file->GetModule()->GetClangASTContext(); 72 } 73