LLVM 20.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
17#include "llvm/Support/Error.h"
19
20#include <future>
21#include <mutex>
22#include <vector>
23
24namespace llvm::orc {
25
26class SymbolLookupSet;
27
29public:
30 /// A pair of a dylib and a set of symbols to be looked up.
36 };
37
38 virtual ~DylibManager();
39
40 /// Load the dynamic library at the given path and return a handle to it.
41 /// If LibraryPath is null this function will return the global handle for
42 /// the target process.
43 virtual Expected<tpctypes::DylibHandle> loadDylib(const char *DylibPath) = 0;
44
45 /// Search for symbols in the target process.
46 ///
47 /// The result of the lookup is a 2-dimensional array of target addresses
48 /// that correspond to the lookup order. If a required symbol is not
49 /// found then this method will return an error. If a weakly referenced
50 /// symbol is not found then it be assigned a '0' value.
53 std::promise<MSVCPExpected<std::vector<tpctypes::LookupResult>>> RP;
54 auto RF = RP.get_future();
55 lookupSymbolsAsync(Request,
56 [&RP](auto Result) { RP.set_value(std::move(Result)); });
57 return RF.get();
58 }
59
61 unique_function<void(Expected<std::vector<tpctypes::LookupResult>>)>;
62
63 /// Search for symbols in the target process.
64 ///
65 /// The result of the lookup is a 2-dimensional array of target addresses
66 /// that correspond to the lookup order. If a required symbol is not
67 /// found then this method will return an error. If a weakly referenced
68 /// symbol is not found then it be assigned a '0' value.
71};
72
73} // end namespace llvm::orc
74
75#endif // LLVM_EXECUTIONENGINE_ORC_DYLIBMANAGER_H
#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:481
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:52
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:194
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:31
const SymbolLookupSet & Symbols
Definition: DylibManager.h:35
LookupRequest(tpctypes::DylibHandle Handle, const SymbolLookupSet &Symbols)
Definition: DylibManager.h:32