Path: blob/main/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/EPCDebugObjectRegistrar.cpp
35269 views
//===----- EPCDebugObjectRegistrar.cpp - EPC-based debug registration -----===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"910#include "llvm/ExecutionEngine/Orc/Core.h"11#include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"12#include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"13#include "llvm/Support/BinaryStreamWriter.h"1415namespace llvm {16namespace orc {1718Expected<std::unique_ptr<EPCDebugObjectRegistrar>> createJITLoaderGDBRegistrar(19ExecutionSession &ES,20std::optional<ExecutorAddr> RegistrationFunctionDylib) {21auto &EPC = ES.getExecutorProcessControl();2223if (!RegistrationFunctionDylib) {24if (auto D = EPC.loadDylib(nullptr))25RegistrationFunctionDylib = *D;26else27return D.takeError();28}2930SymbolStringPtr RegisterFn =31EPC.getTargetTriple().isOSBinFormatMachO()32? EPC.intern("_llvm_orc_registerJITLoaderGDBWrapper")33: EPC.intern("llvm_orc_registerJITLoaderGDBWrapper");3435SymbolLookupSet RegistrationSymbols;36RegistrationSymbols.add(RegisterFn);3738auto Result =39EPC.lookupSymbols({{*RegistrationFunctionDylib, RegistrationSymbols}});40if (!Result)41return Result.takeError();4243assert(Result->size() == 1 && "Unexpected number of dylibs in result");44assert((*Result)[0].size() == 1 &&45"Unexpected number of addresses in result");4647ExecutorAddr RegisterAddr = (*Result)[0][0].getAddress();48return std::make_unique<EPCDebugObjectRegistrar>(ES, RegisterAddr);49}5051Error EPCDebugObjectRegistrar::registerDebugObject(ExecutorAddrRange TargetMem,52bool AutoRegisterCode) {53return ES.callSPSWrapper<void(shared::SPSExecutorAddrRange, bool)>(54RegisterFn, TargetMem, AutoRegisterCode);55}5657} // namespace orc58} // namespace llvm596061