1 //===----- EPCDebugObjectRegistrar.cpp - EPC-based debug registration -----===//
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
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ExecutionEngine/Orc/EPCDebugObjectRegistrar.h"
11 #include "llvm/ExecutionEngine/Orc/Core.h"
16 Expected
<std::unique_ptr
<EPCDebugObjectRegistrar
>> createJITLoaderGDBRegistrar(
18 std::optional
<ExecutorAddr
> RegistrationFunctionDylib
) {
19 auto &EPC
= ES
.getExecutorProcessControl();
21 if (!RegistrationFunctionDylib
) {
22 if (auto D
= EPC
.getDylibMgr().loadDylib(nullptr))
23 RegistrationFunctionDylib
= *D
;
28 SymbolStringPtr RegisterFn
=
29 EPC
.getTargetTriple().isOSBinFormatMachO()
30 ? EPC
.intern("_llvm_orc_registerJITLoaderGDBWrapper")
31 : EPC
.intern("llvm_orc_registerJITLoaderGDBWrapper");
33 SymbolLookupSet RegistrationSymbols
;
34 RegistrationSymbols
.add(RegisterFn
);
36 auto Result
= EPC
.getDylibMgr().lookupSymbols(
37 {{*RegistrationFunctionDylib
, RegistrationSymbols
}});
39 return Result
.takeError();
41 assert(Result
->size() == 1 && "Unexpected number of dylibs in result");
42 assert((*Result
)[0].size() == 1 &&
43 "Unexpected number of addresses in result");
45 ExecutorAddr RegisterAddr
= (*Result
)[0][0].getAddress();
46 return std::make_unique
<EPCDebugObjectRegistrar
>(ES
, RegisterAddr
);
49 Error
EPCDebugObjectRegistrar::registerDebugObject(ExecutorAddrRange TargetMem
,
50 bool AutoRegisterCode
) {
51 return ES
.callSPSWrapper
<void(shared::SPSExecutorAddrRange
, bool)>(
52 RegisterFn
, TargetMem
, AutoRegisterCode
);