LLVM 22.0.0git
ExecutorResolutionGenerator.h
Go to the documentation of this file.
1//===----- ExecutorResolver.h - Resolve symbols in executor -----*- C++ -*-===//
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//
9// Declares ExecutorResolutionGenerator for symbol resolution,
10// dynamic library loading, and lookup in an executor process via
11// ExecutorResolver.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_EXECUTIONENGINE_ORC_EXECUTORRESOLUTIONGENERATOR_H
16#define LLVM_EXECUTIONENGINE_ORC_EXECUTORRESOLUTIONGENERATOR_H
17
21
22namespace llvm::orc {
23
25public:
29
33 AbsoluteSymbolsFn AbsoluteSymbols = absoluteSymbols)
34 : EPC(ES.getExecutorProcessControl()), H(H), Allow(std::move(Allow)),
35 AbsoluteSymbols(std::move(AbsoluteSymbols)) {}
36
39 AbsoluteSymbolsFn AbsoluteSymbols = absoluteSymbols)
40 : EPC(ES.getExecutorProcessControl()), Allow(std::move(Allow)),
41 AbsoluteSymbols(std::move(AbsoluteSymbols)) {}
42
43 /// Permanently loads the library at the given path and, on success, returns
44 /// an ExecutorResolutionGenerator that will search it for symbol
45 /// definitions in the library. On failure returns the reason the library
46 /// failed to load.
48 Load(ExecutionSession &ES, const char *LibraryPath,
50 AbsoluteSymbolsFn AbsoluteSymbols = absoluteSymbols);
51
52 /// Creates a ExecutorResolutionGenerator that searches for symbols in
53 /// the target process.
57 AbsoluteSymbolsFn AbsoluteSymbols = absoluteSymbols) {
58 return Load(ES, nullptr, std::move(Allow), std::move(AbsoluteSymbols));
59 }
60
62 JITDylibLookupFlags JDLookupFlags,
63 const SymbolLookupSet &LookupSet) override;
64
65private:
68 SymbolPredicate Allow;
69 AbsoluteSymbolsFn AbsoluteSymbols;
70};
71
72} // namespace llvm::orc
73
74#endif // LLVM_EXECUTIONENGINE_ORC_EXECUTORRESOLUTIONGENERATOR_H
This file provides a collection of function (or more generally, callable) type erasure utilities supp...
#define H(x, y, z)
Definition MD5.cpp:57
Lightweight error class with error context and mandatory checking.
Definition Error.h:159
Tagged union holding either a T or a Error.
Definition Error.h:485
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
Definition Core.h:859
friend class ExecutionSession
Definition Core.h:860
An ExecutionSession represents a running JIT program.
Definition Core.h:1355
ExecutorProcessControl supports interaction with a JIT target process.
static Expected< std::unique_ptr< ExecutorResolutionGenerator > > Load(ExecutionSession &ES, const char *LibraryPath, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)
Permanently loads the library at the given path and, on success, returns an ExecutorResolutionGenerat...
unique_function< std::unique_ptr< MaterializationUnit >(SymbolMap)> AbsoluteSymbolsFn
ExecutorResolutionGenerator(ExecutionSession &ES, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)
ExecutorResolutionGenerator(ExecutionSession &ES, tpctypes::ResolverHandle H, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &LookupSet) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
static Expected< std::unique_ptr< ExecutorResolutionGenerator > > GetForTargetProcess(ExecutionSession &ES, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)
Creates a ExecutorResolutionGenerator that searches for symbols in the target process.
unique_function< bool(const SymbolStringPtr &)> SymbolPredicate
Represents a JIT'd dynamic library.
Definition Core.h:902
Wraps state for a lookup-in-progress.
Definition Core.h:834
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition Core.h:195
Pointer to a pooled string representing a symbol name.
unique_function is a type-erasing functor similar to std::function.
ExecutorAddr ResolverHandle
A handle used to reference the resolver associated with a loaded dylib in the target process.
std::unique_ptr< AbsoluteSymbolsMaterializationUnit > absoluteSymbols(SymbolMap Symbols)
Create an AbsoluteSymbolsMaterializationUnit with the given symbols.
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition Core.h:147
DenseMap< SymbolStringPtr, ExecutorSymbolDef > SymbolMap
A map from symbol names (as SymbolStringPtrs) to JITSymbols (address/flags pairs).
LookupKind
Describes the kind of lookup being performed.
Definition Core.h:169
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition STLExtras.h:1869
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:867