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