Skip to content

Commit 41365dc

Browse files
committed
[ORC] Add missing DylibManager header.
- Accidentally left out of db21bd4.
1 parent cd4b33c commit 41365dc

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
16+
#include "llvm/ExecutionEngine/Orc/Shared/TargetProcessControlTypes.h"
17+
#include "llvm/Support/Error.h"
18+
#include "llvm/Support/MSVCErrorWorkarounds.h"
19+
20+
#include <future>
21+
#include <mutex>
22+
#include <vector>
23+
24+
namespace llvm::orc {
25+
26+
class SymbolLookupSet;
27+
28+
class DylibManager {
29+
public:
30+
/// A pair of a dylib and a set of symbols to be looked up.
31+
struct LookupRequest {
32+
LookupRequest(tpctypes::DylibHandle Handle, const SymbolLookupSet &Symbols)
33+
: Handle(Handle), Symbols(Symbols) {}
34+
tpctypes::DylibHandle Handle;
35+
const SymbolLookupSet &Symbols;
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.
51+
Expected<std::vector<tpctypes::LookupResult>>
52+
lookupSymbols(ArrayRef<LookupRequest> Request) {
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+
60+
using SymbolLookupCompleteFn =
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.
69+
virtual void lookupSymbolsAsync(ArrayRef<LookupRequest> Request,
70+
SymbolLookupCompleteFn F) = 0;
71+
};
72+
73+
} // end namespace llvm::orc
74+
75+
#endif // LLVM_EXECUTIONENGINE_ORC_DYLIBMANAGER_H

0 commit comments

Comments
 (0)