LLVM  16.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 
16 namespace llvm {
17 namespace orc {
18 
19 Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
21  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  return std::make_unique<EPCDebugObjectRegistrar>(
49  ES, ExecutorAddr((*Result)[0][0]));
50 }
51 
53  ExecutorAddrRange TargetMem) {
54  return ES.callSPSWrapper<void(shared::SPSExecutorAddrRange)>(RegisterFn,
55  TargetMem);
56 }
57 
58 } // namespace orc
59 } // namespace llvm
llvm::orc::ExecutorAddr
Represents an address in the executor process.
Definition: ExecutorAddress.h:31
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
JITLoaderGDB.h
llvm::orc::SymbolLookupSet
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:175
llvm::orc::SymbolStringPtr
Pointer to a pooled string representing a symbol name.
Definition: SymbolStringPool.h:57
llvm::Optional
Definition: APInt.h:33
llvm::orc::shared::SPSTuple
SPS tag type for tuples.
Definition: SimplePackedSerialization.h:195
llvm::orc::SymbolLookupSet::add
SymbolLookupSet & add(SymbolStringPtr Name, SymbolLookupFlags Flags=SymbolLookupFlags::RequiredSymbol)
Add an element to the set.
Definition: Core.h:236
llvm::orc::ExecutorAddrRange
Represents an address range in the exceutor process.
Definition: ExecutorAddress.h:191
llvm::orc::EPCDebugObjectRegistrar::registerDebugObject
Error registerDebugObject(ExecutorAddrRange TargetMem) override
Definition: EPCDebugObjectRegistrar.cpp:52
EPCDebugObjectRegistrar.h
D
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
llvm::orc::createJITLoaderGDBRegistrar
Expected< std::unique_ptr< EPCDebugObjectRegistrar > > createJITLoaderGDBRegistrar(ExecutionSession &ES, Optional< ExecutorAddr > RegistrationFunctionDylib=None)
Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug objects to the GDB JIT in...
Definition: EPCDebugObjectRegistrar.cpp:20
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::orc::ExecutionSession::callSPSWrapper
Error callSPSWrapper(ExecutorAddr WrapperFnAddr, WrapperCallArgTs &&...WrapperCallArgs)
Run a wrapper function using SPS to serialize the arguments and deserialize the results.
Definition: Core.h:1610
llvm::orc::ExecutionSession::getExecutorProcessControl
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1408
SimplePackedSerialization.h
llvm::size
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:1715
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1365
Core.h
BinaryStreamWriter.h