9#include "llvm/ExecutionEngine/ExecutionEngine.h" 
   10#include "llvm/ExecutionEngine/ObjectCache.h" 
   11#include "llvm/IR/Constants.h" 
   12#include "llvm/IR/DiagnosticHandler.h" 
   13#include "llvm/IR/DiagnosticInfo.h" 
   14#include "llvm/IR/LLVMContext.h" 
   15#include "llvm/IR/Module.h" 
   16#include "llvm/Support/Error.h" 
   17#include "llvm/Support/SourceMgr.h" 
   18#include "llvm/Support/raw_ostream.h" 
   48                                 std::unique_ptr<llvm::Module> &module_up,
 
   52                                 std::vector<std::string> &cpu_features)
 
 
   62  const bool zero_memory = 
false;
 
   63  auto address_or_error =
 
   64      Malloc(size, 8, lldb::ePermissionsWritable | lldb::ePermissionsReadable,
 
   66  if (!address_or_error) {
 
   70  lldb::addr_t allocation_process_addr = *address_or_error;
 
   74  if (!
error.Success()) {
 
   76    Free(allocation_process_addr, err);
 
   90                            allocation_process_addr, 16,
 
   95  return allocation_process_addr;
 
 
  104  Free(allocation, err);
 
 
  121    if (function.m_name == 
m_name) {
 
  122      func_local_addr = function.m_local_addr;
 
  123      func_remote_addr = function.m_remote_addr;
 
  129        "Couldn't find function %s for disassembly", 
m_name.AsCString());
 
  134            "Found function, has local address 0x%" PRIx64
 
  135            " and remote address 0x%" PRIx64,
 
  136            (uint64_t)func_local_addr, (uint64_t)func_remote_addr);
 
  138  std::pair<lldb::addr_t, lldb::addr_t> func_range;
 
  142  if (func_range.first == 0 && func_range.second == 0) {
 
  144        "Couldn't find code range for function %s", 
m_name.AsCString());
 
  148  LLDB_LOGF(log, 
"Function's code range is [0x%" PRIx64 
"+0x%" PRIx64 
"]",
 
  149            func_range.first, func_range.second);
 
  162  process->
ReadMemory(func_remote_addr, buffer_sp->GetBytes(),
 
  163                      buffer_sp->GetByteSize(), err);
 
  173  const char *plugin_name = 
nullptr;
 
  174  const char *flavor_string = 
nullptr;
 
  175  const char *cpu_string = 
nullptr;
 
  176  const char *features_string = 
nullptr;
 
  178      arch, flavor_string, cpu_string, features_string, plugin_name);
 
  180  if (!disassembler_sp) {
 
  182        "Unable to find disassembler plug-in for %s architecture.",
 
  196    LLDB_LOGF(log, 
"Function data has contents:");
 
  201  disassembler_sp->DecodeInstructions(
Address(func_remote_addr), extractor, 0,
 
  204  InstructionList &instruction_list = disassembler_sp->GetInstructionList();
 
  205  instruction_list.
Dump(&stream, 
true, 
true, 
false,
 
 
  212struct IRExecDiagnosticHandler : 
public llvm::DiagnosticHandler {
 
  214  IRExecDiagnosticHandler(
Status *err) : err(err) {}
 
  215  bool handleDiagnostics(
const llvm::DiagnosticInfo &DI)
 override {
 
  216    if (DI.getSeverity() == llvm::DS_Error) {
 
  217      const auto &DISM = llvm::cast<llvm::DiagnosticInfoSrcMgr>(DI);
 
  220            "IRExecution error: %s",
 
  221            DISM.getSMDiag().getMessage().str().c_str());
 
  238  static std::recursive_mutex s_runnable_info_mutex;
 
  246                                "process because the process is invalid");
 
  257  std::lock_guard<std::recursive_mutex> guard(s_runnable_info_mutex);
 
  263  std::string error_string;
 
  267    llvm::raw_string_ostream oss(s);
 
  271    LLDB_LOGF(log, 
"Module being sent to JIT: \n%s", s.c_str());
 
  275      std::make_unique<IRExecDiagnosticHandler>(&
error));
 
  277  llvm::EngineBuilder builder(std::move(
m_module_up));
 
  278  llvm::Triple triple(
m_module->getTargetTriple());
 
  280  builder.setEngineKind(llvm::EngineKind::JIT)
 
  281      .setErrorStr(&error_string)
 
  282      .setRelocationModel(triple.isOSBinFormatMachO() ? llvm::Reloc::PIC_
 
  283                                                      : llvm::Reloc::Static)
 
  284      .setMCJITMemoryManager(std::make_unique<MemoryManager>(*
this))
 
  285      .setOptLevel(llvm::CodeGenOptLevel::Less);
 
  290  if (triple.isRISCV64())
 
  291    builder.setCodeModel(llvm::CodeModel::Large);
 
  293  llvm::StringRef mArch;
 
  294  llvm::StringRef mCPU;
 
  295  llvm::SmallVector<std::string, 0> mAttrs;
 
  298    mAttrs.push_back(feature);
 
  300  llvm::TargetMachine *target_machine =
 
  301      builder.selectTarget(triple, mArch, mCPU, mAttrs);
 
  307                                              error_string.c_str());
 
  314  class ObjectDumper : 
public llvm::ObjectCache {
 
  316    ObjectDumper(
FileSpec output_dir)  : m_out_dir(output_dir) {}
 
  317    void notifyObjectCompiled(
const llvm::Module *module,
 
  318                              llvm::MemoryBufferRef 
object)
 override {
 
  320      llvm::SmallVector<char, 256> result_path;
 
  321      std::string object_name_model =
 
  322          "jit-object-" + 
module->getModuleIdentifier() + "-%%%.o";
 
  325      std::string model_path = model_spec.
GetPath();
 
  327      std::error_code result 
 
  328        = llvm::sys::fs::createUniqueFile(model_path, fd, result_path);
 
  330          llvm::raw_fd_ostream fds(fd, 
true);
 
  331          fds.write(
object.getBufferStart(), 
object.getBufferSize());
 
  334    std::unique_ptr<llvm::MemoryBuffer>
 
  335    getObject(
const llvm::Module *module)
 override  {
 
  344  FileSpec save_objects_dir = process_sp->GetTarget().GetSaveJITObjectsDir();
 
  345  if (save_objects_dir) {
 
  356  for (llvm::Function &function : *
m_module) {
 
  357    if (function.isDeclaration() || function.hasPrivateLinkage())
 
  360    const bool external = !function.hasLocalLinkage();
 
  364    if (!
error.Success()) {
 
  371          "'%s' was in the JITted module but wasn't lowered",
 
  372          function.getName().str().c_str());
 
  376        function.getName().str().c_str(), external, 
reinterpret_cast<uintptr_t
>(fun_ptr)));
 
  388  std::function<void(llvm::GlobalValue &)> RegisterOneValue = [
this](
 
  389      llvm::GlobalValue &val) {
 
  390    if (val.hasExternalLinkage() && !val.isDeclaration()) {
 
  391      uint64_t var_ptr_addr =
 
  401        remote_addr = var_ptr_addr;
 
  404      if (var_ptr_addr != 0)
 
  410  for (llvm::GlobalVariable &global_var : 
m_module->globals()) {
 
  411    RegisterOneValue(global_var);
 
  414  for (llvm::GlobalAlias &global_alias : 
m_module->aliases()) {
 
  415    RegisterOneValue(global_alias);
 
  425    bool emitNewLine = 
false;
 
  437        "\nHint: The expression tried to call a function that is not present " 
  438        "in the target, perhaps because it was optimized out by the compiler.");
 
  448    jitted_function.m_remote_addr =
 
  451    if (!
m_name.IsEmpty() && jitted_function.m_name == 
m_name) {
 
  460    LLDB_LOGF(log, 
"Code can be run in the target.");
 
  467      LLDB_LOGF(log, 
"Couldn't disassemble function : %s",
 
  488                                record.m_process_address, 16,
 
  494        DataExtractor my_extractor((
const void *)record.m_host_address,
 
  496        my_extractor.
PutToLog(log, 0, record.m_size, record.m_host_address, 16,
 
 
  520  switch (alloc_kind) {
 
  539    if (name == 
"__text" || name == 
".text")
 
  541    else if (name == 
"__data" || name == 
".data")
 
  543    else if (name.starts_with(
"__debug_") || name.starts_with(
".debug_")) {
 
  544      const uint32_t name_idx = name[0] == 
'_' ? 8 : 7;
 
  545      llvm::StringRef dwarf_name(name.substr(name_idx));
 
  547    } 
else if (name.starts_with(
"__apple_") || name.starts_with(
".apple_"))
 
  549    else if (name == 
"__objc_imageinfo")
 
 
  556    uintptr_t Size, 
unsigned Alignment, 
unsigned SectionID,
 
  557    llvm::StringRef SectionName) {
 
  561      Size, Alignment, SectionID, SectionName);
 
  564      (uintptr_t)return_value,
 
  565      lldb::ePermissionsReadable | lldb::ePermissionsExecutable,
 
  567      Alignment, SectionID, SectionName.str().c_str()));
 
  570            "IRExecutionUnit::allocateCodeSection(Size=0x%" PRIx64
 
  571            ", Alignment=%u, SectionID=%u) = %p",
 
  572            (uint64_t)Size, Alignment, SectionID, (
void *)return_value);
 
  574  if (
m_parent.m_reported_allocations) {
 
  577        m_parent.GetBestExecutionContextScope()->CalculateProcess();
 
 
  586    uintptr_t Size, 
unsigned Alignment, 
unsigned SectionID,
 
  587    llvm::StringRef SectionName, 
bool IsReadOnly) {
 
  591      Size, Alignment, SectionID, SectionName, IsReadOnly);
 
  593  uint32_t permissions = lldb::ePermissionsReadable;
 
  595    permissions |= lldb::ePermissionsWritable;
 
  597      (uintptr_t)return_value, permissions,
 
  599      Alignment, SectionID, SectionName.str().c_str()));
 
  601            "IRExecutionUnit::allocateDataSection(Size=0x%" PRIx64
 
  602            ", Alignment=%u, SectionID=%u) = %p",
 
  603            (uint64_t)Size, Alignment, SectionID, (
void *)return_value);
 
  605  if (
m_parent.m_reported_allocations) {
 
  608        m_parent.GetBestExecutionContextScope()->CalculateProcess();
 
 
  620  C_names.push_back(name);
 
 
  624    std::vector<ConstString> &CPP_names,
 
  625    const std::vector<ConstString> &C_names, 
const SymbolContext &sc) {
 
  629      if (cpp_lang->SymbolNameFitsToLanguage(mangled)) {
 
  631                cpp_lang->FindBestAlternateFunctionMangledName(mangled, sc)) {
 
  632          CPP_names.push_back(best_alternate);
 
  636      std::vector<ConstString> alternates =
 
  637          cpp_lang->GenerateAlternateFunctionManglings(name);
 
  638      CPP_names.insert(CPP_names.end(), alternates.begin(), alternates.end());
 
  643          cpp_lang->GetDemangledFunctionNameWithoutArguments(mangled);
 
  644      CPP_names.push_back(basename);
 
 
  666      if (!candidate_sc.symbol ||
 
  668          !candidate_sc.symbol->IsWeak())
 
  672      if (candidate_sc.symbol) {
 
  673        load_address = candidate_sc.symbol->ResolveCallableAddress(
m_target);
 
  675          Address addr = candidate_sc.symbol->GetAddress();
 
  676          load_address = 
m_target.GetProcessSP()
 
  684        Address addr = candidate_sc.function->GetAddress();
 
  685        load_address = 
m_target.GetProcessSP()
 
  693        const bool is_external =
 
  694            (candidate_sc.function) ||
 
  695            (candidate_sc.symbol && candidate_sc.symbol->IsExternal());
 
 
 
  725static llvm::Expected<lldb::addr_t>
 
  728                         bool &symbol_was_missing_weak) {
 
  729  symbol_was_missing_weak = 
false;
 
  732    return llvm::createStringError(
"target not available.");
 
  736    return llvm::createStringError(
 
  737        llvm::formatv(
"failed to find module by UID {0}", label.
module_id));
 
  739  auto *symbol_file = module_sp->GetSymbolFile();
 
  741    return llvm::createStringError(
 
  742        llvm::formatv(
"no SymbolFile found on module {0:x}.", module_sp.get()));
 
  744  auto sc_or_err = symbol_file->ResolveFunctionCallLabel(label);
 
  746    return llvm::joinErrors(
 
  747        llvm::createStringError(
"failed to resolve function by UID:"),
 
  748        sc_or_err.takeError());
 
  751  sc_list.
Append(*sc_or_err);
 
  757    return llvm::createStringError(
"couldn't resolve address for function");
 
  759  return resolved_addr;
 
 
  765                               bool &symbol_was_missing_weak) {
 
  766  symbol_was_missing_weak = 
false;
 
  798                                  lldb::eFunctionNameTypeFull, function_options,
 
  800      if (
auto load_addr = resolver.
Resolve(sc_list))
 
  807                                        function_options, sc_list);
 
  808      if (
auto load_addr = resolver.
Resolve(sc_list))
 
  814      non_local_images.
FindFunctions(name, lldb::eFunctionNameTypeFull,
 
  815                                     function_options, sc_list);
 
  816      if (
auto load_addr = resolver.
Resolve(sc_list))
 
  824      if (
auto load_addr = resolver.
Resolve(sc_list))
 
  832      if (
auto load_addr = resolver.
Resolve(sc_list))
 
  840      if (
auto load_addr = resolver.
Resolve(sc_list))
 
  847      return best_internal_load_address;
 
 
  870      lldb::addr_t symbol_load_addr = runtime->LookupRuntimeSymbol(name);
 
  873        return symbol_load_addr;
 
 
  881    const std::vector<ConstString> &names,
 
  886    lldb::addr_t symbol_load_addr = target_sp->GetPersistentSymbol(name);
 
  889      return symbol_load_addr;
 
 
  896                                         bool &missing_weak) {
 
  901                     "failed to create FunctionCallLabel from '{1}': {0}",
 
  906    if (
auto addr_or_err =
 
  911                     "Failed to resolve function call label '{1}': {0}",
 
  918      name.
SetString(label_or_err->lookup_name);
 
  925  std::vector<ConstString> candidate_C_names;
 
  926  std::vector<ConstString> candidate_CPlusPlus_names;
 
  936  missing_weak = 
false;
 
 
  952    std::vector<lldb::addr_t> &static_initializers) {
 
  955  llvm::GlobalVariable *global_ctors =
 
  956      m_module->getNamedGlobal(
"llvm.global_ctors");
 
  958    LLDB_LOG(log, 
"Couldn't find llvm.global_ctors.");
 
  962      llvm::dyn_cast<llvm::ConstantArray>(global_ctors->getInitializer());
 
  964    LLDB_LOG(log, 
"llvm.global_ctors not a ConstantArray.");
 
  968  for (llvm::Use &ctor_use : ctor_array->operands()) {
 
  969    auto *ctor_struct = llvm::dyn_cast<llvm::ConstantStruct>(ctor_use);
 
  973    lldbassert(ctor_struct->getNumOperands() == 3);
 
  974    auto *ctor_function =
 
  975        llvm::dyn_cast<llvm::Function>(ctor_struct->getOperand(1));
 
  976    if (!ctor_function) {
 
  977      LLDB_LOG(log, 
"global_ctor doesn't contain an llvm::Function");
 
  981    ConstString ctor_function_name(ctor_function->getName().str());
 
  982    LLDB_LOG(log, 
"Looking for callable jitted function with name {0}.",
 
  986      if (ctor_function_name != jitted_function.m_name)
 
  989        LLDB_LOG(log, 
"Found jitted function with invalid address.");
 
  992      static_initializers.push_back(jitted_function.m_remote_addr);
 
  993      LLDB_LOG(log, 
"Calling function at address {0:x}.",
 
  994               jitted_function.m_remote_addr);
 
 
 1002    bool missing_weak = 
false;
 
 1006      return llvm::JITSymbol(addr, 
 
 1007          llvm::JITSymbolFlags::Exported | llvm::JITSymbolFlags::Weak);
 
 1009      return llvm::JITSymbol(addr, llvm::JITSymbolFlags::Exported);
 
 
 1014  bool missing_weak = 
false;
 
 
 1020    const std::string &Name, 
bool &missing_weak) {
 
 1029              "IRExecutionUnit::getSymbolAddress(Name=\"%s\") = <not found>",
 
 1032    m_parent.ReportSymbolLookupError(name_cs);
 
 1035    LLDB_LOGF(log, 
"IRExecutionUnit::getSymbolAddress(Name=\"%s\") = %" PRIx64,
 
 
 1042    const std::string &Name, 
bool AbortOnFailure) {
 
 
 1051    if (local_address >= record.m_host_address &&
 
 1052        local_address < record.m_host_address + record.m_size) {
 
 1057          record.m_process_address + (local_address - record.m_host_address);
 
 1060                "IRExecutionUnit::GetRemoteAddressForLocal() found 0x%" PRIx64
 
 1061                " in [0x%" PRIx64 
"..0x%" PRIx64 
"], and returned 0x%" PRIx64
 
 1062                " from [0x%" PRIx64 
"..0x%" PRIx64 
"].",
 
 1063                local_address, (uint64_t)record.m_host_address,
 
 1064                (uint64_t)record.m_host_address + (uint64_t)record.m_size, ret,
 
 1065                record.m_process_address,
 
 1066                record.m_process_address + record.m_size);
 
 
 1078    if (local_address >= record.m_host_address &&
 
 1079        local_address < record.m_host_address + record.m_size) {
 
 1083      return AddrRange(record.m_process_address, record.m_size);
 
 
 1122    const bool zero_memory = 
false;
 
 1123    if (
auto address_or_error =
 
 1132  return error.Success();
 
 
 1151        Free(record.m_process_address, err);
 
 
 1170    engine.mapSectionAddress((
void *)record.m_host_address,
 
 1171                             record.m_process_address);
 
 1175  engine.finalizeObject();
 
 
 1179  bool wrote_something = 
false;
 
 1183      WriteMemory(record.m_process_address, (uint8_t *)record.m_host_address,
 
 1184                  record.m_size, err);
 
 1186        wrote_something = 
true;
 
 1189  return wrote_something;
 
 
 1197            "[0x%llx+0x%llx]->0x%llx (alignment %d, section ID %d, name %s)",
 
 
 1222    if (record.m_size > 0) {
 
 1224          obj_file->
GetModule(), obj_file, record.m_section_id,
 
 1226          record.m_process_address, record.m_size,
 
 1227          record.m_host_address, 
 
 1231          record.m_permissions)); 
 
 
 1240    return target->GetArchitecture();
 
 
 1250  auto Delegate = std::static_pointer_cast<lldb_private::ObjectFileJITDelegate>(
 
 1251      shared_from_this());
 
 1258  bool changed = 
false;
 
 1259  jit_module_sp->SetLoadAddress(*target, 0, 
true, changed);
 
 1260  return jit_module_sp;
 
 
static llvm::raw_ostream & error(Stream &strm)
static llvm::Expected< lldb::addr_t > ResolveFunctionCallLabel(FunctionCallLabel &label, const lldb_private::SymbolContext &sc, bool &symbol_was_missing_weak)
Returns address of the function referred to by the special function call label label.
#define LLDB_LOG(log,...)
The LLDB_LOG* macros defined below are the way to emit log messages.
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
LoadAddressResolver(Target &target, bool &symbol_was_missing_weak)
lldb::addr_t m_best_internal_load_address
bool & m_symbol_was_missing_weak
std::optional< lldb::addr_t > Resolve(SymbolContextList &sc_list)
lldb::addr_t GetBestInternalLoadAddress() const
A section + offset based address class.
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
lldb::addr_t GetCallableLoadAddress(Target *target, bool is_indirect=false) const
Get the load address as a callable code load address.
lldb::addr_t GetFileAddress() const
Get the file address.
An architecture specification class.
uint32_t GetAddressByteSize() const
Returns the size in bytes of an address of the current architecture.
const char * GetArchitectureName() const
Returns a static string representing the current architecture.
Represents a generic declaration context in a program.
A uniqued constant string class.
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
llvm::StringRef GetStringRef() const
Get the string value as a llvm::StringRef.
void SetString(llvm::StringRef s)
A subclass of DataBuffer that stores a data buffer on the heap.
lldb::offset_t GetByteSize() const override
Get the number of bytes in the data buffer.
static lldb::DisassemblerSP FindPlugin(const ArchSpec &arch, const char *flavor, const char *cpu, const char *features, const char *plugin_name)
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
uint32_t GetAddressByteSize() const
lldb::ByteOrder GetByteOrder() const
Target * GetTargetPtr() const
Returns a pointer to the target object.
Process * GetProcessPtr() const
Returns a pointer to the process object.
FileSpec CopyByAppendingPathComponent(llvm::StringRef component) const
size_t GetPath(char *path, size_t max_path_length, bool denormalize=true) const
Extract the full path to the file.
void * getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure=true) override
std::unique_ptr< SectionMemoryManager > m_default_mm_up
The memory allocator to use in actually creating space.
uint64_t getSymbolAddress(const std::string &Name) override
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.
IRExecutionUnit & m_parent
The execution unit this is a proxy for.
~MemoryManager() override
uint64_t GetSymbolAddressAndPresence(const std::string &Name, bool &missing_weak)
llvm::JITSymbol findSymbol(const std::string &Name) override
MemoryManager(IRExecutionUnit &parent)
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.
std::vector< std::string > m_cpu_features
void CollectCandidateCPlusPlusNames(std::vector< ConstString > &CPP_names, const std::vector< ConstString > &C_names, const SymbolContext &sc)
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.
static const unsigned eSectionIDInvalid
ModuleList m_preferred_modules
void PopulateSymtab(lldb_private::ObjectFile *obj_file, lldb_private::Symtab &symtab) override
lldb::addr_t FindInSymbols(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc, bool &symbol_was_missing_weak)
void GetRunnableInfo(Status &error, lldb::addr_t &func_addr, lldb::addr_t &func_end)
lldb::ByteOrder GetByteOrder() const override
ObjectFileJITDelegate overrides.
SymbolContext m_sym_ctx
Used for symbol lookups.
std::vector< JittedFunction > m_jitted_functions
A vector of all functions that have been JITted into machine code.
Status DisassembleFunction(Stream &stream, lldb::ProcessSP &process_sp)
std::vector< ConstString > m_failed_lookups
std::unique_ptr< llvm::Module > m_module_up
Holder for the module until it's been handed off.
lldb::addr_t FindSymbol(ConstString name, bool &missing_weak)
lldb::addr_t FindInRuntimes(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc)
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.
static lldb::SectionType GetSectionTypeFromSectionName(const llvm::StringRef &name, AllocationKind alloc_kind)
uint32_t GetAddressByteSize() const override
bool CommitAllocations(lldb::ProcessSP &process_sp)
Commit all allocations to the process and record where they were stored.
bool CommitOneAllocation(lldb::ProcessSP &process_sp, Status &error, AllocationRecord &record)
void GetStaticInitializers(std::vector< lldb::addr_t > &static_initializers)
void CollectCandidateCNames(std::vector< ConstString > &C_names, ConstString name)
std::unique_ptr< llvm::ExecutionEngine > m_execution_engine_up
llvm::Module * m_module
Owned by the execution engine.
std::unique_ptr< llvm::LLVMContext > m_context_up
ArchSpec GetArchitecture() override
lldb::addr_t m_function_load_addr
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,...
bool m_strip_underscore
True for platforms where global symbols have a _ prefix.
void ReportSymbolLookupError(ConstString name)
lldb::addr_t FindInUserDefinedSymbols(const std::vector< ConstString > &names, const lldb_private::SymbolContext &sc)
lldb::addr_t m_function_end_load_addr
void PopulateSectionList(lldb_private::ObjectFile *obj_file, lldb_private::SectionList §ion_list) override
std::pair< lldb::addr_t, uintptr_t > AddrRange
void FreeNow(lldb::addr_t allocation)
std::atomic< bool > m_did_jit
std::vector< JittedGlobalVariable > m_jitted_global_variables
A vector of all functions that have been JITted into machine code.
bool WriteData(lldb::ProcessSP &process_sp)
Write the contents of all allocations to the process.
std::unique_ptr< llvm::ObjectCache > m_object_cache_up
~IRExecutionUnit() override
Destructor.
lldb::ModuleSP GetJITModule()
void ReportAllocations(llvm::ExecutionEngine &engine)
Report all committed allocations to the execution engine.
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,...
bool m_reported_allocations
True after allocations have been reported.
void Free(lldb::addr_t process_address, Status &error)
llvm::Expected< lldb::addr_t > Malloc(size_t size, uint8_t alignment, uint32_t permissions, AllocationPolicy policy, bool zero_memory, AllocationPolicy *used_policy=nullptr)
ExecutionContextScope * GetBestExecutionContextScope() const
lldb::ProcessWP & GetProcessWP()
IRMemoryMap(lldb::TargetSP target_sp)
void WriteMemory(lldb::addr_t process_address, const uint8_t *bytes, size_t size, Status &error)
void ReadMemory(uint8_t *bytes, lldb::addr_t process_address, size_t size, Status &error)
@ eAllocationPolicyProcessOnly
The intent is that this allocation exist only in the process.
@ eAllocationPolicyMirror
The intent is that this allocation exist both in the host and the process and have the same content i...
void Dump(Stream *s, bool show_address, bool show_bytes, bool show_control_flow_kind, const ExecutionContext *exe_ctx)
static Language * FindPlugin(lldb::LanguageType language)
A class that handles mangled names.
lldb::ModuleSP GetModule() const
Get const accessor for the module pointer.
A collection class for Module objects.
void FindFunctions(ConstString name, lldb::FunctionNameType name_type_mask, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list) const
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list) const
bool Remove(const lldb::ModuleSP &module_sp, bool notify=true)
Remove a module from the module list.
static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args)
A plug-in interface definition class for object file parsers.
static lldb::SectionType GetDWARFSectionTypeFromName(llvm::StringRef name)
Parses the section type from a section name for DWARF sections.
A plug-in interface definition class for debugging a process.
virtual size_t ReadMemory(lldb::addr_t vm_addr, void *buf, size_t size, Status &error)
Read of memory from a process.
lldb::ByteOrder GetByteOrder() const
size_t AddSection(const lldb::SectionSP §ion_sp)
void Clear()
Clear the object state.
static Status FromErrorStringWithFormat(const char *format,...) __attribute__((format(printf
static Status FromErrorString(const char *str)
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
bool Success() const
Test for success condition.
const char * GetData() const
llvm::StringRef GetString() const
A stream class that can stream formatted output to a file.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Defines a list of symbol context objects.
void Append(const SymbolContext &sc)
Append a new symbol context to the list.
SymbolContextIterable SymbolContexts()
Defines a symbol context baton that can be handed other debug core functions.
lldb::ModuleSP module_sp
The Module for a given query.
lldb::TargetSP target_sp
The Target for a given query.
const ModuleList & GetImages() const
Get accessor for the images for this process.
const ArchSpec & GetArchitecture() const
uint8_t * GetBytes()
Get a pointer to the data.
#define LLDB_INVALID_ADDRESS
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
constexpr llvm::StringRef FunctionCallLabelPrefix
LLDB attaches this prefix to mangled names of functions that get called from JITted expressions.
@ eLanguageTypeC_plus_plus
ISO C++:1998.
std::shared_ptr< lldb_private::Process > ProcessSP
std::shared_ptr< lldb_private::Disassembler > DisassemblerSP
ByteOrder
Byte ordering definitions.
std::shared_ptr< lldb_private::Section > SectionSP
std::shared_ptr< lldb_private::WritableDataBuffer > WritableDataBufferSP
std::shared_ptr< lldb_private::Target > TargetSP
@ eSectionTypeDWARFDebugStrOffsets
@ eSectionTypeDWARFDebugPubNames
@ eSectionTypeDWARFDebugFrame
@ eSectionTypeDWARFDebugLocLists
DWARF v5 .debug_loclists.
@ eSectionTypeDWARFDebugMacInfo
@ eSectionTypeDWARFAppleNamespaces
@ eSectionTypeDWARFAppleTypes
@ eSectionTypeDWARFDebugInfo
@ eSectionTypeDWARFDebugRanges
@ eSectionTypeDWARFDebugLine
@ eSectionTypeDWARFDebugPubTypes
@ eSectionTypeDWARFDebugStr
@ eSectionTypeDWARFDebugLoc
@ eSectionTypeDWARFAppleNames
@ eSectionTypeDWARFAppleObjC
@ eSectionTypeDWARFDebugCuIndex
@ eSectionTypeDWARFDebugAranges
@ eSectionTypeDWARFGNUDebugAltLink
@ eSectionTypeDWARFDebugAbbrev
@ eSectionTypeDWARFDebugAddr
std::shared_ptr< lldb_private::Module > ModuleSP
Holds parsed information about a function call label that LLDB attaches as an AsmLabel to function AS...
static llvm::Expected< FunctionCallLabel > fromString(llvm::StringRef label)
Decodes the specified function label into a FunctionCallLabel.
lldb::user_id_t module_id
Unique identifier of the lldb_private::Module which contains the symbol identified by symbol_id.
Encapsulates a single allocation request made by the JIT.
lldb::SectionType m_sect_type
lldb::addr_t m_process_address
"lldb/Expression/IRExecutionUnit.h" Encapsulates a single function that has been generated by the JIT...
Options used by Module::FindFunctions.
bool include_inlines
Include inlined functions.
bool include_symbols
Include the symbol table.