blob: 3f684a40cfa1f950b03bbb7bd58e1359b1d8fa47 [file] [log] [blame]
Chris Lattner24943d22010-06-08 16:52:24 +00001//===-- 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 Claytone98ac252010-11-10 04:57:04 +000012#include "lldb/Core/Module.h"
Chris Lattner24943d22010-06-08 16:52:24 +000013#include "lldb/Core/PluginManager.h"
Greg Claytone98ac252010-11-10 04:57:04 +000014#include "lldb/Symbol/ObjectFile.h"
Chris Lattner24943d22010-06-08 16:52:24 +000015
16using namespace lldb_private;
17
18SymbolFile*
19SymbolFile::FindPlugin (ObjectFile* obj_file)
20{
21 std::auto_ptr<SymbolFile> best_sym_file_ap;
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 //----------------------------------------------------------------------
30 std::auto_ptr<SymbolFile> best_symfile_ap;
31 uint32_t best_symfile_abilities = 0;
32
33 SymbolFileCreateInstance create_callback;
34 for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != NULL; ++idx)
35 {
36 std::auto_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file));
37
38 if (curr_symfile_ap.get())
39 {
40 uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities();
41 if (sym_file_abilities > best_symfile_abilities)
42 {
43 best_symfile_abilities = sym_file_abilities;
44 best_sym_file_ap = curr_symfile_ap;
45 }
46 }
47 }
48 }
49 return best_sym_file_ap.release();
50}
51
Greg Claytone98ac252010-11-10 04:57:04 +000052TypeList *
53SymbolFile::GetTypeList ()
54{
55 return m_obj_file->GetModule()->GetTypeList();
56}