blob: b361d400f228b6a2e83dafb3b900c0a70b55d026 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- SymbolVendor.mm -----------------------------------------*- 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/Symbol/SymbolVendor.h"
11
12// C Includes
13// C++ Includes
14// Other libraries and framework includes
15// Project includes
16#include "lldb/Core/Module.h"
17#include "lldb/Core/PluginManager.h"
Greg Clayton1f746072012-08-29 21:13:06 +000018#include "lldb/Core/Stream.h"
19#include "lldb/Symbol/CompileUnit.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020#include "lldb/Symbol/ObjectFile.h"
21#include "lldb/Symbol/SymbolFile.h"
22
23using namespace lldb;
24using namespace lldb_private;
25
26
27//----------------------------------------------------------------------
28// FindPlugin
29//
30// Platforms can register a callback to use when creating symbol
31// vendors to allow for complex debug information file setups, and to
32// also allow for finding separate debug information files.
33//----------------------------------------------------------------------
34SymbolVendor*
Greg Clayton136dff82012-12-14 02:15:00 +000035SymbolVendor::FindPlugin (const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000036{
Greg Clayton7b0992d2013-04-18 22:45:39 +000037 std::unique_ptr<SymbolVendor> instance_ap;
Chris Lattner30fdc8d2010-06-08 16:52:24 +000038 SymbolVendorCreateInstance create_callback;
Michael Sartaina7499c92013-07-01 19:45:50 +000039
Ed Masted4612ad2014-04-20 13:17:36 +000040 for (size_t idx = 0; (create_callback = PluginManager::GetSymbolVendorCreateCallbackAtIndex(idx)) != nullptr; ++idx)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000041 {
Greg Clayton136dff82012-12-14 02:15:00 +000042 instance_ap.reset(create_callback(module_sp, feedback_strm));
Chris Lattner30fdc8d2010-06-08 16:52:24 +000043
44 if (instance_ap.get())
45 {
Chris Lattner30fdc8d2010-06-08 16:52:24 +000046 return instance_ap.release();
47 }
48 }
49 // The default implementation just tries to create debug information using the
50 // file representation for the module.
Greg Claytone72dfb32012-02-24 01:59:29 +000051 instance_ap.reset(new SymbolVendor(module_sp));
Chris Lattner30fdc8d2010-06-08 16:52:24 +000052 if (instance_ap.get())
Greg Clayton762f7132011-09-18 18:59:15 +000053 {
Greg Claytone72dfb32012-02-24 01:59:29 +000054 ObjectFile *objfile = module_sp->GetObjectFile();
Greg Clayton762f7132011-09-18 18:59:15 +000055 if (objfile)
Greg Claytone1cd1be2012-01-29 20:56:30 +000056 instance_ap->AddSymbolFileRepresentation(objfile->shared_from_this());
Greg Clayton762f7132011-09-18 18:59:15 +000057 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000058 return instance_ap.release();
59}
60
61//----------------------------------------------------------------------
62// SymbolVendor constructor
63//----------------------------------------------------------------------
Greg Claytone72dfb32012-02-24 01:59:29 +000064SymbolVendor::SymbolVendor(const lldb::ModuleSP &module_sp) :
65 ModuleChild (module_sp),
Chris Lattner30fdc8d2010-06-08 16:52:24 +000066 m_type_list(),
67 m_compile_units(),
68 m_sym_file_ap()
69{
Chris Lattner30fdc8d2010-06-08 16:52:24 +000070}
71
72//----------------------------------------------------------------------
73// Destructor
74//----------------------------------------------------------------------
75SymbolVendor::~SymbolVendor()
76{
77}
78
79//----------------------------------------------------------------------
Bruce Mitchenere171da52015-07-22 00:16:02 +000080// Add a representation given an object file.
Chris Lattner30fdc8d2010-06-08 16:52:24 +000081//----------------------------------------------------------------------
82void
Jim Ingham7d1c1152011-12-06 01:07:22 +000083SymbolVendor::AddSymbolFileRepresentation(const ObjectFileSP &objfile_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000084{
Greg Claytona1743492012-03-13 23:14:29 +000085 ModuleSP module_sp(GetModule());
86 if (module_sp)
Greg Clayton762f7132011-09-18 18:59:15 +000087 {
Greg Claytona1743492012-03-13 23:14:29 +000088 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
89 if (objfile_sp)
90 {
91 m_objfile_sp = objfile_sp;
92 m_sym_file_ap.reset(SymbolFile::FindPlugin(objfile_sp.get()));
93 }
Greg Clayton762f7132011-09-18 18:59:15 +000094 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000095}
96
97bool
Greg Claytonc7bece562013-01-25 18:06:21 +000098SymbolVendor::SetCompileUnitAtIndex (size_t idx, const CompUnitSP &cu_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +000099{
Greg Claytona1743492012-03-13 23:14:29 +0000100 ModuleSP module_sp(GetModule());
101 if (module_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000102 {
Greg Claytona1743492012-03-13 23:14:29 +0000103 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
Greg Claytonc7bece562013-01-25 18:06:21 +0000104 const size_t num_compile_units = GetNumCompileUnits();
Greg Claytona1743492012-03-13 23:14:29 +0000105 if (idx < num_compile_units)
106 {
107 // Fire off an assertion if this compile unit already exists for now.
108 // The partial parsing should take care of only setting the compile
109 // unit once, so if this assertion fails, we need to make sure that
110 // we don't have a race condition, or have a second parse of the same
111 // compile unit.
Ed Masted4612ad2014-04-20 13:17:36 +0000112 assert(m_compile_units[idx].get() == nullptr);
Greg Clayton53eb1c22012-04-02 22:59:12 +0000113 m_compile_units[idx] = cu_sp;
Greg Claytona1743492012-03-13 23:14:29 +0000114 return true;
115 }
Greg Clayton53eb1c22012-04-02 22:59:12 +0000116 else
117 {
118 // This should NOT happen, and if it does, we want to crash and know
119 // about it
120 assert (idx < num_compile_units);
121 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000122 }
123 return false;
124}
125
Greg Claytonc7bece562013-01-25 18:06:21 +0000126size_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000127SymbolVendor::GetNumCompileUnits()
128{
Greg Claytona1743492012-03-13 23:14:29 +0000129 ModuleSP module_sp(GetModule());
130 if (module_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000131 {
Greg Claytona1743492012-03-13 23:14:29 +0000132 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
133 if (m_compile_units.empty())
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000134 {
Greg Claytona1743492012-03-13 23:14:29 +0000135 if (m_sym_file_ap.get())
136 {
137 // Resize our array of compile unit shared pointers -- which will
138 // each remain NULL until someone asks for the actual compile unit
139 // information. When this happens, the symbol file will be asked
140 // to parse this compile unit information.
141 m_compile_units.resize(m_sym_file_ap->GetNumCompileUnits());
142 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000143 }
144 }
145 return m_compile_units.size();
146}
147
Greg Clayton1f746072012-08-29 21:13:06 +0000148lldb::LanguageType
149SymbolVendor::ParseCompileUnitLanguage (const SymbolContext& sc)
150{
151 ModuleSP module_sp(GetModule());
152 if (module_sp)
153 {
154 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
155 if (m_sym_file_ap.get())
156 return m_sym_file_ap->ParseCompileUnitLanguage(sc);
157 }
158 return eLanguageTypeUnknown;
159}
160
161
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000162size_t
163SymbolVendor::ParseCompileUnitFunctions (const SymbolContext &sc)
164{
Greg Claytona1743492012-03-13 23:14:29 +0000165 ModuleSP module_sp(GetModule());
166 if (module_sp)
167 {
168 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
169 if (m_sym_file_ap.get())
170 return m_sym_file_ap->ParseCompileUnitFunctions(sc);
171 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000172 return 0;
173}
174
175bool
176SymbolVendor::ParseCompileUnitLineTable (const SymbolContext &sc)
177{
Greg Claytona1743492012-03-13 23:14:29 +0000178 ModuleSP module_sp(GetModule());
179 if (module_sp)
180 {
181 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
182 if (m_sym_file_ap.get())
183 return m_sym_file_ap->ParseCompileUnitLineTable(sc);
184 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000185 return false;
186}
187
188bool
189SymbolVendor::ParseCompileUnitSupportFiles (const SymbolContext& sc, FileSpecList& support_files)
190{
Greg Claytona1743492012-03-13 23:14:29 +0000191 ModuleSP module_sp(GetModule());
192 if (module_sp)
193 {
194 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
195 if (m_sym_file_ap.get())
196 return m_sym_file_ap->ParseCompileUnitSupportFiles(sc, support_files);
197 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000198 return false;
199}
200
Sean Callananf0c5aeb2015-04-20 16:31:29 +0000201bool
202SymbolVendor::ParseImportedModules (const SymbolContext &sc,
203 std::vector<ConstString> &imported_modules)
204{
205 ModuleSP module_sp(GetModule());
206 if (module_sp)
207 {
208 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
209 if (m_sym_file_ap.get())
210 return m_sym_file_ap->ParseImportedModules(sc, imported_modules);
211 }
212 return false;
213
214}
215
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000216size_t
217SymbolVendor::ParseFunctionBlocks (const SymbolContext &sc)
218{
Greg Claytona1743492012-03-13 23:14:29 +0000219 ModuleSP module_sp(GetModule());
220 if (module_sp)
221 {
222 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
223 if (m_sym_file_ap.get())
224 return m_sym_file_ap->ParseFunctionBlocks(sc);
225 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000226 return 0;
227}
228
229size_t
230SymbolVendor::ParseTypes (const SymbolContext &sc)
231{
Greg Claytona1743492012-03-13 23:14:29 +0000232 ModuleSP module_sp(GetModule());
233 if (module_sp)
234 {
235 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
236 if (m_sym_file_ap.get())
237 return m_sym_file_ap->ParseTypes(sc);
238 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000239 return 0;
240}
241
242size_t
243SymbolVendor::ParseVariablesForContext (const SymbolContext& sc)
244{
Greg Claytona1743492012-03-13 23:14:29 +0000245 ModuleSP module_sp(GetModule());
246 if (module_sp)
247 {
248 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
249 if (m_sym_file_ap.get())
250 return m_sym_file_ap->ParseVariablesForContext(sc);
251 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000252 return 0;
253}
254
255Type*
256SymbolVendor::ResolveTypeUID(lldb::user_id_t type_uid)
257{
Greg Claytona1743492012-03-13 23:14:29 +0000258 ModuleSP module_sp(GetModule());
259 if (module_sp)
260 {
261 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
262 if (m_sym_file_ap.get())
263 return m_sym_file_ap->ResolveTypeUID(type_uid);
264 }
Ed Masted4612ad2014-04-20 13:17:36 +0000265 return nullptr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000266}
267
268
269uint32_t
270SymbolVendor::ResolveSymbolContext (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc)
271{
Greg Claytona1743492012-03-13 23:14:29 +0000272 ModuleSP module_sp(GetModule());
273 if (module_sp)
274 {
275 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
276 if (m_sym_file_ap.get())
277 return m_sym_file_ap->ResolveSymbolContext(so_addr, resolve_scope, sc);
278 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000279 return 0;
280}
281
282uint32_t
283SymbolVendor::ResolveSymbolContext (const FileSpec& file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list)
284{
Greg Claytona1743492012-03-13 23:14:29 +0000285 ModuleSP module_sp(GetModule());
286 if (module_sp)
287 {
288 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
289 if (m_sym_file_ap.get())
290 return m_sym_file_ap->ResolveSymbolContext(file_spec, line, check_inlines, resolve_scope, sc_list);
291 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000292 return 0;
293}
294
Greg Claytonc7bece562013-01-25 18:06:21 +0000295size_t
Greg Clayton99558cc42015-08-24 23:46:31 +0000296SymbolVendor::FindGlobalVariables (const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, VariableList& variables)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000297{
Greg Claytona1743492012-03-13 23:14:29 +0000298 ModuleSP module_sp(GetModule());
299 if (module_sp)
300 {
301 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
302 if (m_sym_file_ap.get())
Greg Clayton99558cc42015-08-24 23:46:31 +0000303 return m_sym_file_ap->FindGlobalVariables(name, parent_decl_ctx, append, max_matches, variables);
Greg Claytona1743492012-03-13 23:14:29 +0000304 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000305 return 0;
306}
307
Greg Claytonc7bece562013-01-25 18:06:21 +0000308size_t
309SymbolVendor::FindGlobalVariables (const RegularExpression& regex, bool append, size_t max_matches, VariableList& variables)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000310{
Greg Claytona1743492012-03-13 23:14:29 +0000311 ModuleSP module_sp(GetModule());
312 if (module_sp)
313 {
314 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
315 if (m_sym_file_ap.get())
316 return m_sym_file_ap->FindGlobalVariables(regex, append, max_matches, variables);
317 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000318 return 0;
319}
320
Greg Claytonc7bece562013-01-25 18:06:21 +0000321size_t
Greg Clayton99558cc42015-08-24 23:46:31 +0000322SymbolVendor::FindFunctions(const ConstString &name, const CompilerDeclContext *parent_decl_ctx, uint32_t name_type_mask, bool include_inlines, bool append, SymbolContextList& sc_list)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000323{
Greg Claytona1743492012-03-13 23:14:29 +0000324 ModuleSP module_sp(GetModule());
325 if (module_sp)
326 {
327 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
328 if (m_sym_file_ap.get())
Greg Clayton99558cc42015-08-24 23:46:31 +0000329 return m_sym_file_ap->FindFunctions(name, parent_decl_ctx, name_type_mask, include_inlines, append, sc_list);
Greg Claytona1743492012-03-13 23:14:29 +0000330 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000331 return 0;
332}
333
Greg Claytonc7bece562013-01-25 18:06:21 +0000334size_t
Sean Callanan9df05fb2012-02-10 22:52:19 +0000335SymbolVendor::FindFunctions(const RegularExpression& regex, bool include_inlines, bool append, SymbolContextList& sc_list)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000336{
Greg Claytona1743492012-03-13 23:14:29 +0000337 ModuleSP module_sp(GetModule());
338 if (module_sp)
339 {
340 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
341 if (m_sym_file_ap.get())
342 return m_sym_file_ap->FindFunctions(regex, include_inlines, append, sc_list);
343 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000344 return 0;
345}
346
347
Greg Claytonc7bece562013-01-25 18:06:21 +0000348size_t
Ravitheja Addepally40697302015-10-08 09:45:41 +0000349SymbolVendor::FindTypes (const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx, bool append, size_t max_matches, TypeMap& types)
Greg Claytonb0b9fe62010-08-03 00:35:52 +0000350{
Greg Claytona1743492012-03-13 23:14:29 +0000351 ModuleSP module_sp(GetModule());
352 if (module_sp)
353 {
354 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
355 if (m_sym_file_ap.get())
Greg Clayton99558cc42015-08-24 23:46:31 +0000356 return m_sym_file_ap->FindTypes(sc, name, parent_decl_ctx, append, max_matches, types);
Greg Claytona1743492012-03-13 23:14:29 +0000357 }
Greg Claytonb0b9fe62010-08-03 00:35:52 +0000358 if (!append)
359 types.Clear();
360 return 0;
361}
Greg Clayton526e5af2010-11-13 03:52:47 +0000362
Greg Claytonf02500c2013-06-18 22:51:05 +0000363size_t
Greg Claytone6b36cd2015-12-08 01:02:08 +0000364SymbolVendor::FindTypes (const std::vector<CompilerContext> &context, bool append, TypeMap& types)
365{
366 ModuleSP module_sp(GetModule());
367 if (module_sp)
368 {
369 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
370 if (m_sym_file_ap.get())
371 return m_sym_file_ap->FindTypes(context, append, types);
372 }
373 if (!append)
374 types.Clear();
375 return 0;
376}
377
378size_t
Greg Claytonf02500c2013-06-18 22:51:05 +0000379SymbolVendor::GetTypes (SymbolContextScope *sc_scope,
380 uint32_t type_mask,
381 lldb_private::TypeList &type_list)
382{
383 ModuleSP module_sp(GetModule());
384 if (module_sp)
385 {
386 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
387 if (m_sym_file_ap.get())
388 return m_sym_file_ap->GetTypes (sc_scope, type_mask, type_list);
389 }
390 return 0;
391}
392
Greg Clayton99558cc42015-08-24 23:46:31 +0000393CompilerDeclContext
394SymbolVendor::FindNamespace(const SymbolContext& sc, const ConstString &name, const CompilerDeclContext *parent_decl_ctx)
Greg Clayton526e5af2010-11-13 03:52:47 +0000395{
Greg Clayton99558cc42015-08-24 23:46:31 +0000396 CompilerDeclContext namespace_decl_ctx;
Greg Claytona1743492012-03-13 23:14:29 +0000397 ModuleSP module_sp(GetModule());
398 if (module_sp)
399 {
400 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
401 if (m_sym_file_ap.get())
Greg Clayton99558cc42015-08-24 23:46:31 +0000402 namespace_decl_ctx = m_sym_file_ap->FindNamespace (sc, name, parent_decl_ctx);
Greg Claytona1743492012-03-13 23:14:29 +0000403 }
Greg Clayton99558cc42015-08-24 23:46:31 +0000404 return namespace_decl_ctx;
Greg Clayton526e5af2010-11-13 03:52:47 +0000405}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000406
407void
408SymbolVendor::Dump(Stream *s)
409{
Greg Claytona1743492012-03-13 23:14:29 +0000410 ModuleSP module_sp(GetModule());
411 if (module_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000412 {
Greg Clayton50bd5a22015-04-14 22:34:00 +0000413 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
414
Greg Claytona1743492012-03-13 23:14:29 +0000415 bool show_context = false;
416
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000417 s->Printf("%p: ", static_cast<void*>(this));
Greg Claytona1743492012-03-13 23:14:29 +0000418 s->Indent();
419 s->PutCString("SymbolVendor");
420 if (m_sym_file_ap.get())
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000421 {
Greg Claytona1743492012-03-13 23:14:29 +0000422 ObjectFile *objfile = m_sym_file_ap->GetObjectFile();
423 if (objfile)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000424 {
Greg Claytona1743492012-03-13 23:14:29 +0000425 const FileSpec &objfile_file_spec = objfile->GetFileSpec();
426 if (objfile_file_spec)
427 {
428 s->PutCString(" (");
429 objfile_file_spec.Dump(s);
430 s->PutChar(')');
431 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000432 }
433 }
Greg Claytona1743492012-03-13 23:14:29 +0000434 s->EOL();
435 s->IndentMore();
436 m_type_list.Dump(s, show_context);
437
438 CompileUnitConstIter cu_pos, cu_end;
439 cu_end = m_compile_units.end();
440 for (cu_pos = m_compile_units.begin(); cu_pos != cu_end; ++cu_pos)
441 {
442 // We currently only dump the compile units that have been parsed
443 if (cu_pos->get())
444 (*cu_pos)->Dump(s, show_context);
445 }
446
447 s->IndentLess();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000448 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000449}
450
451CompUnitSP
Greg Claytonc7bece562013-01-25 18:06:21 +0000452SymbolVendor::GetCompileUnitAtIndex(size_t idx)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000453{
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000454 CompUnitSP cu_sp;
Greg Claytona1743492012-03-13 23:14:29 +0000455 ModuleSP module_sp(GetModule());
456 if (module_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000457 {
Greg Clayton50bd5a22015-04-14 22:34:00 +0000458 lldb_private::Mutex::Locker locker(module_sp->GetMutex());
Greg Claytonc7bece562013-01-25 18:06:21 +0000459 const size_t num_compile_units = GetNumCompileUnits();
Greg Claytona1743492012-03-13 23:14:29 +0000460 if (idx < num_compile_units)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000461 {
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000462 cu_sp = m_compile_units[idx];
Ed Masted4612ad2014-04-20 13:17:36 +0000463 if (cu_sp.get() == nullptr)
Greg Claytona1743492012-03-13 23:14:29 +0000464 {
465 m_compile_units[idx] = m_sym_file_ap->ParseCompileUnitAtIndex(idx);
466 cu_sp = m_compile_units[idx];
467 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000468 }
469 }
470 return cu_sp;
471}
472
Ilia Ke912e3e2015-03-10 21:18:59 +0000473FileSpec
474SymbolVendor::GetMainFileSpec() const
475{
476 if (m_sym_file_ap.get())
477 {
478 const ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile();
479 if (symfile_objfile)
480 return symfile_objfile->GetFileSpec();
481 }
482
483 return FileSpec();
484}
485
Michael Sartaina7499c92013-07-01 19:45:50 +0000486Symtab *
487SymbolVendor::GetSymtab ()
488{
489 ModuleSP module_sp(GetModule());
490 if (module_sp)
491 {
492 ObjectFile *objfile = module_sp->GetObjectFile();
493 if (objfile)
494 {
495 // Get symbol table from unified section list.
Greg Clayton3046e662013-07-10 01:23:25 +0000496 return objfile->GetSymtab ();
Michael Sartaina7499c92013-07-01 19:45:50 +0000497 }
498 }
Ed Masted4612ad2014-04-20 13:17:36 +0000499 return nullptr;
Michael Sartaina7499c92013-07-01 19:45:50 +0000500}
501
502void
503SymbolVendor::ClearSymtab()
504{
505 ModuleSP module_sp(GetModule());
506 if (module_sp)
507 {
508 ObjectFile *objfile = module_sp->GetObjectFile();
509 if (objfile)
510 {
511 // Clear symbol table from unified section list.
Greg Clayton3046e662013-07-10 01:23:25 +0000512 objfile->ClearSymtab ();
Michael Sartaina7499c92013-07-01 19:45:50 +0000513 }
514 }
515}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000516
Jason Molenda05a09c62014-08-22 02:46:46 +0000517void
518SymbolVendor::SectionFileAddressesChanged ()
519{
520 ModuleSP module_sp(GetModule());
521 if (module_sp)
522 {
523 ObjectFile *module_objfile = module_sp->GetObjectFile ();
524 if (m_sym_file_ap.get())
525 {
526 ObjectFile *symfile_objfile = m_sym_file_ap->GetObjectFile ();
527 if (symfile_objfile != module_objfile)
528 symfile_objfile->SectionFileAddressesChanged ();
529 }
530 Symtab *symtab = GetSymtab ();
531 if (symtab)
532 {
533 symtab->SectionFileAddressesChanged ();
534 }
535 }
536}
537
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000538//------------------------------------------------------------------
539// PluginInterface protocol
540//------------------------------------------------------------------
Greg Clayton57abc5d2013-05-10 21:47:16 +0000541lldb_private::ConstString
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000542SymbolVendor::GetPluginName()
543{
Greg Clayton57abc5d2013-05-10 21:47:16 +0000544 static ConstString g_name("vendor-default");
545 return g_name;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000546}
547
548uint32_t
549SymbolVendor::GetPluginVersion()
550{
551 return 1;
552}
553