LLVM  14.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  auto &EPC = ES.getExecutorProcessControl();
22  auto ProcessHandle = EPC.loadDylib(nullptr);
23  if (!ProcessHandle)
24  return ProcessHandle.takeError();
25 
26  SymbolStringPtr RegisterFn =
27  EPC.getTargetTriple().isOSBinFormatMachO()
28  ? EPC.intern("_llvm_orc_registerJITLoaderGDBWrapper")
29  : EPC.intern("llvm_orc_registerJITLoaderGDBWrapper");
30 
31  SymbolLookupSet RegistrationSymbols;
32  RegistrationSymbols.add(RegisterFn);
33 
34  auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
35  if (!Result)
36  return Result.takeError();
37 
38  assert(Result->size() == 1 && "Unexpected number of dylibs in result");
39  assert((*Result)[0].size() == 1 &&
40  "Unexpected number of addresses in result");
41 
42  return std::make_unique<EPCDebugObjectRegistrar>(
43  ES, ExecutorAddr((*Result)[0][0]));
44 }
45 
47  ExecutorAddrRange TargetMem) {
48  return ES.callSPSWrapper<void(SPSExecutorAddrRange)>(RegisterFn, TargetMem);
49 }
50 
51 } // namespace orc
52 } // namespace llvm
llvm::orc::ExecutorAddr
Represents an address in the executor process.
Definition: ExecutorAddress.h:37
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
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:50
llvm::orc::shared::SPSTuple
SPS tag type for tuples.
Definition: SimplePackedSerialization.h:183
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:134
llvm::orc::EPCDebugObjectRegistrar::registerDebugObject
Error registerDebugObject(ExecutorAddrRange TargetMem) override
Definition: EPCDebugObjectRegistrar.cpp:46
EPCDebugObjectRegistrar.h
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:1500
llvm::orc::ExecutionSession::getExecutorProcessControl
ExecutorProcessControl & getExecutorProcessControl()
Get the ExecutorProcessControl object associated with this ExecutionSession.
Definition: Core.h:1310
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:1562
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:157
llvm::orc::ExecutionSession
An ExecutionSession represents a running JIT program.
Definition: Core.h:1271
llvm::orc::ExecutorProcessControl::loadDylib
virtual Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath)=0
Load the dynamic library at the given path and return a handle to it.
Core.h
llvm::orc::createJITLoaderGDBRegistrar
Expected< std::unique_ptr< EPCDebugObjectRegistrar > > createJITLoaderGDBRegistrar(ExecutionSession &ES)
Create a ExecutorProcessControl-based DebugObjectRegistrar that emits debug objects to the GDB JIT in...
Definition: EPCDebugObjectRegistrar.cpp:20
BinaryStreamWriter.h