Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / source / Plugins / ObjectFile / COFF / ObjectFileCOFF.h
blob46c43f93f7ffce90a2ad277566974bc04e8c6025
1 //===-- ObjectFileCOFF.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 //===----------------------------------------------------------------------===//
9 #ifndef LLDB_SOURCE_PLUGINS_OBJECTFILE_COFF_OBJECTFILECOFF_H
10 #define LLDB_SOURCE_PLUGINS_OBJECTFILE_COFF_OBJECTFILECOFF_H
12 #include "lldb/Symbol/ObjectFile.h"
14 #include "llvm/Object/COFF.h"
16 /// \class ObjectFileELF
17 /// Generic COFF object file reader.
18 ///
19 /// This class provides a generic COFF reader plugin implementing the ObjectFile
20 /// protocol. Assumes that the COFF object format is a Microsoft style COFF
21 /// rather than the full generality afforded by it.
22 class ObjectFileCOFF : public lldb_private::ObjectFile {
23 std::unique_ptr<llvm::object::COFFObjectFile> m_object;
24 lldb_private::UUID m_uuid;
26 ObjectFileCOFF(std::unique_ptr<llvm::object::COFFObjectFile> object,
27 const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
28 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
29 lldb::offset_t file_offset, lldb::offset_t length)
30 : ObjectFile(module_sp, file, file_offset, length, data_sp, data_offset),
31 m_object(std::move(object)) {}
33 public:
34 ~ObjectFileCOFF() override;
36 static void Initialize();
37 static void Terminate();
39 static llvm::StringRef GetPluginNameStatic() { return "COFF"; }
40 static llvm::StringRef GetPluginDescriptionStatic() {
41 return "COFF Object File Reader";
44 static lldb_private::ObjectFile *
45 CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP data_sp,
46 lldb::offset_t data_offset, const lldb_private::FileSpec *file,
47 lldb::offset_t file_offset, lldb::offset_t length);
49 static lldb_private::ObjectFile *
50 CreateMemoryInstance(const lldb::ModuleSP &module_sp,
51 lldb::WritableDataBufferSP data_sp,
52 const lldb::ProcessSP &process_sp, lldb::addr_t header);
54 static size_t GetModuleSpecifications(const lldb_private::FileSpec &file,
55 lldb::DataBufferSP &data_sp,
56 lldb::offset_t data_offset,
57 lldb::offset_t file_offset,
58 lldb::offset_t length,
59 lldb_private::ModuleSpecList &specs);
61 // LLVM RTTI support
62 static char ID;
63 bool isA(const void *ClassID) const override {
64 return ClassID == &ID || ObjectFile::isA(ClassID);
66 static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
68 // PluginInterface protocol
69 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
71 // ObjectFile protocol
72 void Dump(lldb_private::Stream *stream) override;
74 uint32_t GetAddressByteSize() const override;
76 uint32_t GetDependentModules(lldb_private::FileSpecList &specs) override {
77 return 0;
80 bool IsExecutable() const override {
81 // COFF is an object file format only, it cannot host an executable.
82 return false;
85 lldb_private::ArchSpec GetArchitecture() override;
87 void CreateSections(lldb_private::SectionList &) override;
89 void ParseSymtab(lldb_private::Symtab &) override;
91 bool IsStripped() override {
92 // FIXME see if there is a good way to identify a /Z7 v /Zi or /ZI build.
93 return false;
96 lldb_private::UUID GetUUID() override { return m_uuid; }
98 lldb::ByteOrder GetByteOrder() const override {
99 // Microsoft always uses little endian.
100 return lldb::ByteOrder::eByteOrderLittle;
103 bool ParseHeader() override;
105 lldb_private::ObjectFile::Type CalculateType() override {
106 // COFF is an object file format only, it cannot host an executable.
107 return lldb_private::ObjectFile::eTypeObjectFile;
110 lldb_private::ObjectFile::Strata CalculateStrata() override {
111 // FIXME the object file may correspond to a kernel image.
112 return lldb_private::ObjectFile::eStrataUser;
116 #endif