Path: blob/main/contrib/llvm-project/llvm/lib/ExecutionEngine/Orc/Debugging/DebuggerSupport.cpp
35294 views
//===------ DebuggerSupport.cpp - Utils for enabling debugger support -----===//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/Debugging/DebuggerSupport.h"9#include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"10#include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h"11#include "llvm/ExecutionEngine/Orc/LLJIT.h"1213#define DEBUG_TYPE "orc"1415using namespace llvm;16using namespace llvm::orc;1718namespace llvm::orc {1920Error enableDebuggerSupport(LLJIT &J) {21auto *ObjLinkingLayer = dyn_cast<ObjectLinkingLayer>(&J.getObjLinkingLayer());22if (!ObjLinkingLayer)23return make_error<StringError>("Cannot enable LLJIT debugger support: "24"Debugger support requires JITLink",25inconvertibleErrorCode());26auto ProcessSymsJD = J.getProcessSymbolsJITDylib();27if (!ProcessSymsJD)28return make_error<StringError>("Cannot enable LLJIT debugger support: "29"Process symbols are not available",30inconvertibleErrorCode());3132auto &ES = J.getExecutionSession();33const auto &TT = J.getTargetTriple();3435switch (TT.getObjectFormat()) {36case Triple::ELF: {37auto Registrar = createJITLoaderGDBRegistrar(ES);38if (!Registrar)39return Registrar.takeError();40ObjLinkingLayer->addPlugin(std::make_unique<DebugObjectManagerPlugin>(41ES, std::move(*Registrar), false, true));42return Error::success();43}44case Triple::MachO: {45auto DS = GDBJITDebugInfoRegistrationPlugin::Create(ES, *ProcessSymsJD, TT);46if (!DS)47return DS.takeError();48ObjLinkingLayer->addPlugin(std::move(*DS));49return Error::success();50}51default:52return make_error<StringError>(53"Cannot enable LLJIT debugger support: " +54Triple::getObjectFormatTypeName(TT.getObjectFormat()) +55" is not supported",56inconvertibleErrorCode());57}58}5960} // namespace llvm::orc616263