LLVM 22.0.0git
DylibManager.h
Go to the documentation of this file.
1//===------ DylibManager.h - Manage dylibs in the 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// APIs for managing real (non-JIT) dylibs in the executing process.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_EXECUTIONENGINE_ORC_DYLIBMANAGER_H
14#define LLVM_EXECUTIONENGINE_ORC_DYLIBMANAGER_H
15
18#include "llvm/Support/Error.h"
20
21#include <future>
22#include <mutex>
23#include <vector>
24
25namespace llvm::orc {
26
27class SymbolLookupSet;
28
30public:
31 /// A pair of a dylib and a set of symbols to be looked up.
34 : Handle(Handle), Symbols(Symbols) {}
37 };
38
39 virtual ~DylibManager();
40
41 /// Load the dynamic library at the given path and return a handle to it.
42 /// If LibraryPath is null this function will return the global handle for
43 /// the target process.
44 virtual Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) = 0;
45
46 /// Search for symbols in the target process.
47 ///
48 /// The result of the lookup is a 2-dimensional array of target addresses
49 /// that correspond to the lookup order. If a required symbol is not
50 /// found then this method will return an error. If a weakly referenced
51 /// symbol is not found then it be assigned a '0' value.
54 std::promise<MSVCPExpected<std::vector<tpctypes::LookupResult>>> RP;
55 auto RF = RP.get_future();
56 lookupSymbolsAsync(Request,
57 [&RP](auto Result) { RP.set_value(std::move(Result)); });
58 return RF.get();
59 }
60
62 unique_function<void(Expected<std::vector<tpctypes::LookupResult>>)>;
63
64 /// Search for symbols in the target process.
65 ///
66 /// The result of the lookup is a 2-dimensional array of target addresses
67 /// that correspond to the lookup order. If a required symbol is not
68 /// found then this method will return an error. If a weakly referenced
69 /// symbol is not found then it be assigned a '0' value.
72};
73
74} // end namespace llvm::orc
75
76#endif // LLVM_EXECUTIONENGINE_ORC_DYLIBMANAGER_H
#define LLVM_ABI
Definition: Compiler.h:213
#define F(x, y, z)
Definition: MD5.cpp:55
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Tagged union holding either a T or a Error.
Definition: Error.h:485
virtual void lookupSymbolsAsync(ArrayRef< LookupRequest > Request, SymbolLookupCompleteFn F)=0
Search for symbols in the target process.
Expected< std::vector< tpctypes::LookupResult > > lookupSymbols(ArrayRef< LookupRequest > Request)
Search for symbols in the target process.
Definition: DylibManager.h:53
virtual Expected< tpctypes::DylibHandle > loadDylib(const char *DylibPath)=0
Load the dynamic library at the given path and return a handle to it.
Represents an address in the executor process.
A set of symbols to look up, each associated with a SymbolLookupFlags value.
Definition: Core.h:195
unique_function is a type-erasing functor similar to std::function.
A pair of a dylib and a set of symbols to be looked up.
Definition: DylibManager.h:32
const SymbolLookupSet & Symbols
Definition: DylibManager.h:36
LookupRequest(tpctypes::DylibHandle Handle, const SymbolLookupSet &Symbols)
Definition: DylibManager.h:33