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
30 for (auto create_callback : PluginManager::GetSymbolVendorCreateCallbacks()) {
31 instance_up.reset(create_callback(module_sp, feedback_strm));
32
33 if (instance_up) {
34 return instance_up.release();
35 }
36 }
37 // The default implementation just tries to create debug information using
38 // the file representation for the module.
39 ObjectFileSP sym_objfile_sp;
40 FileSpec sym_spec = module_sp->GetSymbolFileFileSpec();
41 if (sym_spec && sym_spec != module_sp->GetObjectFile()->GetFileSpec()) {
42 DataExtractorSP extractor_sp;
43 offset_t data_offset = 0;
44 sym_objfile_sp = ObjectFile::FindPlugin(
45 module_sp, &sym_spec, 0, FileSystem::Instance().GetByteSize(sym_spec),
46 extractor_sp, data_offset);
47 }
48 if (!sym_objfile_sp)
49 sym_objfile_sp = module_sp->GetObjectFile()->shared_from_this();
50 instance_up = std::make_unique<SymbolVendor>(module_sp);
51 instance_up->AddSymbolFileRepresentation(sym_objfile_sp);
52 return instance_up.release();
53}
54
55// SymbolVendor constructor
58
59// Add a representation given an object file.
61 ModuleSP module_sp(GetModule());
62 if (module_sp) {
63 std::lock_guard<std::recursive_mutex> guard(module_sp->GetMutex());
64 if (objfile_sp)
65 m_sym_file_up.reset(SymbolFile::FindPlugin(objfile_sp));
66 }
67}
A file utility class.
Definition FileSpec.h:57
static FileSystem & Instance()
ModuleChild(const lldb::ModuleSP &module_sp)
Construct with owning module.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
static lldb::ObjectFileSP FindPlugin(const lldb::ModuleSP &module_sp, const FileSpec *file_spec, lldb::offset_t file_offset, lldb::offset_t file_size, lldb::DataExtractorSP extractor_sp, lldb::offset_t &data_offset)
Find a ObjectFile plug-in that can parse file_spec.
static llvm::SmallVector< SymbolVendorCreateInstance > GetSymbolVendorCreateCallbacks()
A stream class that can stream formatted output to a file.
Definition Stream.h:28
static SymbolFile * FindPlugin(lldb::ObjectFileSP objfile_sp)
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
SymbolVendor(const lldb::ModuleSP &module_sp)
A class that represents a running process on the host machine.
uint64_t offset_t
Definition lldb-types.h:85
std::shared_ptr< lldb_private::ObjectFile > ObjectFileSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP