xref: /freebsd-src/contrib/llvm-project/lldb/source/Plugins/ObjectFile/PDB/ObjectFilePDB.h (revision 81ad626541db97eb356e2c1d4a20eb2a26a766ab)
1e8d8bef9SDimitry Andric //===-- ObjectFilePDB.h --------------------------------------- -*- C++ -*-===//
2e8d8bef9SDimitry Andric //
3e8d8bef9SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4e8d8bef9SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5e8d8bef9SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6e8d8bef9SDimitry Andric //
7e8d8bef9SDimitry Andric //===----------------------------------------------------------------------===//
8e8d8bef9SDimitry Andric 
9e8d8bef9SDimitry Andric #ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H
10e8d8bef9SDimitry Andric #define LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H
11e8d8bef9SDimitry Andric 
12e8d8bef9SDimitry Andric #include "lldb/Symbol/ObjectFile.h"
13e8d8bef9SDimitry Andric #include "lldb/Utility/ArchSpec.h"
14e8d8bef9SDimitry Andric #include "llvm/DebugInfo/PDB/Native/NativeSession.h"
15e8d8bef9SDimitry Andric #include "llvm/DebugInfo/PDB/PDBTypes.h"
16e8d8bef9SDimitry Andric 
17e8d8bef9SDimitry Andric namespace lldb_private {
18e8d8bef9SDimitry Andric 
19e8d8bef9SDimitry Andric class ObjectFilePDB : public ObjectFile {
20e8d8bef9SDimitry Andric public:
21e8d8bef9SDimitry Andric   // Static Functions
22e8d8bef9SDimitry Andric   static void Initialize();
23e8d8bef9SDimitry Andric   static void Terminate();
24e8d8bef9SDimitry Andric 
GetPluginNameStatic()25349cc55cSDimitry Andric   static llvm::StringRef GetPluginNameStatic() { return "pdb"; }
GetPluginDescriptionStatic()26e8d8bef9SDimitry Andric   static const char *GetPluginDescriptionStatic() {
27e8d8bef9SDimitry Andric     return "PDB object file reader.";
28e8d8bef9SDimitry Andric   }
29e8d8bef9SDimitry Andric 
30e8d8bef9SDimitry Andric   static std::unique_ptr<llvm::pdb::PDBFile>
31e8d8bef9SDimitry Andric   loadPDBFile(std::string PdbPath, llvm::BumpPtrAllocator &Allocator);
32e8d8bef9SDimitry Andric 
33e8d8bef9SDimitry Andric   static ObjectFile *
34*81ad6265SDimitry Andric   CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
35e8d8bef9SDimitry Andric                  lldb::offset_t data_offset, const FileSpec *file,
36e8d8bef9SDimitry Andric                  lldb::offset_t file_offset, lldb::offset_t length);
37e8d8bef9SDimitry Andric 
38e8d8bef9SDimitry Andric   static ObjectFile *CreateMemoryInstance(const lldb::ModuleSP &module_sp,
39*81ad6265SDimitry Andric                                           lldb::WritableDataBufferSP data_sp,
40e8d8bef9SDimitry Andric                                           const lldb::ProcessSP &process_sp,
41e8d8bef9SDimitry Andric                                           lldb::addr_t header_addr);
42e8d8bef9SDimitry Andric 
43e8d8bef9SDimitry Andric   static size_t GetModuleSpecifications(const FileSpec &file,
44e8d8bef9SDimitry Andric                                         lldb::DataBufferSP &data_sp,
45e8d8bef9SDimitry Andric                                         lldb::offset_t data_offset,
46e8d8bef9SDimitry Andric                                         lldb::offset_t file_offset,
47e8d8bef9SDimitry Andric                                         lldb::offset_t length,
48e8d8bef9SDimitry Andric                                         ModuleSpecList &specs);
49e8d8bef9SDimitry Andric 
50e8d8bef9SDimitry Andric   // PluginInterface protocol
GetPluginName()51349cc55cSDimitry Andric   llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
52e8d8bef9SDimitry Andric 
53e8d8bef9SDimitry Andric   // LLVM RTTI support
54e8d8bef9SDimitry Andric   static char ID;
isA(const void * ClassID)55e8d8bef9SDimitry Andric   bool isA(const void *ClassID) const override {
56e8d8bef9SDimitry Andric     return ClassID == &ID || ObjectFile::isA(ClassID);
57e8d8bef9SDimitry Andric   }
classof(const ObjectFile * obj)58e8d8bef9SDimitry Andric   static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
59e8d8bef9SDimitry Andric 
60e8d8bef9SDimitry Andric   // ObjectFile Protocol.
GetAddressByteSize()61e8d8bef9SDimitry Andric   uint32_t GetAddressByteSize() const override { return 8; }
62e8d8bef9SDimitry Andric 
GetByteOrder()63e8d8bef9SDimitry Andric   lldb::ByteOrder GetByteOrder() const override {
64e8d8bef9SDimitry Andric     return lldb::eByteOrderLittle;
65e8d8bef9SDimitry Andric   }
66e8d8bef9SDimitry Andric 
ParseHeader()67e8d8bef9SDimitry Andric   bool ParseHeader() override { return true; }
68e8d8bef9SDimitry Andric 
IsExecutable()69e8d8bef9SDimitry Andric   bool IsExecutable() const override { return false; }
70e8d8bef9SDimitry Andric 
ParseSymtab(lldb_private::Symtab & symtab)714824e7fdSDimitry Andric   void ParseSymtab(lldb_private::Symtab &symtab) override {}
72e8d8bef9SDimitry Andric 
IsStripped()73e8d8bef9SDimitry Andric   bool IsStripped() override { return false; }
74e8d8bef9SDimitry Andric 
75e8d8bef9SDimitry Andric   // No section in PDB file.
CreateSections(SectionList & unified_section_list)76e8d8bef9SDimitry Andric   void CreateSections(SectionList &unified_section_list) override {}
77e8d8bef9SDimitry Andric 
Dump(Stream * s)78e8d8bef9SDimitry Andric   void Dump(Stream *s) override {}
79e8d8bef9SDimitry Andric 
80e8d8bef9SDimitry Andric   ArchSpec GetArchitecture() override;
81e8d8bef9SDimitry Andric 
GetUUID()82e8d8bef9SDimitry Andric   UUID GetUUID() override { return m_uuid; }
83e8d8bef9SDimitry Andric 
GetDependentModules(FileSpecList & files)84e8d8bef9SDimitry Andric   uint32_t GetDependentModules(FileSpecList &files) override { return 0; }
85e8d8bef9SDimitry Andric 
CalculateType()86e8d8bef9SDimitry Andric   Type CalculateType() override { return eTypeDebugInfo; }
87e8d8bef9SDimitry Andric 
CalculateStrata()88e8d8bef9SDimitry Andric   Strata CalculateStrata() override { return eStrataUser; }
89e8d8bef9SDimitry Andric 
GetPDBFile()90e8d8bef9SDimitry Andric   llvm::pdb::PDBFile &GetPDBFile() { return *m_file_up; }
91e8d8bef9SDimitry Andric 
92e8d8bef9SDimitry Andric   ObjectFilePDB(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp,
93e8d8bef9SDimitry Andric                 lldb::offset_t data_offset, const FileSpec *file,
94e8d8bef9SDimitry Andric                 lldb::offset_t offset, lldb::offset_t length);
95e8d8bef9SDimitry Andric 
96e8d8bef9SDimitry Andric private:
97e8d8bef9SDimitry Andric   UUID m_uuid;
98e8d8bef9SDimitry Andric   llvm::BumpPtrAllocator m_allocator;
99e8d8bef9SDimitry Andric   std::unique_ptr<llvm::pdb::PDBFile> m_file_up;
100e8d8bef9SDimitry Andric 
101e8d8bef9SDimitry Andric   bool initPDBFile();
102e8d8bef9SDimitry Andric };
103e8d8bef9SDimitry Andric 
104e8d8bef9SDimitry Andric } // namespace lldb_private
10504eeddc0SDimitry Andric #endif // LLDB_SOURCE_PLUGINS_OBJECTFILE_PDB_OBJECTFILEPDB_H
106