[llvm-shlib] Fix the version naming style of libLLVM for Windows (#85710)
[llvm-project.git] / llvm / lib / ExecutionEngine / Orc / Debugging / DebuggerSupport.cpp
blob1668473c0eb47498e08e867ed670cc74c69d4ce4
1 //===------ DebuggerSupport.cpp - Utils for enabling debugger support -----===//
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 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupport.h"
10 #include "llvm/ExecutionEngine/Orc/DebugObjectManagerPlugin.h"
11 #include "llvm/ExecutionEngine/Orc/Debugging/DebuggerSupportPlugin.h"
12 #include "llvm/ExecutionEngine/Orc/LLJIT.h"
14 #define DEBUG_TYPE "orc"
16 using namespace llvm;
17 using namespace llvm::orc;
19 namespace llvm::orc {
21 Error enableDebuggerSupport(LLJIT &J) {
22 auto *ObjLinkingLayer = dyn_cast<ObjectLinkingLayer>(&J.getObjLinkingLayer());
23 if (!ObjLinkingLayer)
24 return make_error<StringError>("Cannot enable LLJIT debugger support: "
25 "Debugger support requires JITLink",
26 inconvertibleErrorCode());
27 auto ProcessSymsJD = J.getProcessSymbolsJITDylib();
28 if (!ProcessSymsJD)
29 return make_error<StringError>("Cannot enable LLJIT debugger support: "
30 "Process symbols are not available",
31 inconvertibleErrorCode());
33 auto &ES = J.getExecutionSession();
34 const auto &TT = J.getTargetTriple();
36 switch (TT.getObjectFormat()) {
37 case Triple::ELF: {
38 auto Registrar = createJITLoaderGDBRegistrar(ES);
39 if (!Registrar)
40 return Registrar.takeError();
41 ObjLinkingLayer->addPlugin(std::make_unique<DebugObjectManagerPlugin>(
42 ES, std::move(*Registrar), false, true));
43 return Error::success();
45 case Triple::MachO: {
46 auto DS = GDBJITDebugInfoRegistrationPlugin::Create(ES, *ProcessSymsJD, TT);
47 if (!DS)
48 return DS.takeError();
49 ObjLinkingLayer->addPlugin(std::move(*DS));
50 return Error::success();
52 default:
53 return make_error<StringError>(
54 "Cannot enable LLJIT debugger support: " +
55 Triple::getObjectFormatTypeName(TT.getObjectFormat()) +
56 " is not supported",
57 inconvertibleErrorCode());
61 } // namespace llvm::orc