diff options
author | emaste <emaste@FreeBSD.org> | 2013-08-23 18:06:42 +0000 |
---|---|---|
committer | emaste <emaste@FreeBSD.org> | 2013-08-23 18:06:42 +0000 |
commit | 424d4dadd208e2a1e9a43c3d55f47f03ba0c4509 (patch) | |
tree | 05d762b98a499804ce690e6ce04033f1ddf4dee6 /contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp | |
parent | cde487f27a84e02a560384f75178fddca68740f6 (diff) | |
parent | dcd15f81789e389c1cb27d264fcdddfd0a6002bd (diff) | |
download | FreeBSD-src-424d4dadd208e2a1e9a43c3d55f47f03ba0c4509.zip FreeBSD-src-424d4dadd208e2a1e9a43c3d55f47f03ba0c4509.tar.gz |
Merge lldb r188801 to contrib/llvm/tools/lldb/
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp b/contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp new file mode 100644 index 0000000..412c460 --- /dev/null +++ b/contrib/llvm/tools/lldb/source/Symbol/SymbolFile.cpp @@ -0,0 +1,89 @@ +//===-- SymbolFile.cpp ------------------------------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include "lldb/Symbol/SymbolFile.h" + +#include "lldb/lldb-private.h" +#include "lldb/Core/Log.h" +#include "lldb/Core/Module.h" +#include "lldb/Core/PluginManager.h" +#include "lldb/Core/StreamString.h" +#include "lldb/Symbol/ObjectFile.h" + +using namespace lldb_private; + +SymbolFile* +SymbolFile::FindPlugin (ObjectFile* obj_file) +{ + std::unique_ptr<SymbolFile> best_symfile_ap; + if (obj_file != NULL) + { + + // We need to test the abilities of this section list. So create what it would + // be with this new obj_file. + lldb::ModuleSP module_sp(obj_file->GetModule()); + if (module_sp) + { + // Default to the main module section list. + ObjectFile *module_obj_file = module_sp->GetObjectFile(); + if (module_obj_file != obj_file) + { + // Make sure the main object file's sections are created + module_obj_file->GetSectionList(); + obj_file->CreateSections (*module_sp->GetUnifiedSectionList()); + } + } + + // TODO: Load any plug-ins in the appropriate plug-in search paths and + // iterate over all of them to find the best one for the job. + + uint32_t best_symfile_abilities = 0; + + SymbolFileCreateInstance create_callback; + for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != NULL; ++idx) + { + std::unique_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file)); + + if (curr_symfile_ap.get()) + { + const uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities(); + if (sym_file_abilities > best_symfile_abilities) + { + best_symfile_abilities = sym_file_abilities; + best_symfile_ap.reset (curr_symfile_ap.release()); + // If any symbol file parser has all of the abilities, then + // we should just stop looking. + if ((kAllAbilities & sym_file_abilities) == kAllAbilities) + break; + } + } + } + if (best_symfile_ap.get()) + { + // Let the winning symbol file parser initialize itself more + // completely now that it has been chosen + best_symfile_ap->InitializeObject(); + } + } + return best_symfile_ap.release(); +} + +TypeList * +SymbolFile::GetTypeList () +{ + if (m_obj_file) + return m_obj_file->GetModule()->GetTypeList(); + return NULL; +} + +lldb_private::ClangASTContext & +SymbolFile::GetClangASTContext () +{ + return m_obj_file->GetModule()->GetClangASTContext(); +} |