LLDB mainline
SymbolVendor.cpp
Go to the documentation of this file.
1//===-- SymbolVendor.cpp --------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10
11#include "lldb/Core/Module.h"
16#include "lldb/Utility/Stream.h"
17
18using namespace lldb;
19using namespace lldb_private;
20
21// FindPlugin
22//
23// Platforms can register a callback to use when creating symbol vendors to
24// allow for complex debug information file setups, and to also allow for
25// finding separate debug information files.
27 lldb_private::Stream *feedback_strm) {
28 std::unique_ptr<SymbolVendor> instance_up;
29 SymbolVendorCreateInstance create_callback;
30
31 for (size_t idx = 0;
33 idx)) != nullptr;
34 ++idx) {
35 instance_up.reset(create_callback(module_sp, feedback_strm));
36
37 if (instance_up) {
38 return instance_up.release();
39 }
40 }
41 // The default implementation just tries to create debug information using
42 // the file representation for the module.
43 ObjectFileSP sym_objfile_sp;
44 FileSpec sym_spec = module_sp->GetSymbolFileFileSpec();
45 if (sym_spec && sym_spec != module_sp->GetObjectFile()->GetFileSpec()) {
46 DataBufferSP data_sp;
47 offset_t data_offset = 0;
48 sym_objfile_sp = ObjectFile::FindPlugin(
49 module_sp, &sym_spec, 0, FileSystem::Instance().GetByteSize(sym_spec),
50 data_sp, data_offset);
51 }
52 if (!sym_objfile_sp)
53 sym_objfile_sp = module_sp->GetObjectFile()->shared_from_this();
54 instance_up = std::make_unique<SymbolVendor>(module_sp);
55 instance_up->AddSymbolFileRepresentation(sym_objfile_sp);
56 return instance_up.release();
57}
58
59// SymbolVendor constructor
61 : ModuleChild(module_sp), m_sym_file_up() {}
62
63// Add a representation given an object file.
65 ModuleSP module_sp(GetModule());
66 if (module_sp) {
67 std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
68 if (objfile_sp)
69 m_sym_file_up.reset(SymbolFile::FindPlugin(objfile_sp));
70 }
71}
A file utility class.
Definition: FileSpec.h:56
static FileSystem & Instance()
A mix in class that contains a pointer back to the module that owns the object which inherits from it...
Definition: ModuleChild.h:19
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
Definition: ModuleChild.cpp:24
static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataBufferSP &data_sp, lldb::offset_t &data_offset)
Find a ObjectFile plug-in that can parse file_spec.
Definition: ObjectFile.cpp:53
static SymbolVendorCreateInstance GetSymbolVendorCreateCallbackAtIndex(uint32_t idx)
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
static SymbolFile * FindPlugin(lldb::ObjectFileSP objfile_sp)
Definition: SymbolFile.cpp:40
void AddSymbolFileRepresentation(const lldb::ObjectFileSP &objfile_sp)
static SymbolVendor * FindPlugin(const lldb::ModuleSP &module_sp, Stream *feedback_strm)
std::unique_ptr< SymbolFile > m_sym_file_up
Definition: SymbolVendor.h:47
SymbolVendor(const lldb::ModuleSP &module_sp)
A class that represents a running process on the host machine.
SymbolVendor *(* SymbolVendorCreateInstance)(const lldb::ModuleSP &module_sp, lldb_private::Stream *feedback_strm)
Definition: SBAddress.h:15
uint64_t offset_t
Definition: lldb-types.h:85
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
Definition: lldb-forward.h:375
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
Definition: lldb-forward.h:336
std::shared_ptr< lldb_private::Module > ModuleSP
Definition: lldb-forward.h:373