LLDB mainline
ObjectFileJIT.h
Go to the documentation of this file.
1//===-- ObjectFileJIT.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_EXPRESSION_OBJECTFILEJIT_H
10#define LLDB_EXPRESSION_OBJECTFILEJIT_H
11
12#include "lldb/Core/Address.h"
13#include "lldb/Core/Section.h"
15#include "lldb/Symbol/Symtab.h"
17
18namespace lldb_private {
19
21public:
23 virtual ~ObjectFileJITDelegate() = default;
24 virtual lldb::ByteOrder GetByteOrder() const = 0;
25 virtual uint32_t GetAddressByteSize() const = 0;
27 lldb_private::Symtab &symtab) = 0;
29 lldb_private::SectionList &section_list) = 0;
31 /// Returns the Target this JIT-compiled code was produced for, or null
32 /// if the delegate that created this ObjectFile no longer exists.
34};
35
36class ObjectFileJIT : public ObjectFile {
37public:
38 ObjectFileJIT(const lldb::ModuleSP &module_sp,
39 const lldb::ObjectFileJITDelegateSP &delegate_sp);
40
41 ~ObjectFileJIT() override;
42
43 // Static Functions
44 static void Initialize();
45
46 static void Terminate();
47
48 static llvm::StringRef GetPluginNameStatic() { return "jit"; }
49
50 static llvm::StringRef GetPluginDescriptionStatic() {
51 return "JIT code object file";
52 }
53
55 CreateInstance(const lldb::ModuleSP &module_sp,
56 lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset,
57 const lldb_private::FileSpec *file, lldb::offset_t file_offset,
58 lldb::offset_t length);
59
61 const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp,
62 const lldb::ProcessSP &process_sp, lldb::addr_t header_addr);
63
64 static ModuleSpecList
66 lldb::DataExtractorSP &extractor_sp,
67 lldb::offset_t file_offset, lldb::offset_t length);
68
69 // LLVM RTTI support
70 static char ID;
71 bool isA(const void *ClassID) const override {
72 return ClassID == &ID || ObjectFile::isA(ClassID);
73 }
74 static bool classof(const ObjectFile *obj) { return obj->isA(&ID); }
75
76 // Member Functions
77 bool ParseHeader() override;
78
80 bool value_is_offset) override;
81
82 lldb::ByteOrder GetByteOrder() const override;
83
84 bool IsExecutable() const override;
85
86 uint32_t GetAddressByteSize() const override;
87
88 void ParseSymtab(lldb_private::Symtab &symtab) override;
89
90 bool IsStripped() override;
91
92 void CreateSections(lldb_private::SectionList &unified_section_list) override;
93
94 void Dump(lldb_private::Stream *s) override;
95
97
98 /// Returns the Target this JIT-compiled code was produced for, or null
99 /// if the delegate that created this ObjectFile no longer exists.
101
102 lldb_private::UUID GetUUID() override;
103
104 uint32_t GetDependentModules(lldb_private::FileSpecList &files) override;
105
107 lldb::offset_t section_offset, void *dst,
108 size_t dst_len) override;
109
111 lldb_private::DataExtractor &section_data) override;
112
114
116
118
120
121 // PluginInterface protocol
122 llvm::StringRef GetPluginName() override { return GetPluginNameStatic(); }
123
124protected:
126};
127} // namespace lldb_private
128
129#endif // LLDB_EXPRESSION_OBJECTFILEJIT_H
A section + offset based address class.
Definition Address.h:62
An architecture specification class.
Definition ArchSpec.h:32
An data extractor class.
A file collection class.
A file utility class.
Definition FileSpec.h:56
virtual uint32_t GetAddressByteSize() const =0
virtual ArchSpec GetArchitecture()=0
virtual void PopulateSymtab(lldb_private::ObjectFile *obj_file, lldb_private::Symtab &symtab)=0
virtual void PopulateSectionList(lldb_private::ObjectFile *obj_file, lldb_private::SectionList &section_list)=0
virtual ~ObjectFileJITDelegate()=default
virtual lldb::ByteOrder GetByteOrder() const =0
virtual lldb::TargetSP GetTargetSP()=0
Returns the Target this JIT-compiled code was produced for, or null if the delegate that created this...
ObjectFileJIT(const lldb::ModuleSP &module_sp, const lldb::ObjectFileJITDelegateSP &delegate_sp)
uint32_t GetDependentModules(lldb_private::FileSpecList &files) override
Extract the dependent modules from an object file.
bool IsStripped() override
Detect if this object file has been stripped of local symbols.
bool IsExecutable() const override
Tells whether this object file is capable of being the main executable for a process.
lldb::ByteOrder GetByteOrder() const override
Gets whether endian swapping should occur when extracting data from this object file.
bool isA(const void *ClassID) const override
lldb_private::Address GetBaseAddress() override
Returns base address of this object file.
static llvm::StringRef GetPluginDescriptionStatic()
lldb_private::UUID GetUUID() override
Gets the UUID for this object file.
static bool classof(const ObjectFile *obj)
static lldb_private::ObjectFile * CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataExtractorSP extractor_sp, lldb::offset_t data_offset, const lldb_private::FileSpec *file, lldb::offset_t file_offset, lldb::offset_t length)
static ModuleSpecList GetModuleSpecifications(const lldb_private::FileSpec &file, lldb::DataExtractorSP &extractor_sp, lldb::offset_t file_offset, lldb::offset_t length)
lldb_private::ArchSpec GetArchitecture() override
Get the ArchSpec for this object file.
lldb_private::Address GetEntryPointAddress() override
Returns the address of the Entry Point in this object file - if the object file doesn't have an entry...
void Dump(lldb_private::Stream *s) override
Dump a description of this object to a Stream.
bool ParseHeader() override
Attempts to parse the object header.
lldb::ObjectFileJITDelegateWP m_delegate_wp
ObjectFile::Strata CalculateStrata() override
The object file should be able to calculate the strata of the object file.
llvm::StringRef GetPluginName() override
uint32_t GetAddressByteSize() const override
Gets the address size in bytes for the current object file.
static llvm::StringRef GetPluginNameStatic()
void CreateSections(lldb_private::SectionList &unified_section_list) override
ObjectFile::Type CalculateType() override
The object file should be able to calculate its type by looking at its file header and possibly the s...
size_t ReadSectionData(lldb_private::Section *section, lldb::offset_t section_offset, void *dst, size_t dst_len) override
bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value, bool value_is_offset) override
Sets the load address for an entire module, assuming a rigid slide of sections, if possible in the im...
void ParseSymtab(lldb_private::Symtab &symtab) override
Parse the symbol table into the provides symbol table object.
static lldb_private::ObjectFile * CreateMemoryInstance(const lldb::ModuleSP &module_sp, lldb::WritableDataBufferSP data_sp, const lldb::ProcessSP &process_sp, lldb::addr_t header_addr)
lldb::TargetSP GetTargetSP()
Returns the Target this JIT-compiled code was produced for, or null if the delegate that created this...
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:46
virtual bool isA(const void *ClassID) const
Definition ObjectFile.h:216
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:86
std::shared_ptr< lldb_private::Process > ProcessSP
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::ObjectFileJITDelegate > ObjectFileJITDelegateSP
std::shared_ptr< lldb_private::Target > TargetSP
std::shared_ptr< lldb_private::DataExtractor > DataExtractorSP
std::shared_ptr< lldb_private::Module > ModuleSP
std::weak_ptr< lldb_private::ObjectFileJITDelegate > ObjectFileJITDelegateWP