AMDGPU: Mark test as XFAIL in expensive_checks builds
[llvm-project.git] / llvm / lib / ExecutionEngine / Orc / EPCDebugObjectRegistrar.cpp
blob9f7d517d481d4b0eaae9bca4a5663863f99f62d3
1 //===----- EPCDebugObjectRegistrar.cpp - EPC-based debug registration -----===//
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/EPCDebugObjectRegistrar.h"
11 #include "llvm/ExecutionEngine/Orc/Core.h"
13 namespace llvm {
14 namespace orc {
16 Expected<std::unique_ptr<EPCDebugObjectRegistrar>> createJITLoaderGDBRegistrar(
17 ExecutionSession &ES,
18 std::optional<ExecutorAddr> RegistrationFunctionDylib) {
19 auto &EPC = ES.getExecutorProcessControl();
21 if (!RegistrationFunctionDylib) {
22 if (auto D = EPC.getDylibMgr().loadDylib(nullptr))
23 RegistrationFunctionDylib = *D;
24 else
25 return D.takeError();
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}});
38 if (!Result)
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);
55 } // namespace orc
56 } // namespace llvm