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 = IS.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());
93 auto objfile_up = std::make_unique<ObjectFilePDB>(
94 module_sp, data_sp, data_offset, file, file_offset, length);
95 if (!objfile_up->initPDBFile())
97 return objfile_up.release();
101 WritableDataBufferSP data_sp,
102 const ProcessSP &process_sp,
110 const size_t initial_count = specs.
GetSize();
112 llvm::BumpPtrAllocator allocator;
115 return initial_count;
117 auto info_stream = pdb_file->getPDBInfoStream();
119 llvm::consumeError(info_stream.takeError());
120 return initial_count;
122 auto dbi_stream = pdb_file->getPDBDbiStream();
124 llvm::consumeError(dbi_stream.takeError());
125 return initial_count;
132 switch (dbi_stream->getMachineType()) {
133 case PDB_Machine::Amd64:
134 module_arch.
SetTriple(
"x86_64-pc-windows");
135 specs.
Append(module_spec);
137 case PDB_Machine::x86:
138 module_arch.
SetTriple(
"i386-pc-windows");
139 specs.
Append(module_spec);
141 case PDB_Machine::ArmNT:
142 module_arch.
SetTriple(
"armv7-pc-windows");
143 specs.
Append(module_spec);
145 case PDB_Machine::Arm64:
146 module_arch.
SetTriple(
"aarch64-pc-windows");
147 specs.
Append(module_spec);
153 return specs.
GetSize() - initial_count;
159 :
ObjectFile(module_sp, file, offset, length, data_sp, data_offset) {}
161std::unique_ptr<PDBFile>
163 llvm::BumpPtrAllocator &Allocator) {
164 llvm::file_magic magic;
165 auto ec = llvm::identify_magic(PdbPath, magic);
166 if (ec || magic != llvm::file_magic::pdb)
168 llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> ErrorOrBuffer =
169 llvm::MemoryBuffer::getFile(PdbPath,
false,
173 std::unique_ptr<llvm::MemoryBuffer> Buffer = std::move(*ErrorOrBuffer);
175 llvm::StringRef Path = Buffer->getBufferIdentifier();
176 auto Stream = std::make_unique<llvm::MemoryBufferByteStream>(
177 std::move(Buffer), llvm::support::little);
179 auto File = std::make_unique<PDBFile>(Path, std::move(
Stream), Allocator);
180 if (
auto EC =
File->parseFileHeaders()) {
181 llvm::consumeError(std::move(EC));
184 if (
auto EC =
File->parseStreamData()) {
185 llvm::consumeError(std::move(EC));
static UUID GetPDBUUID(InfoStream &IS)
#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.
struct lldb_private::UUID::CvRecordPdb70::@43 Uuid
llvm::support::ulittle32_t Age