LLVM 19.0.0git
EPCDynamicLibrarySearchGenerator.h
Go to the documentation of this file.
1//===------------ EPCDynamicLibrarySearchGenerator.h ------------*- 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// Support loading and searching of dynamic libraries in an executor process
10// via the ExecutorProcessControl class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_H
15#define LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_H
16
19
20namespace llvm {
21namespace orc {
22
23class ExecutorProcessControl;
24
26public:
29
30 /// Create a DynamicLibrarySearchGenerator that searches for symbols in the
31 /// library with the given handle.
32 ///
33 /// If the Allow predicate is given then only symbols matching the predicate
34 /// will be searched for. If the predicate is not given then all symbols will
35 /// be searched for.
36 ///
37 /// If \p AddAbsoluteSymbols is provided, it is used to add the symbols to the
38 /// \c JITDylib; otherwise it uses JD.define(absoluteSymbols(...)).
42 AddAbsoluteSymbolsFn AddAbsoluteSymbols = nullptr)
43 : EPC(ES.getExecutorProcessControl()), H(H), Allow(std::move(Allow)),
44 AddAbsoluteSymbols(std::move(AddAbsoluteSymbols)) {}
45
46 /// Permanently loads the library at the given path and, on success, returns
47 /// a DynamicLibrarySearchGenerator that will search it for symbol definitions
48 /// in the library. On failure returns the reason the library failed to load.
50 Load(ExecutionSession &ES, const char *LibraryPath,
52 AddAbsoluteSymbolsFn AddAbsoluteSymbols = nullptr);
53
54 /// Creates a EPCDynamicLibrarySearchGenerator that searches for symbols in
55 /// the target process.
59 AddAbsoluteSymbolsFn AddAbsoluteSymbols = nullptr) {
60 return Load(ES, nullptr, std::move(Allow), std::move(AddAbsoluteSymbols));
61 }
62
64 JITDylibLookupFlags JDLookupFlags,
65 const SymbolLookupSet &Symbols) override;
66
67private:
70 SymbolPredicate Allow;
71 AddAbsoluteSymbolsFn AddAbsoluteSymbols;
72};
73
74} // end namespace orc
75} // end namespace llvm
76
77#endif // LLVM_EXECUTIONENGINE_ORC_EPCDYNAMICLIBRARYSEARCHGENERATOR_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:160
Tagged union holding either a T or a Error.
Definition: Error.h:474
Definition generators can be attached to JITDylibs to generate new definitions for otherwise unresolv...
Definition: Core.h:946
static Expected< std::unique_ptr< EPCDynamicLibrarySearchGenerator > > Load(ExecutionSession &ES, const char *LibraryPath, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
Permanently loads the library at the given path and, on success, returns a DynamicLibrarySearchGenera...
static Expected< std::unique_ptr< EPCDynamicLibrarySearchGenerator > > GetForTargetProcess(ExecutionSession &ES, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
Creates a EPCDynamicLibrarySearchGenerator that searches for symbols in the target process.
unique_function< bool(const SymbolStringPtr &)> SymbolPredicate
unique_function< Error(JITDylib &, SymbolMap)> AddAbsoluteSymbolsFn
Error tryToGenerate(LookupState &LS, LookupKind K, JITDylib &JD, JITDylibLookupFlags JDLookupFlags, const SymbolLookupSet &Symbols) override
DefinitionGenerators should override this method to insert new definitions into the parent JITDylib.
EPCDynamicLibrarySearchGenerator(ExecutionSession &ES, tpctypes::DylibHandle H, SymbolPredicate Allow=SymbolPredicate(), AddAbsoluteSymbolsFn AddAbsoluteSymbols=nullptr)
Create a DynamicLibrarySearchGenerator that searches for symbols in the library with the given handle...
An ExecutionSession represents a running JIT program.
Definition: Core.h:1431
Represents an address in the executor process.
ExecutorProcessControl supports interaction with a JIT target process.
Represents a JIT'd dynamic library.
Definition: Core.h:989
Wraps state for a lookup-in-progress.
Definition: Core.h:921
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:183
Pointer to a pooled string representing a symbol name.
JITDylibLookupFlags
Lookup flags that apply to each dylib in the search order for a lookup.
Definition: Core.h:135
LookupKind
Describes the kind of lookup being performed.
Definition: Core.h:157
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
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:1849
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858