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());
98 auto objfile_up = std::make_unique<ObjectFilePDB>(
99 module_sp, data_sp, data_offset, file, file_offset, length);
100 if (!objfile_up->initPDBFile())
102 return objfile_up.release();
115 const size_t initial_count = specs.
GetSize();
117 llvm::BumpPtrAllocator allocator;
120 return initial_count;
122 auto info_stream = pdb_file->getPDBInfoStream();
124 llvm::consumeError(info_stream.takeError());
125 return initial_count;
127 auto dbi_stream = pdb_file->getPDBDbiStream();
129 llvm::consumeError(dbi_stream.takeError());
130 return initial_count;
137 switch (dbi_stream->getMachineType()) {
138 case PDB_Machine::Amd64:
139 module_arch.
SetTriple(
"x86_64-pc-windows");
140 specs.
Append(module_spec);
142 case PDB_Machine::x86:
143 module_arch.
SetTriple(
"i386-pc-windows");
144 specs.
Append(module_spec);
146 case PDB_Machine::ArmNT:
147 module_arch.
SetTriple(
"armv7-pc-windows");
148 specs.
Append(module_spec);
150 case PDB_Machine::Arm64:
151 module_arch.
SetTriple(
"aarch64-pc-windows");
152 specs.
Append(module_spec);
158 return specs.
GetSize() - initial_count;
164 :
ObjectFile(module_sp, file, offset, length, data_sp, data_offset) {}
166std::unique_ptr<PDBFile>
168 llvm::BumpPtrAllocator &Allocator) {
169 llvm::file_magic magic;
170 auto ec = llvm::identify_magic(PdbPath, magic);
171 if (ec || magic != llvm::file_magic::pdb)
173 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ErrorOrBuffer =
174 llvm::MemoryBuffer::getFile(PdbPath,
false,
178 std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
180 llvm::StringRef Path = Buffer->getBufferIdentifier();
181 auto Stream = std::make_unique<llvm::MemoryBufferByteStream>(
182 std::move(Buffer), llvm::endianness::little);
184 auto File = std::make_unique<PDBFile>(Path, std::move(
Stream), Allocator);
185 if (
auto EC =
File->parseFileHeaders()) {
186 llvm::consumeError(std::move(EC));
189 if (
auto EC =
File->parseStreamData()) {
190 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 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
ObjectFilePDB(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t offset, lldb::offset_t length)
static ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
llvm::BumpPtrAllocator m_allocator
static llvm::StringRef GetPluginNameStatic()
ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
static ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp, lldb::offset_t data_offset, const FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
A plug-in interface definition class for object file parsers.
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.
#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::Module > ModuleSP
struct lldb_private::UUID::CvRecordPdb70::@41 Uuid
llvm::support::ulittle32_t Age