blob: d7898919f45e419d3f4d6968f652ddaf0a66fb29 [file] [log] [blame]
Chris Lattner30fdc8d2010-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
Chris Lattner30fdc8d2010-06-08 16:52:24 +000010#include "lldb/Symbol/SymbolFile.h"
Greg Claytonc982b3d2011-11-28 01:45:00 +000011
Greg Clayton2d95dc9b2010-11-10 04:57:04 +000012#include "lldb/Core/Module.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000013#include "lldb/Core/PluginManager.h"
Greg Clayton2d95dc9b2010-11-10 04:57:04 +000014#include "lldb/Symbol/ObjectFile.h"
Ravitheja Addepally40697302015-10-08 09:45:41 +000015#include "lldb/Symbol/TypeMap.h"
Greg Clayton56939cb2015-09-17 22:23:34 +000016#include "lldb/Symbol/TypeSystem.h"
Greg Clayton99558cc42015-08-24 23:46:31 +000017#include "lldb/Symbol/VariableList.h"
Zachary Turner6f9e6902017-03-03 20:56:28 +000018#include "lldb/Utility/Log.h"
Zachary Turnerbf9a7732017-02-02 21:39:50 +000019#include "lldb/Utility/StreamString.h"
Kate Stoneb9c1b512016-09-06 20:57:50 +000020#include "lldb/lldb-private.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000021
22using namespace lldb_private;
23
Kate Stoneb9c1b512016-09-06 20:57:50 +000024SymbolFile *SymbolFile::FindPlugin(ObjectFile *obj_file) {
25 std::unique_ptr<SymbolFile> best_symfile_ap;
26 if (obj_file != nullptr) {
Greg Clayton3046e662013-07-10 01:23:25 +000027
Kate Stoneb9c1b512016-09-06 20:57:50 +000028 // We need to test the abilities of this section list. So create what it
29 // would
30 // be with this new obj_file.
31 lldb::ModuleSP module_sp(obj_file->GetModule());
32 if (module_sp) {
33 // Default to the main module section list.
34 ObjectFile *module_obj_file = module_sp->GetObjectFile();
35 if (module_obj_file != obj_file) {
36 // Make sure the main object file's sections are created
37 module_obj_file->GetSectionList();
38 obj_file->CreateSections(*module_sp->GetUnifiedSectionList());
39 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000040 }
Kate Stoneb9c1b512016-09-06 20:57:50 +000041
42 // TODO: Load any plug-ins in the appropriate plug-in search paths and
43 // iterate over all of them to find the best one for the job.
44
45 uint32_t best_symfile_abilities = 0;
46
47 SymbolFileCreateInstance create_callback;
48 for (uint32_t idx = 0;
49 (create_callback = PluginManager::GetSymbolFileCreateCallbackAtIndex(
50 idx)) != nullptr;
51 ++idx) {
52 std::unique_ptr<SymbolFile> curr_symfile_ap(create_callback(obj_file));
53
54 if (curr_symfile_ap.get()) {
55 const uint32_t sym_file_abilities = curr_symfile_ap->GetAbilities();
56 if (sym_file_abilities > best_symfile_abilities) {
57 best_symfile_abilities = sym_file_abilities;
58 best_symfile_ap.reset(curr_symfile_ap.release());
59 // If any symbol file parser has all of the abilities, then
60 // we should just stop looking.
61 if ((kAllAbilities & sym_file_abilities) == kAllAbilities)
62 break;
63 }
64 }
65 }
66 if (best_symfile_ap.get()) {
67 // Let the winning symbol file parser initialize itself more
68 // completely now that it has been chosen
69 best_symfile_ap->InitializeObject();
70 }
71 }
72 return best_symfile_ap.release();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000073}
74
Kate Stoneb9c1b512016-09-06 20:57:50 +000075TypeList *SymbolFile::GetTypeList() {
76 if (m_obj_file)
77 return m_obj_file->GetModule()->GetTypeList();
78 return nullptr;
Greg Clayton2d95dc9b2010-11-10 04:57:04 +000079}
Greg Clayton6beaaa62011-01-17 03:46:26 +000080
Kate Stoneb9c1b512016-09-06 20:57:50 +000081TypeSystem *SymbolFile::GetTypeSystemForLanguage(lldb::LanguageType language) {
82 TypeSystem *type_system =
83 m_obj_file->GetModule()->GetTypeSystemForLanguage(language);
84 if (type_system)
85 type_system->SetSymbolFile(this);
86 return type_system;
Greg Clayton8b4edba2015-08-14 20:02:05 +000087}
88
Kate Stoneb9c1b512016-09-06 20:57:50 +000089uint32_t SymbolFile::ResolveSymbolContext(const FileSpec &file_spec,
90 uint32_t line, bool check_inlines,
91 uint32_t resolve_scope,
92 SymbolContextList &sc_list) {
93 return 0;
Greg Clayton99558cc42015-08-24 23:46:31 +000094}
95
Kate Stoneb9c1b512016-09-06 20:57:50 +000096uint32_t SymbolFile::FindGlobalVariables(
97 const ConstString &name, const CompilerDeclContext *parent_decl_ctx,
98 bool append, uint32_t max_matches, VariableList &variables) {
99 if (!append)
100 variables.Clear();
101 return 0;
Greg Clayton99558cc42015-08-24 23:46:31 +0000102}
103
Kate Stoneb9c1b512016-09-06 20:57:50 +0000104uint32_t SymbolFile::FindGlobalVariables(const RegularExpression &regex,
105 bool append, uint32_t max_matches,
106 VariableList &variables) {
107 if (!append)
108 variables.Clear();
109 return 0;
Greg Clayton99558cc42015-08-24 23:46:31 +0000110}
111
Kate Stoneb9c1b512016-09-06 20:57:50 +0000112uint32_t SymbolFile::FindFunctions(const ConstString &name,
113 const CompilerDeclContext *parent_decl_ctx,
114 uint32_t name_type_mask,
115 bool include_inlines, bool append,
116 SymbolContextList &sc_list) {
117 if (!append)
118 sc_list.Clear();
119 return 0;
Greg Clayton99558cc42015-08-24 23:46:31 +0000120}
121
Kate Stoneb9c1b512016-09-06 20:57:50 +0000122uint32_t SymbolFile::FindFunctions(const RegularExpression &regex,
123 bool include_inlines, bool append,
124 SymbolContextList &sc_list) {
125 if (!append)
126 sc_list.Clear();
127 return 0;
Greg Clayton99558cc42015-08-24 23:46:31 +0000128}
129
Kate Stoneb9c1b512016-09-06 20:57:50 +0000130void SymbolFile::GetMangledNamesForFunction(
131 const std::string &scope_qualified_name,
132 std::vector<ConstString> &mangled_names) {
133 return;
Siva Chandra9293fc42016-01-07 23:32:34 +0000134}
135
Kate Stoneb9c1b512016-09-06 20:57:50 +0000136uint32_t SymbolFile::FindTypes(
137 const SymbolContext &sc, const ConstString &name,
138 const CompilerDeclContext *parent_decl_ctx, bool append,
139 uint32_t max_matches,
140 llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
141 TypeMap &types) {
142 if (!append)
143 types.Clear();
144 return 0;
Greg Clayton99558cc42015-08-24 23:46:31 +0000145}
146
Kate Stoneb9c1b512016-09-06 20:57:50 +0000147size_t SymbolFile::FindTypes(const std::vector<CompilerContext> &context,
148 bool append, TypeMap &types) {
149 if (!append)
150 types.Clear();
151 return 0;
Greg Claytone6b36cd2015-12-08 01:02:08 +0000152}