1 //===-- SymbolFile.cpp ------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #include "lldb/Symbol/SymbolFile.h"
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"
19 using namespace lldb_private;
22 SymbolFile::FindPlugin (ObjectFile* obj_file)
24 std::unique_ptr<SymbolFile> best_symfile_ap;
28 // We need to test the abilities of this section list. So create what it would
29 // be with this new obj_file.
30 lldb::ModuleSP module_sp(obj_file->GetModule());
33 // Default to the main module section list.
34 ObjectFile *module_obj_file = module_sp->GetObjectFile();
35 if (module_obj_file != obj_file)
37 // Make sure the main object file's sections are created
38 module_obj_file->GetSectionList();
39 obj_file->CreateSections (*module_sp->GetUnifiedSectionList());
43 // TODO: Load any plug-ins in the appropriate plug-in search paths and
44 // iterate over all of them to find the best one for the job.
46 uint32_t best_symfile_abilities = 0;
48 SymbolFileCreateInstance create_callback;
49 for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != NULL; ++idx)
51 std::unique_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file));
53 if (curr_symfile_ap.get())
55 const uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities();
56 if (sym_file_abilities > best_symfile_abilities)
58 best_symfile_abilities = sym_file_abilities;
59 best_symfile_ap.reset (curr_symfile_ap.release());
60 // If any symbol file parser has all of the abilities, then
61 // we should just stop looking.
62 if ((kAllAbilities & sym_file_abilities) == kAllAbilities)
67 if (best_symfile_ap.get())
69 // Let the winning symbol file parser initialize itself more
70 // completely now that it has been chosen
71 best_symfile_ap->InitializeObject();
74 return best_symfile_ap.release();
78 SymbolFile::GetTypeList ()
81 return m_obj_file->GetModule()->GetTypeList();
85 lldb_private::ClangASTContext &
86 SymbolFile::GetClangASTContext ()
88 return m_obj_file->GetModule()->GetClangASTContext();