[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / ExecutionEngine / Orc / EPCDebugObjectRegistrar.cpp
blob5715eda71eee2340d16392dcf98b92a32b5bfa8b
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"
12 #include "llvm/ExecutionEngine/Orc/Shared/SimplePackedSerialization.h"
13 #include "llvm/ExecutionEngine/Orc/TargetProcess/JITLoaderGDB.h"
14 #include "llvm/Support/BinaryStreamWriter.h"
16 namespace llvm {
17 namespace orc {
19 Expected<std::unique_ptr<EPCDebugObjectRegistrar>>
20 createJITLoaderGDBRegistrar(ExecutionSession &ES) {
21 auto &EPC = ES.getExecutorProcessControl();
22 auto ProcessHandle = EPC.loadDylib(nullptr);
23 if (!ProcessHandle)
24 return ProcessHandle.takeError();
26 SymbolStringPtr RegisterFn =
27 EPC.getTargetTriple().isOSBinFormatMachO()
28 ? EPC.intern("_llvm_orc_registerJITLoaderGDBWrapper")
29 : EPC.intern("llvm_orc_registerJITLoaderGDBWrapper");
31 SymbolLookupSet RegistrationSymbols;
32 RegistrationSymbols.add(RegisterFn);
34 auto Result = EPC.lookupSymbols({{*ProcessHandle, RegistrationSymbols}});
35 if (!Result)
36 return Result.takeError();
38 assert(Result->size() == 1 && "Unexpected number of dylibs in result");
39 assert((*Result)[0].size() == 1 &&
40 "Unexpected number of addresses in result");
42 return std::make_unique<EPCDebugObjectRegistrar>(ES, (*Result)[0][0]);
45 Error EPCDebugObjectRegistrar::registerDebugObject(sys::MemoryBlock TargetMem) {
46 return ES.callSPSWrapper<void(SPSExecutorAddress, uint64_t)>(
47 RegisterFn, ExecutorAddress::fromPtr(TargetMem.base()),
48 static_cast<uint64_t>(TargetMem.allocatedSize()));
51 } // namespace orc
52 } // namespace llvm