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();
119 llvm::BumpPtrAllocator allocator;
124 auto info_stream = pdb_file->getPDBInfoStream();
126 llvm::consumeError(info_stream.takeError());
129 auto dbi_stream = pdb_file->getPDBDbiStream();
131 llvm::consumeError(dbi_stream.takeError());
140 switch (dbi_stream->getMachineType()) {
141 case PDB_Machine::Amd64:
142 module_arch.
SetTriple(
"x86_64-pc-windows");
143 specs.
Append(module_spec);
145 case PDB_Machine::x86:
146 module_arch.
SetTriple(
"i386-pc-windows");
147 specs.
Append(module_spec);
149 case PDB_Machine::ArmNT:
150 module_arch.
SetTriple(
"armv7-pc-windows");
151 specs.
Append(module_spec);
153 case PDB_Machine::Arm64:
154 module_arch.
SetTriple(
"aarch64-pc-windows");
155 specs.
Append(module_spec);
168 :
ObjectFile(module_sp, file, offset, length, extractor_sp, data_offset) {}
170std::unique_ptr<PDBFile>
172 llvm::BumpPtrAllocator &Allocator) {
173 llvm::file_magic magic;
174 auto ec = llvm::identify_magic(PdbPath, magic);
175 if (ec || magic != llvm::file_magic::pdb)
177 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ErrorOrBuffer =
178 llvm::MemoryBuffer::getFile(PdbPath,
false,
182 std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
184 llvm::StringRef Path = Buffer->getBufferIdentifier();
185 auto Stream = std::make_unique<llvm::MemoryBufferByteStream>(
186 std::move(Buffer), llvm::endianness::little);
188 auto File = std::make_unique<PDBFile>(Path, std::move(
Stream), Allocator);
189 if (
auto EC =
File->parseFileHeaders()) {
190 llvm::consumeError(std::move(EC));
193 if (
auto EC =
File->parseStreamData()) {
194 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)
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.
static ModuleSpecList GetModuleSpecifications(const FileSpec &file, lldb::DataExtractorSP &extractor_sp, lldb::offset_t file_offset, lldb::offset_t length)
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::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