LLDB mainline
ObjectFilePDB.h
Go to the documentation of this file.
1//===-- ObjectFilePDB.h --------------------------------------- -*- C++ -*-===//
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
9#ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H
10#define LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H
11
14#include "llvm/DebugInfo/PDB/Native/NativeSession.h"
15#include "llvm/DebugInfo/PDB/PDBTypes.h"
16
17namespace lldb_private {
18
19class ObjectFilePDB : public ObjectFile {
20public:
21 // Static Functions
22 static void Initialize();
23 static void Terminate();
24
25 static llvm::StringRef GetPluginNameStatic() { return "pdb"; }
26 static const char *GetPluginDescriptionStatic() {
27 return "PDB object file reader.";
28 }
29
30 static std::unique_ptr<llvm::pdb::PDBFile>
31 loadPDBFile(std::string PdbPath, llvm::BumpPtrAllocator &Allocator);
32
33 static ObjectFile *CreateInstance(const lldb::ModuleSP &module_sp,
34 lldb::DataExtractorSP extractor_sp,
35 lldb::offset_t data_offset,
36 const FileSpec *file,
37 lldb::offset_t file_offset,
38 lldb::offset_t length);
39
40 static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp,
42 const lldb::ProcessSP &process_sp,
43 lldb::addr_t header_addr);
44
45 static size_t GetModuleSpecifications(const FileSpec &file,
46 lldb::DataBufferSP &data_sp,
47 lldb::offset_t data_offset,
48 lldb::offset_t file_offset,
49 lldb::offset_t length,
50 ModuleSpecList &specs);
51
52 // PluginInterface protocol
53 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
54
55 // LLVM RTTI support
56 static char ID;
57 bool isA(const void *ClassID) const override {
58 return ClassID == &ID || ObjectFile::isA(ClassID);
59 }
60 static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
61
62 // ObjectFile Protocol.
63 uint32_t GetAddressByteSize() const override { return 8; }
64
65 lldb::ByteOrder GetByteOrder() const override {
67 }
68
69 bool ParseHeader() override { return true; }
70
71 bool IsExecutable() const override { return false; }
72
73 void ParseSymtab(lldb_private::Symtab &symtab) override {}
74
75 bool IsStripped() override { return false; }
76
77 // No section in PDB file.
78 void CreateSections(SectionList &unified_section_list) override {}
79
80 void Dump(Stream *s) override {}
81
82 ArchSpec GetArchitecture() override;
83
84 UUID GetUUID() override { return m_uuid; }
85
86 uint32_t GetDependentModules(FileSpecList &files) override { return 0; }
87
88 Type CalculateType() override { return eTypeDebugInfo; }
89
90 Strata CalculateStrata() override { return eStrataUser; }
91
92 llvm::pdb::PDBFile &GetPDBFile() { return *m_file_up; }
93
94 ObjectFilePDB(const lldb::ModuleSP &module_sp,
95 lldb::DataExtractorSP &extractor_sp, lldb::offset_t data_offset,
96 const FileSpec *file, lldb::offset_t offset,
97 lldb::offset_t length);
98
99private:
101 llvm::BumpPtrAllocator m_allocator;
102 std::unique_ptr<llvm::pdb::PDBFile> m_file_up;
103
104 bool initPDBFile();
105};
106
107} // namespace lldb_private
108#endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H
An architecture specification class.
Definition ArchSpec.h:31
A file collection class.
A file utility class.
Definition FileSpec.h:57
Strata CalculateStrata() override
The object file should be able to calculate the strata of the object file.
void ParseSymtab(lldb_private::Symtab &symtab) override
Parse the symbol table into the provides symbol table object.
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)
UUID GetUUID() override
Gets the UUID for this object file.
uint32_t GetDependentModules(FileSpecList &files) override
Extract the dependent modules from an object file.
static const char * GetPluginDescriptionStatic()
bool ParseHeader() override
Attempts to parse the object header.
static std::unique_ptr< llvm::pdb::PDBFile > loadPDBFile(std::string PdbPath, llvm::BumpPtrAllocator &Allocator)
llvm::StringRef GetPluginName() override
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)
uint32_t GetAddressByteSize() const override
Gets the address size in bytes for the current object file.
std::unique_ptr< llvm::pdb::PDBFile > m_file_up
bool isA(const void *ClassID) const override
void CreateSections(SectionList &unified_section_list) override
static bool classof(const ObjectFile *obj)
Type CalculateType() override
The object file should be able to calculate its type by looking at its file header and possibly the s...
lldb::ByteOrder GetByteOrder() const override
Gets whether endian swapping should occur when extracting data from this object file.
static ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
llvm::pdb::PDBFile & GetPDBFile()
void Dump(Stream *s) override
Dump a description of this object to a Stream.
bool IsExecutable() const override
Tells whether this object file is capable of being the main executable for a process.
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.
bool IsStripped() override
Detect if this object file has been stripped of local symbols.
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
@ eTypeDebugInfo
An object file that contains only debug information.
Definition ObjectFile.h:57
virtual bool isA(const void *ClassID) const
Definition ObjectFile.h:218
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.
A stream class that can stream formatted output to a file.
Definition Stream.h:28
Represents UUID's of various sizes.
Definition UUID.h:27
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::Process > ProcessSP
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::DataBuffer > DataBufferSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP