LLVM 19.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
15
16namespace llvm {
17namespace orc {
18
21 std::optional<ExecutorAddr> RegistrationFunctionDylib) {
22 auto &EPC = ES.getExecutorProcessControl();
23
24 if (!RegistrationFunctionDylib) {
25 if (auto D = EPC.loadDylib(nullptr))
26 RegistrationFunctionDylib = *D;
27 else
28 return D.takeError();
29 }
30
31 SymbolStringPtr RegisterFn =
32 EPC.getTargetTriple().isOSBinFormatMachO()
33 ? EPC.intern("_llvm_orc_registerJITLoaderGDBWrapper")
34 : EPC.intern("llvm_orc_registerJITLoaderGDBWrapper");
35
36 SymbolLookupSet RegistrationSymbols;
37 RegistrationSymbols.add(RegisterFn);
38
39 auto Result =
40 EPC.lookupSymbols({{*RegistrationFunctionDylib, RegistrationSymbols}});
41 if (!Result)
42 return Result.takeError();
43
44 assert(Result->size() == 1 && "Unexpected number of dylibs in result");
45 assert((*Result)[0].size() == 1 &&
46 "Unexpected number of addresses in result");
47
48 ExecutorAddr RegisterAddr = (*Result)[0][0].getAddress();
49 return std::make_unique<EPCDebugObjectRegistrar>(ES, RegisterAddr);
50}
51
53 bool AutoRegisterCode) {
54 return ES.callSPSWrapper<void(shared::SPSExecutorAddrRange, bool)>(
55 RegisterFn, TargetMem, AutoRegisterCode);
56}
57
58} // namespace orc
59} // 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:474
Error registerDebugObject(ExecutorAddrRange TargetMem, bool AutoRegisterCode) override
An ExecutionSession represents a running JIT program.
Definition: Core.h:1425
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1468
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition: Core.h:1688
Represents an address in the executor process.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:183
SymbolLookupSet & add(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Add an element to the set.
Definition: Core.h:244
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:1689
Represents an address range in the exceutor process.