blob: edfd56d3bd965df18f64d6e687bfd80e387f059a [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"
12#include "lldb/Core/PluginManager.h"
13
14using namespace lldb_private;
15
16SymbolFile*
17SymbolFile::FindPlugin (ObjectFile* obj_file)
18{
19 std::auto_ptr<SymbolFile> best_sym_file_ap;
20 if (obj_file != NULL)
21 {
22 // TODO: Load any plug-ins in the appropriate plug-in search paths and
23 // iterate over all of them to find the best one for the job.
24
25 //----------------------------------------------------------------------
26 // We currently only have one debug symbol parser...
27 //----------------------------------------------------------------------
28 std::auto_ptr<SymbolFile> best_symfile_ap;
29 uint32_t best_symfile_abilities = 0;
30
31 SymbolFileCreateInstance create_callback;
32 for (uint32_t idx = 0; (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(idx)) != NULL; ++idx)
33 {
34 std::auto_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file));
35
36 if (curr_symfile_ap.get())
37 {
38 uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities();
39 if (sym_file_abilities > best_symfile_abilities)
40 {
41 best_symfile_abilities = sym_file_abilities;
42 best_sym_file_ap = curr_symfile_ap;
43 }
44 }
45 }
46 }
47 return best_sym_file_ap.release();
48}
49
50