LLVM 23.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
22
23namespace llvm::orc {
24
26public:
30
34 AbsoluteSymbolsFn AbsoluteSymbols = absoluteSymbols)
35 : ES(ES), DylibMgr(DylibMgr), H(H), Allow(std::move(Allow)),
36 AbsoluteSymbols(std::move(AbsoluteSymbols)) {}
37
39 ExecutionSession &ES, DylibManager &DylibMgr,
41 AbsoluteSymbolsFn AbsoluteSymbols = absoluteSymbols)
42 : ES(ES), DylibMgr(DylibMgr), Allow(std::move(Allow)),
43 AbsoluteSymbols(std::move(AbsoluteSymbols)) {}
44
45 /// Permanently loads the library at the given path and, on success, returns
46 /// an ExecutorResolutionGenerator that will search it for symbol
47 /// definitions in the library. On failure returns the reason the library
48 /// failed to load.
50 Load(ExecutionSession &ES, DylibManager &DylibMgr, const char *LibraryPath,
52 AbsoluteSymbolsFn AbsoluteSymbols = absoluteSymbols);
53
54 /// Creates a ExecutorResolutionGenerator that searches for symbols in
55 /// the target process.
59 AbsoluteSymbolsFn AbsoluteSymbols = absoluteSymbols) {
60 return Load(ES, DylibMgr, nullptr, std::move(Allow),
61 std::move(AbsoluteSymbols));
62 }
63
65 JITDylibLookupFlags JDLookupFlags,
66 const SymbolLookupSet &LookupSet) override;
67
68private:
70 DylibManager &DylibMgr;
72 SymbolPredicate Allow;
73 AbsoluteSymbolsFn AbsoluteSymbols;
74};
75
76} // namespace llvm::orc
77
78#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:56
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:876
friend class ExecutionSession
Definition Core.h:877
An ExecutionSession represents a running JIT program.
Definition Core.h:1355
static Expected< std::unique_ptr< ExecutorResolutionGenerator > > GetForTargetProcess(ExecutionSession &ES, DylibManager &DylibMgr, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)
Creates a ExecutorResolutionGenerator that searches for symbols in the target process.
static Expected< std::unique_ptr< ExecutorResolutionGenerator > > Load(ExecutionSession &ES, DylibManager &DylibMgr, 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
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.
ExecutorResolutionGenerator(ExecutionSession &ES, DylibManager &DylibMgr, tpctypes::ResolverHandle H, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)
ExecutorResolutionGenerator(ExecutionSession &ES, DylibManager &DylibMgr, SymbolPredicate Allow=SymbolPredicate(), AbsoluteSymbolsFn AbsoluteSymbols=absoluteSymbols)
unique_function< bool(const SymbolStringPtr &)> SymbolPredicate
Represents a JIT'd dynamic library.
Definition Core.h:919
Wraps state for a lookup-in-progress.
Definition Core.h:851
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition Core.h:199
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:151
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:173
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:1917
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:870