LLVM 20.0.0git
EPCDebugObjectRegistrar.cpp
Go to the documentation of this file.
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//===----------------------------------------------------------------------===//
8
10
12
13namespace llvm {
14namespace orc {
15
18 std::optional<ExecutorAddr> RegistrationFunctionDylib) {
19 auto &EPC = ES.getExecutorProcessControl();
20
21 if (!RegistrationFunctionDylib) {
22 if (auto D = EPC.getDylibMgr().loadDylib(nullptr))
23 RegistrationFunctionDylib = *D;
24 else
25 return D.takeError();
26 }
27
28 SymbolStringPtr RegisterFn =
29 EPC.getTargetTriple().isOSBinFormatMachO()
30 ? EPC.intern("_llvm_orc_registerJITLoaderGDBWrapper")
31 : EPC.intern("llvm_orc_registerJITLoaderGDBWrapper");
32
33 SymbolLookupSet RegistrationSymbols;
34 RegistrationSymbols.add(RegisterFn);
35
36 auto Result = EPC.getDylibMgr().lookupSymbols(
37 {{*RegistrationFunctionDylib, RegistrationSymbols}});
38 if (!Result)
39 return Result.takeError();
40
41 assert(Result->size() == 1 && "Unexpected number of dylibs in result");
42 assert((*Result)[0].size() == 1 &&
43 "Unexpected number of addresses in result");
44
45 ExecutorAddr RegisterAddr = (*Result)[0][0].getAddress();
46 return std::make_unique<EPCDebugObjectRegistrar>(ES, RegisterAddr);
47}
48
50 bool AutoRegisterCode) {
51 return ES.callSPSWrapper<void(shared::SPSExecutorAddrRange, bool)>(
52 RegisterFn, TargetMem, AutoRegisterCode);
53}
54
55} // namespace orc
56} // namespace llvm
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
Tagged union holding either a T or a Error.
Definition: Error.h:481
Error registerDebugObject(ExecutorAddrRange TargetMem, bool AutoRegisterCode) override
An ExecutionSession represents a running JIT program.
Definition: Core.h:1339
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1379
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition: Core.h:1593
Represents an address in the executor process.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:194
SymbolLookupSet & add(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Add an element to the set.
Definition: Core.h:260
Pointer to a pooled string representing a symbol name.
Expected< std::unique_ptr< EPCDebugObjectRegistrar > > createJITLoaderGDBRegistrar(ExecutionSession &ES, std::optional< ExecutorAddr > RegistrationFunctionDylib=std::nullopt)
Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug objects to the GDB JIT in...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto size(R &&Range, std::enable_if_t< std::is_base_of< std::random_access_iterator_tag, typename std::iterator_traits< decltype(Range.begin())>::iterator_category >::value, void > *=nullptr)
Get the size of a range.
Definition: STLExtras.h:1697
Represents an address range in the exceutor process.