LLDB  mainline
IRExecutionUnit.h
Go to the documentation of this file.
1 //===-- IRExecutionUnit.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_IREXECUTIONUNIT_H
10 #define LLDB_EXPRESSION_IREXECUTIONUNIT_H
11 
12 #include <atomic>
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #include "llvm/ExecutionEngine/SectionMemoryManager.h"
18 #include "llvm/IR/Module.h"
19 
21 #include "lldb/Symbol/ObjectFile.h"
24 #include "lldb/lldb-forward.h"
25 #include "lldb/lldb-private.h"
26 
27 namespace llvm {
28 
29 class Module;
30 class ExecutionEngine;
31 class ObjectCache;
32 
33 } // namespace llvm
34 
35 namespace lldb_private {
36 
37 class Status;
38 
39 /// \class IRExecutionUnit IRExecutionUnit.h
40 /// "lldb/Expression/IRExecutionUnit.h" Contains the IR and, optionally, JIT-
41 /// compiled code for a module.
42 ///
43 /// This class encapsulates the compiled version of an expression, in IR form
44 /// (for interpretation purposes) and in raw machine code form (for execution
45 /// in the target).
46 ///
47 /// This object wraps an IR module that comes from the expression parser, and
48 /// knows how to use the JIT to make it into executable code. It can then be
49 /// used as input to the IR interpreter, or the address of the executable code
50 /// can be passed to a thread plan to run in the target.
51 ///
52 /// This class creates a subclass of LLVM's SectionMemoryManager, because that
53 /// is how the JIT emits code. Because LLDB needs to move JIT-compiled code
54 /// into the target process, the IRExecutionUnit knows how to copy the emitted
55 /// code into the target process.
56 class IRExecutionUnit : public std::enable_shared_from_this<IRExecutionUnit>,
57  public IRMemoryMap,
58  public ObjectFileJITDelegate {
59 public:
60  /// Constructor
61  IRExecutionUnit(std::unique_ptr<llvm::LLVMContext> &context_up,
62  std::unique_ptr<llvm::Module> &module_up, ConstString &name,
63  const lldb::TargetSP &target_sp, const SymbolContext &sym_ctx,
64  std::vector<std::string> &cpu_features);
65 
66  /// Destructor
67  ~IRExecutionUnit() override;
68 
70 
71  llvm::Module *GetModule() { return m_module; }
72 
73  llvm::Function *GetFunction() {
74  return ((m_module != nullptr) ? m_module->getFunction(m_name.GetStringRef())
75  : nullptr);
76  }
77 
78  void GetRunnableInfo(Status &error, lldb::addr_t &func_addr,
79  lldb::addr_t &func_end);
80 
81  /// Accessors for IRForTarget and other clients that may want binary data
82  /// placed on their behalf. The binary data is owned by the IRExecutionUnit
83  /// unless the client explicitly chooses to free it.
84 
85  lldb::addr_t WriteNow(const uint8_t *bytes, size_t size, Status &error);
86 
87  void FreeNow(lldb::addr_t allocation);
88 
89  /// ObjectFileJITDelegate overrides
90  lldb::ByteOrder GetByteOrder() const override;
91 
92  uint32_t GetAddressByteSize() const override;
93 
95  lldb_private::Symtab &symtab) override;
96 
98  lldb_private::SectionList &section_list) override;
99 
100  ArchSpec GetArchitecture() override;
101 
102  lldb::ModuleSP GetJITModule();
103 
104  lldb::addr_t FindSymbol(ConstString name, bool &missing_weak);
105 
106  void GetStaticInitializers(std::vector<lldb::addr_t> &static_initializers);
107 
108  /// \class JittedFunction IRExecutionUnit.h
109  /// "lldb/Expression/IRExecutionUnit.h"
110  /// Encapsulates a single function that has been generated by the JIT.
111  ///
112  /// Functions that have been generated by the JIT are first resident in the
113  /// local process, and then placed in the target process. JittedFunction
114  /// represents a function possibly resident in both.
115  struct JittedEntity {
116  ConstString m_name; ///< The function's name
117  lldb::addr_t m_local_addr; ///< The address of the function in LLDB's memory
119  m_remote_addr; ///< The address of the function in the target's memory
120 
121  /// Constructor
122  ///
123  /// Initializes class variabes.
124  ///
125  /// \param[in] name
126  /// The name of the function.
127  ///
128  /// \param[in] local_addr
129  /// The address of the function in LLDB, or LLDB_INVALID_ADDRESS if
130  /// it is not present in LLDB's memory.
131  ///
132  /// \param[in] remote_addr
133  /// The address of the function in the target, or LLDB_INVALID_ADDRESS
134  /// if it is not present in the target's memory.
135  JittedEntity(const char *name,
136  lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
137  lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS)
138  : m_name(name), m_local_addr(local_addr), m_remote_addr(remote_addr) {}
139  };
140 
143  JittedFunction(const char *name, bool external,
144  lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
145  lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS)
146  : JittedEntity(name, local_addr, remote_addr), m_external(external) {}
147  };
148 
150  JittedGlobalVariable(const char *name,
151  lldb::addr_t local_addr = LLDB_INVALID_ADDRESS,
152  lldb::addr_t remote_addr = LLDB_INVALID_ADDRESS)
153  : JittedEntity(name, local_addr, remote_addr) {}
154  };
155 
156  const std::vector<JittedFunction> &GetJittedFunctions() {
157  return m_jitted_functions;
158  }
159 
160  const std::vector<JittedGlobalVariable> &GetJittedGlobalVariables() {
162  }
163 
164 private:
165  /// Look up the object in m_address_map that contains a given address, find
166  /// where it was copied to, and return the remote address at the same offset
167  /// into the copied entity
168  ///
169  /// \param[in] local_address
170  /// The address in the debugger.
171  ///
172  /// \return
173  /// The address in the target process.
175 
176  typedef std::pair<lldb::addr_t, uintptr_t> AddrRange;
177 
178  /// Look up the object in m_address_map that contains a given address, find
179  /// where it was copied to, and return its address range in the target
180  /// process
181  ///
182  /// \param[in] local_address
183  /// The address in the debugger.
184  ///
185  /// \return
186  /// The range of the containing object in the target process.
188 
189  /// Commit all allocations to the process and record where they were stored.
190  ///
191  /// \param[in] process_sp
192  /// The process to allocate memory in.
193  ///
194  /// \return
195  /// True <=> all allocations were performed successfully.
196  /// This method will attempt to free allocated memory if the
197  /// operation fails.
198  bool CommitAllocations(lldb::ProcessSP &process_sp);
199 
200  /// Report all committed allocations to the execution engine.
201  ///
202  /// \param[in] engine
203  /// The execution engine to notify.
204  void ReportAllocations(llvm::ExecutionEngine &engine);
205 
206  /// Write the contents of all allocations to the process.
207  ///
208  /// \param[in] process_sp
209  /// The process containing the allocations.
210  ///
211  /// \return
212  /// True <=> all allocations were performed successfully.
213  bool WriteData(lldb::ProcessSP &process_sp);
214 
215  Status DisassembleFunction(Stream &stream, lldb::ProcessSP &process_sp);
216 
217  void CollectCandidateCNames(std::vector<ConstString> &C_names,
218  ConstString name);
219 
220  void CollectCandidateCPlusPlusNames(std::vector<ConstString> &CPP_names,
221  const std::vector<ConstString> &C_names,
222  const SymbolContext &sc);
223 
224  lldb::addr_t FindInSymbols(const std::vector<ConstString> &names,
225  const lldb_private::SymbolContext &sc,
226  bool &symbol_was_missing_weak);
227 
228  lldb::addr_t FindInRuntimes(const std::vector<ConstString> &names,
229  const lldb_private::SymbolContext &sc);
230 
231  lldb::addr_t FindInUserDefinedSymbols(const std::vector<ConstString> &names,
232  const lldb_private::SymbolContext &sc);
233 
235 
236  class MemoryManager : public llvm::SectionMemoryManager {
237  public:
239 
240  ~MemoryManager() override;
241 
242  /// Allocate space for executable code, and add it to the m_spaceBlocks
243  /// map
244  ///
245  /// \param[in] Size
246  /// The size of the area.
247  ///
248  /// \param[in] Alignment
249  /// The required alignment of the area.
250  ///
251  /// \param[in] SectionID
252  /// A unique identifier for the section.
253  ///
254  /// \return
255  /// Allocated space.
256  uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment,
257  unsigned SectionID,
258  llvm::StringRef SectionName) override;
259 
260  /// Allocate space for data, and add it to the m_spaceBlocks map
261  ///
262  /// \param[in] Size
263  /// The size of the area.
264  ///
265  /// \param[in] Alignment
266  /// The required alignment of the area.
267  ///
268  /// \param[in] SectionID
269  /// A unique identifier for the section.
270  ///
271  /// \param[in] IsReadOnly
272  /// Flag indicating the section is read-only.
273  ///
274  /// \return
275  /// Allocated space.
276  uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
277  unsigned SectionID,
278  llvm::StringRef SectionName,
279  bool IsReadOnly) override;
280 
281  /// Called when object loading is complete and section page permissions
282  /// can be applied. Currently unimplemented for LLDB.
283  ///
284  /// \param[out] ErrMsg
285  /// The error that prevented the page protection from succeeding.
286  ///
287  /// \return
288  /// True in case of failure, false in case of success.
289  bool finalizeMemory(std::string *ErrMsg) override {
290  // TODO: Ensure that the instruction cache is flushed because
291  // relocations are updated by dy-load. See:
292  // sys::Memory::InvalidateInstructionCache
293  // llvm::SectionMemoryManager
294  return false;
295  }
296 
297  // Ignore any EHFrame registration.
298  void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr,
299  size_t Size) override {}
300  void deregisterEHFrames() override {}
301 
302  uint64_t getSymbolAddress(const std::string &Name) override;
303 
304  // Find the address of the symbol Name. If Name is a missing weak symbol
305  // then missing_weak will be true.
306  uint64_t GetSymbolAddressAndPresence(const std::string &Name,
307  bool &missing_weak);
308 
309  llvm::JITSymbol findSymbol(const std::string &Name) override;
310 
311  void *getPointerToNamedFunction(const std::string &Name,
312  bool AbortOnFailure = true) override;
313 
314  private:
315  std::unique_ptr<SectionMemoryManager> m_default_mm_up; ///< The memory
316  /// allocator to use
317  /// in actually
318  /// creating space.
319  /// All calls are
320  /// passed through to
321  /// it.
322  IRExecutionUnit &m_parent; ///< The execution unit this is a proxy for.
323  };
324 
325  static const unsigned eSectionIDInvalid = (unsigned)-1;
326 
327  enum class AllocationKind { Stub, Code, Data, Global, Bytes };
328 
329  static lldb::SectionType
330  GetSectionTypeFromSectionName(const llvm::StringRef &name,
331  AllocationKind alloc_kind);
332 
333  /// Encapsulates a single allocation request made by the JIT.
334  ///
335  /// Allocations made by the JIT are first queued up and then applied in bulk
336  /// to the underlying process.
340  uintptr_t m_host_address;
343  size_t m_size;
344  unsigned m_alignment;
345  unsigned m_section_id;
346 
347  AllocationRecord(uintptr_t host_address, uint32_t permissions,
348  lldb::SectionType sect_type, size_t size,
349  unsigned alignment, unsigned section_id, const char *name)
351  m_host_address(host_address), m_permissions(permissions),
352  m_sect_type(sect_type), m_size(size), m_alignment(alignment),
353  m_section_id(section_id) {
354  if (name && name[0])
355  m_name = name;
356  }
357 
358  void dump(Log *log);
359  };
360 
361  bool CommitOneAllocation(lldb::ProcessSP &process_sp, Status &error,
362  AllocationRecord &record);
363 
364  typedef std::vector<AllocationRecord> RecordVector;
366 
367  std::unique_ptr<llvm::LLVMContext> m_context_up;
368  std::unique_ptr<llvm::ExecutionEngine> m_execution_engine_up;
369  std::unique_ptr<llvm::ObjectCache> m_object_cache_up;
370  std::unique_ptr<llvm::Module>
371  m_module_up; ///< Holder for the module until it's been handed off
372  llvm::Module *m_module; ///< Owned by the execution engine
373  std::vector<std::string> m_cpu_features;
374  std::vector<JittedFunction> m_jitted_functions; ///< A vector of all functions
375  ///that have been JITted into
376  ///machine code
377  std::vector<JittedGlobalVariable> m_jitted_global_variables; ///< A vector of
378  ///all functions
379  ///that have been
380  ///JITted into
381  ///machine code
383  SymbolContext m_sym_ctx; ///< Used for symbol lookups
384  std::vector<ConstString> m_failed_lookups;
385 
386  std::atomic<bool> m_did_jit;
387 
390 
391  bool m_strip_underscore = true; ///< True for platforms where global symbols
392  /// have a _ prefix
393  bool m_reported_allocations; ///< True after allocations have been reported.
394  ///It is possible that
395  ///< sections will be allocated when this is true, in which case they weren't
396  ///< depended on by any function. (Top-level code defining a variable, but
397  ///< defining no functions using that variable, would do this.) If this
398  ///< is true, any allocations need to be committed immediately -- no
399  ///< opportunity for relocation.
400 };
401 
402 } // namespace lldb_private
403 
404 #endif // LLDB_EXPRESSION_IREXECUTIONUNIT_H
lldb_private::IRExecutionUnit
Definition: IRExecutionUnit.h:56
lldb_private::IRExecutionUnit::GetJittedFunctions
const std::vector< JittedFunction > & GetJittedFunctions()
Definition: IRExecutionUnit.h:156
lldb_private::IRExecutionUnit::FindInUserDefinedSymbols
lldb::addr_t FindInUserDefinedSymbols(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc)
Definition: IRExecutionUnit.cpp:842
lldb_private::IRExecutionUnit::m_jitted_global_variables
std::vector< JittedGlobalVariable > m_jitted_global_variables
A vector of all functions that have been JITted into machine code.
Definition: IRExecutionUnit.h:377
lldb_private::IRExecutionUnit::JittedGlobalVariable::JittedGlobalVariable
JittedGlobalVariable(const char *name, lldb::addr_t local_addr=LLDB_INVALID_ADDRESS, lldb::addr_t remote_addr=LLDB_INVALID_ADDRESS)
Definition: IRExecutionUnit.h:150
lldb_private::IRExecutionUnit::GetRunnableInfo
void GetRunnableInfo(Status &error, lldb::addr_t &func_addr, lldb::addr_t &func_end)
Definition: IRExecutionUnit.cpp:230
llvm
Definition: Debugger.h:49
lldb_private::IRExecutionUnit::GetAddressByteSize
uint32_t GetAddressByteSize() const override
Definition: IRExecutionUnit.cpp:1139
lldb_private::IRExecutionUnit::m_strip_underscore
bool m_strip_underscore
True for platforms where global symbols have a _ prefix.
Definition: IRExecutionUnit.h:391
lldb_private::ArchSpec
Definition: ArchSpec.h:33
IRMemoryMap.h
lldb_private::IRExecutionUnit::MemoryManager::deregisterEHFrames
void deregisterEHFrames() override
Definition: IRExecutionUnit.h:300
lldb_private::IRExecutionUnit::DisassembleFunction
Status DisassembleFunction(Stream &stream, lldb::ProcessSP &process_sp)
Definition: IRExecutionUnit.cpp:100
lldb_private::IRExecutionUnit::GetFunctionName
ConstString GetFunctionName()
Definition: IRExecutionUnit.h:69
lldb_private::IRExecutionUnit::AllocationRecord::dump
void dump(Log *log)
Definition: IRExecutionUnit.cpp:1123
lldb_private::IRExecutionUnit::AddrRange
std::pair< lldb::addr_t, uintptr_t > AddrRange
Definition: IRExecutionUnit.h:176
lldb_private::IRExecutionUnit::AllocationRecord::m_section_id
unsigned m_section_id
Definition: IRExecutionUnit.h:345
lldb_private::IRExecutionUnit::~IRExecutionUnit
~IRExecutionUnit() override
Destructor.
Definition: IRExecutionUnit.cpp:490
lldb_private::IRExecutionUnit::JittedGlobalVariable
Definition: IRExecutionUnit.h:149
lldb_private::IRExecutionUnit::m_sym_ctx
SymbolContext m_sym_ctx
Used for symbol lookups.
Definition: IRExecutionUnit.h:383
lldb_private::CompilerContextKind::Module
@ Module
lldb_private::SectionList
Definition: Section.h:34
lldb_private::IRExecutionUnit::MemoryManager::m_parent
IRExecutionUnit & m_parent
The execution unit this is a proxy for.
Definition: IRExecutionUnit.h:322
lldb_private::IRExecutionUnit::WriteData
bool WriteData(lldb::ProcessSP &process_sp)
Write the contents of all allocations to the process.
Definition: IRExecutionUnit.cpp:1109
lldb_private::IRExecutionUnit::FindSymbol
lldb::addr_t FindSymbol(ConstString name, bool &missing_weak)
Definition: IRExecutionUnit.cpp:857
lldb_private::IRExecutionUnit::GetFunction
llvm::Function * GetFunction()
Definition: IRExecutionUnit.h:73
lldb_private::Stream
Definition: Stream.h:28
lldb_private::IRExecutionUnit::FindInSymbols
lldb::addr_t FindInSymbols(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc, bool &symbol_was_missing_weak)
Definition: IRExecutionUnit.cpp:763
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ObjectFileJITDelegate
Definition: ObjectFile.h:26
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::IRExecutionUnit::MemoryManager::allocateDataSection
uint8_t * allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, llvm::StringRef SectionName, bool IsReadOnly) override
Allocate space for data, and add it to the m_spaceBlocks map.
Definition: IRExecutionUnit.cpp:624
lldb_private::IRExecutionUnit::AllocationRecord::AllocationRecord
AllocationRecord(uintptr_t host_address, uint32_t permissions, lldb::SectionType sect_type, size_t size, unsigned alignment, unsigned section_id, const char *name)
Definition: IRExecutionUnit.h:347
lldb_private::IRExecutionUnit::JittedEntity::m_local_addr
lldb::addr_t m_local_addr
The address of the function in LLDB's memory.
Definition: IRExecutionUnit.h:117
lldb_private::IRExecutionUnit::AllocationRecord::m_size
size_t m_size
Definition: IRExecutionUnit.h:343
lldb_private::IRExecutionUnit::MemoryManager::registerEHFrames
void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size) override
Definition: IRExecutionUnit.h:298
lldb_private::IRExecutionUnit::MemoryManager::MemoryManager
MemoryManager(IRExecutionUnit &parent)
Definition: IRExecutionUnit.cpp:496
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::IRExecutionUnit::m_failed_lookups
std::vector< ConstString > m_failed_lookups
Definition: IRExecutionUnit.h:384
lldb_private::IRExecutionUnit::PopulateSectionList
void PopulateSectionList(lldb_private::ObjectFile *obj_file, lldb_private::SectionList &section_list) override
Definition: IRExecutionUnit.cpp:1149
lldb_private::IRExecutionUnit::ReportAllocations
void ReportAllocations(llvm::ExecutionEngine &engine)
Report all committed allocations to the execution engine.
Definition: IRExecutionUnit.cpp:1091
lldb_private::IRExecutionUnit::GetRemoteAddressForLocal
lldb::addr_t GetRemoteAddressForLocal(lldb::addr_t local_address)
Look up the object in m_address_map that contains a given address, find where it was copied to,...
Definition: IRExecutionUnit.cpp:981
lldb_private::IRExecutionUnit::CollectCandidateCNames
void CollectCandidateCNames(std::vector< ConstString > &C_names, ConstString name)
Definition: IRExecutionUnit.cpp:655
lldb_private::IRExecutionUnit::m_module
llvm::Module * m_module
Owned by the execution engine.
Definition: IRExecutionUnit.h:372
lldb_private::IRExecutionUnit::m_function_end_load_addr
lldb::addr_t m_function_end_load_addr
Definition: IRExecutionUnit.h:389
lldb_private::ConstString::GetStringRef
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
Definition: ConstString.h:202
lldb_private::IRExecutionUnit::m_reported_allocations
bool m_reported_allocations
True after allocations have been reported.
Definition: IRExecutionUnit.h:393
lldb_private::IRExecutionUnit::JittedFunction::JittedFunction
JittedFunction(const char *name, bool external, lldb::addr_t local_addr=LLDB_INVALID_ADDRESS, lldb::addr_t remote_addr=LLDB_INVALID_ADDRESS)
Definition: IRExecutionUnit.h:143
lldb_private::IRExecutionUnit::AllocationKind::Stub
@ Stub
lldb_private::IRExecutionUnit::IRExecutionUnit
IRExecutionUnit(std::unique_ptr< llvm::LLVMContext > &context_up, std::unique_ptr< llvm::Module > &module_up, ConstString &name, const lldb::TargetSP &target_sp, const SymbolContext &sym_ctx, std::vector< std::string > &cpu_features)
Constructor.
Definition: IRExecutionUnit.cpp:41
lldb_private::IRExecutionUnit::MemoryManager::findSymbol
llvm::JITSymbol findSymbol(const std::string &Name) override
Definition: IRExecutionUnit.cpp:935
lldb_private::IRExecutionUnit::AllocationRecord::m_name
std::string m_name
Definition: IRExecutionUnit.h:338
lldb_private::IRExecutionUnit::JittedFunction
Definition: IRExecutionUnit.h:141
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::IRExecutionUnit::GetModule
llvm::Module * GetModule()
Definition: IRExecutionUnit.h:71
lldb_private::IRExecutionUnit::eSectionIDInvalid
static const unsigned eSectionIDInvalid
Definition: IRExecutionUnit.h:325
lldb_private::IRExecutionUnit::AllocationKind::Code
@ Code
lldb_private::IRExecutionUnit::MemoryManager::getPointerToNamedFunction
void * getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure=true) override
Definition: IRExecutionUnit.cpp:975
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::IRExecutionUnit::MemoryManager::~MemoryManager
~MemoryManager() override
lldb_private::IRExecutionUnit::AllocationRecord::m_alignment
unsigned m_alignment
Definition: IRExecutionUnit.h:344
lldb_private::IRExecutionUnit::AllocationKind
AllocationKind
Definition: IRExecutionUnit.h:327
lldb_private::IRExecutionUnit::GetSectionTypeFromSectionName
static lldb::SectionType GetSectionTypeFromSectionName(const llvm::StringRef &name, AllocationKind alloc_kind)
Definition: IRExecutionUnit.cpp:501
lldb_private::IRExecutionUnit::m_did_jit
std::atomic< bool > m_did_jit
Definition: IRExecutionUnit.h:386
ObjectFile.h
lldb_private::IRExecutionUnit::PopulateSymtab
void PopulateSymtab(lldb_private::ObjectFile *obj_file, lldb_private::Symtab &symtab) override
Definition: IRExecutionUnit.cpp:1144
lldb-private.h
lldb_private::IRExecutionUnit::ReportSymbolLookupError
void ReportSymbolLookupError(ConstString name)
Definition: IRExecutionUnit.cpp:226
lldb_private::IRExecutionUnit::CommitAllocations
bool CommitAllocations(lldb::ProcessSP &process_sp)
Commit all allocations to the process and record where they were stored.
Definition: IRExecutionUnit.cpp:1066
lldb_private::IRExecutionUnit::MemoryManager::allocateCodeSection
uint8_t * allocateCodeSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, llvm::StringRef SectionName) override
Allocate space for executable code, and add it to the m_spaceBlocks map.
Definition: IRExecutionUnit.cpp:594
lldb_private::IRExecutionUnit::m_cpu_features
std::vector< std::string > m_cpu_features
Definition: IRExecutionUnit.h:373
lldb_private::IRExecutionUnit::m_module_up
std::unique_ptr< llvm::Module > m_module_up
Holder for the module until it's been handed off.
Definition: IRExecutionUnit.h:371
lldb_private::IRExecutionUnit::MemoryManager::finalizeMemory
bool finalizeMemory(std::string *ErrMsg) override
Called when object loading is complete and section page permissions can be applied.
Definition: IRExecutionUnit.h:289
lldb_private::IRExecutionUnit::GetStaticInitializers
void GetStaticInitializers(std::vector< lldb::addr_t > &static_initializers)
Definition: IRExecutionUnit.cpp:885
lldb_private::IRExecutionUnit::GetJittedGlobalVariables
const std::vector< JittedGlobalVariable > & GetJittedGlobalVariables()
Definition: IRExecutionUnit.h:160
lldb_private::IRExecutionUnit::AllocationRecord
Encapsulates a single allocation request made by the JIT.
Definition: IRExecutionUnit.h:337
lldb_private::Status
Definition: Status.h:44
lldb_private::IRExecutionUnit::AllocationKind::Data
@ Data
lldb_private::Symtab
Definition: Symtab.h:22
uint32_t
lldb::SectionType
SectionType
Definition: lldb-enumerations.h:646
lldb_private::IRExecutionUnit::AllocationKind::Bytes
@ Bytes
lldb_private::IRExecutionUnit::FreeNow
void FreeNow(lldb::addr_t allocation)
Definition: IRExecutionUnit.cpp:91
lldb_private::IRExecutionUnit::AllocationRecord::m_process_address
lldb::addr_t m_process_address
Definition: IRExecutionUnit.h:339
lldb_private::IRExecutionUnit::m_jitted_functions
std::vector< JittedFunction > m_jitted_functions
A vector of all functions that have been JITted into machine code.
Definition: IRExecutionUnit.h:374
lldb_private::IRExecutionUnit::m_records
RecordVector m_records
Definition: IRExecutionUnit.h:365
lldb_private::IRExecutionUnit::CollectCandidateCPlusPlusNames
void CollectCandidateCPlusPlusNames(std::vector< ConstString > &CPP_names, const std::vector< ConstString > &C_names, const SymbolContext &sc)
Definition: IRExecutionUnit.cpp:662
lldb_private::IRExecutionUnit::GetRemoteRangeForLocal
AddrRange GetRemoteRangeForLocal(lldb::addr_t local_address)
Look up the object in m_address_map that contains a given address, find where it was copied to,...
Definition: IRExecutionUnit.cpp:1010
lldb_private::IRExecutionUnit::m_context_up
std::unique_ptr< llvm::LLVMContext > m_context_up
Definition: IRExecutionUnit.h:367
lldb_private::IRExecutionUnit::MemoryManager::m_default_mm_up
std::unique_ptr< SectionMemoryManager > m_default_mm_up
The memory allocator to use in actually creating space.
Definition: IRExecutionUnit.h:315
lldb_private::IRExecutionUnit::m_function_load_addr
lldb::addr_t m_function_load_addr
Definition: IRExecutionUnit.h:388
lldb_private::IRExecutionUnit::JittedEntity::m_remote_addr
lldb::addr_t m_remote_addr
The address of the function in the target's memory.
Definition: IRExecutionUnit.h:119
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:86
lldb_private::IRExecutionUnit::AllocationRecord::m_sect_type
lldb::SectionType m_sect_type
Definition: IRExecutionUnit.h:342
lldb_private::IRExecutionUnit::GetByteOrder
lldb::ByteOrder GetByteOrder() const override
ObjectFileJITDelegate overrides.
Definition: IRExecutionUnit.cpp:1134
lldb_private::IRExecutionUnit::RecordVector
std::vector< AllocationRecord > RecordVector
Definition: IRExecutionUnit.h:364
lldb_private::IRExecutionUnit::GetArchitecture
ArchSpec GetArchitecture() override
Definition: IRExecutionUnit.cpp:1168
lldb-forward.h
SymbolContext.h
lldb_private::IRExecutionUnit::FindInRuntimes
lldb::addr_t FindInRuntimes(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc)
Definition: IRExecutionUnit.cpp:816
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::IRExecutionUnit::MemoryManager::GetSymbolAddressAndPresence
uint64_t GetSymbolAddressAndPresence(const std::string &Name, bool &missing_weak)
Definition: IRExecutionUnit.cpp:953
lldb_private::IRExecutionUnit::AllocationKind::Global
@ Global
lldb_private::IRExecutionUnit::WriteNow
lldb::addr_t WriteNow(const uint8_t *bytes, size_t size, Status &error)
Accessors for IRForTarget and other clients that may want binary data placed on their behalf.
Definition: IRExecutionUnit.cpp:54
lldb_private::IRExecutionUnit::m_name
const ConstString m_name
Definition: IRExecutionUnit.h:382
lldb_private::IRExecutionUnit::MemoryManager
Definition: IRExecutionUnit.h:236
lldb_private::IRExecutionUnit::JittedEntity
Definition: IRExecutionUnit.h:115
lldb_private::IRExecutionUnit::JittedEntity::JittedEntity
JittedEntity(const char *name, lldb::addr_t local_addr=LLDB_INVALID_ADDRESS, lldb::addr_t remote_addr=LLDB_INVALID_ADDRESS)
Constructor.
Definition: IRExecutionUnit.h:135
lldb_private::IRExecutionUnit::m_execution_engine_up
std::unique_ptr< llvm::ExecutionEngine > m_execution_engine_up
Definition: IRExecutionUnit.h:368
lldb_private::IRExecutionUnit::AllocationRecord::m_host_address
uintptr_t m_host_address
Definition: IRExecutionUnit.h:340
lldb_private::IRExecutionUnit::MemoryManager::getSymbolAddress
uint64_t getSymbolAddress(const std::string &Name) override
Definition: IRExecutionUnit.cpp:947
lldb_private::IRExecutionUnit::JittedFunction::m_external
bool m_external
Definition: IRExecutionUnit.h:142
lldb_private::Log
Definition: Log.h:49
lldb_private::IRExecutionUnit::GetJITModule
lldb::ModuleSP GetJITModule()
Definition: IRExecutionUnit.cpp:1175
lldb_private::IRExecutionUnit::JittedEntity::m_name
ConstString m_name
The function's name.
Definition: IRExecutionUnit.h:116
lldb_private::IRExecutionUnit::AllocationRecord::m_permissions
uint32_t m_permissions
Definition: IRExecutionUnit.h:341
lldb_private::LineStatus::Status
@ Status
lldb_private::IRMemoryMap
Definition: IRMemoryMap.h:34
lldb_private::ObjectFile
Definition: ObjectFile.h:58
DataBufferHeap.h
lldb_private::IRExecutionUnit::m_object_cache_up
std::unique_ptr< llvm::ObjectCache > m_object_cache_up
Definition: IRExecutionUnit.h:369
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138
lldb_private::IRExecutionUnit::CommitOneAllocation
bool CommitOneAllocation(lldb::ProcessSP &process_sp, Status &error, AllocationRecord &record)
Definition: IRExecutionUnit.cpp:1024