15#include "llvm/BinaryFormat/Magic.h"
16#include "llvm/DebugInfo/PDB/Native/DbiStream.h"
17#include "llvm/DebugInfo/PDB/Native/InfoStream.h"
18#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
19#include "llvm/DebugInfo/PDB/Native/PDBFile.h"
20#include "llvm/DebugInfo/PDB/PDB.h"
21#include "llvm/Support/BinaryByteStream.h"
32 memcpy(&debug_info.
Uuid, IS.getGuid().Guid,
sizeof(debug_info.
Uuid));
33 debug_info.
Age = DS.getAge();
34 return UUID(debug_info);
50 auto dbi_stream =
m_file_up->getPDBDbiStream();
52 llvm::consumeError(dbi_stream.takeError());
56 PDB_Machine machine = dbi_stream->getMachineType();
60 case PDB_Machine::Amd64:
61 case PDB_Machine::x86:
62 case PDB_Machine::PowerPC:
63 case PDB_Machine::PowerPCFP:
64 case PDB_Machine::Arm:
65 case PDB_Machine::ArmNT:
66 case PDB_Machine::Thumb:
67 case PDB_Machine::Arm64:
80 auto info_stream =
m_file_up->getPDBInfoStream();
82 llvm::consumeError(info_stream.takeError());
85 auto dbi_stream =
m_file_up->getPDBDbiStream();
87 llvm::consumeError(dbi_stream.takeError());
100 auto objfile_up = std::make_unique<ObjectFilePDB>(
101 module_sp, extractor_sp, data_offset, file, file_offset, length);
102 if (!objfile_up->initPDBFile())
104 return objfile_up.release();
117 const size_t initial_count = specs.
GetSize();
119 llvm::BumpPtrAllocator allocator;
122 return initial_count;
124 auto info_stream = pdb_file->getPDBInfoStream();
126 llvm::consumeError(info_stream.takeError());
127 return initial_count;
129 auto dbi_stream = pdb_file->getPDBDbiStream();
131 llvm::consumeError(dbi_stream.takeError());
132 return initial_count;
139 switch (dbi_stream->getMachineType()) {
140 case PDB_Machine::Amd64:
141 module_arch.
SetTriple(
"x86_64-pc-windows");
142 specs.
Append(module_spec);
144 case PDB_Machine::x86:
145 module_arch.
SetTriple(
"i386-pc-windows");
146 specs.
Append(module_spec);
148 case PDB_Machine::ArmNT:
149 module_arch.
SetTriple(
"armv7-pc-windows");
150 specs.
Append(module_spec);
152 case PDB_Machine::Arm64:
153 module_arch.
SetTriple(
"aarch64-pc-windows");
154 specs.
Append(module_spec);
160 return specs.
GetSize() - initial_count;
167 :
ObjectFile(module_sp, file, offset, length, extractor_sp, data_offset) {}
169std::unique_ptr<PDBFile>
171 llvm::BumpPtrAllocator &Allocator) {
172 llvm::file_magic magic;
173 auto ec = llvm::identify_magic(PdbPath, magic);
174 if (ec || magic != llvm::file_magic::pdb)
176 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ErrorOrBuffer =
177 llvm::MemoryBuffer::getFile(PdbPath,
false,
181 std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
183 llvm::StringRef Path = Buffer->getBufferIdentifier();
184 auto Stream = std::make_unique<llvm::MemoryBufferByteStream>(
185 std::move(Buffer), llvm::endianness::little);
187 auto File = std::make_unique<PDBFile>(Path, std::move(
Stream), Allocator);
188 if (
auto EC =
File->parseFileHeaders()) {
189 llvm::consumeError(std::move(EC));
192 if (
auto EC =
File->parseStreamData()) {
193 llvm::consumeError(std::move(EC));
static UUID GetPDBUUID(InfoStream &IS, DbiStream &DS)
#define LLDB_PLUGIN_DEFINE(PluginName)
An architecture specification class.
bool SetTriple(const llvm::Triple &triple)
Architecture triple setter.
bool SetArchitecture(ArchitectureType arch_type, uint32_t cpu, uint32_t sub, uint32_t os=0)
Change the architecture object type, CPU type and OS type.
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
An abstract base class for files.
void Append(const ModuleSpec &spec)
ArchSpec & GetArchitecture()
static ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
static const char * GetPluginDescriptionStatic()
static std::unique_ptr< llvm::pdb::PDBFile > loadPDBFile(std::string PdbPath, llvm::BumpPtrAllocator &Allocator)
static size_t GetModuleSpecifications(const FileSpec &file, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, lldb::offset_t file_offset, lldb::offset_t length, ModuleSpecList &specs)
std::unique_ptr< llvm::pdb::PDBFile > m_file_up
static ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
ObjectFilePDB(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP &extractor_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
llvm::BumpPtrAllocator m_allocator
static llvm::StringRef GetPluginNameStatic()
ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
ObjectFile(const lldb::ModuleSP &module_sp, const FileSpec *file_spec_ptr, lldb::offset_t file_offset, lldb::offset_t length, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset)
Construct with a parent module, offset, and header data.
static bool RegisterPlugin(llvm::StringRef name, llvm::StringRef description, ABICreateInstance create_callback)
static bool UnregisterPlugin(ABICreateInstance create_callback)
A stream class that can stream formatted output to a file.
Represents UUID's of various sizes.
#define LLDB_INVALID_CPUTYPE
A class that represents a running process on the host machine.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP
struct lldb_private::UUID::CvRecordPdb70::@270014123013057306020052025020177330273131255133 Uuid
llvm::support::ulittle32_t Age