LLVM 22.0.0git
InProcessMemoryAccess.cpp
Go to the documentation of this file.
1//===------ InProcessMemoryAccess.cpp - Direct, in-process mem access -----===//
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
10
11#define DEBUG_TYPE "orc"
12
13namespace llvm::orc {
14
16
18 WriteResultFn OnWriteComplete) {
19 for (auto &W : Ws)
20 *W.Addr.toPtr<uint8_t *>() = W.Value;
21 OnWriteComplete(Error::success());
22}
23
26 for (auto &W : Ws)
27 *W.Addr.toPtr<uint16_t *>() = W.Value;
28 OnWriteComplete(Error::success());
29}
30
33 for (auto &W : Ws)
34 *W.Addr.toPtr<uint32_t *>() = W.Value;
35 OnWriteComplete(Error::success());
36}
37
40 for (auto &W : Ws)
41 *W.Addr.toPtr<uint64_t *>() = W.Value;
42 OnWriteComplete(Error::success());
43}
44
47 if (IsArch64Bit) {
48 for (auto &W : Ws)
49 *W.Addr.toPtr<uint64_t *>() = W.Value.getValue();
50 } else {
51 for (auto &W : Ws)
52 *W.Addr.toPtr<uint32_t *>() = static_cast<uint32_t>(W.Value.getValue());
53 }
54
55 OnWriteComplete(Error::success());
56}
57
60 for (auto &W : Ws)
61 memcpy(W.Addr.toPtr<char *>(), W.Buffer.data(), W.Buffer.size());
62 OnWriteComplete(Error::success());
63}
64
68 Result.reserve(Rs.size());
69 for (auto &R : Rs)
70 Result.push_back(*R.toPtr<uint8_t *>());
71 OnComplete(std::move(Result));
72}
73
77 Result.reserve(Rs.size());
78 for (auto &R : Rs)
79 Result.push_back(*R.toPtr<uint16_t *>());
80 OnComplete(std::move(Result));
81}
82
86 Result.reserve(Rs.size());
87 for (auto &R : Rs)
88 Result.push_back(*R.toPtr<uint32_t *>());
89 OnComplete(std::move(Result));
90}
91
95 Result.reserve(Rs.size());
96 for (auto &R : Rs)
97 Result.push_back(*R.toPtr<uint64_t *>());
98 OnComplete(std::move(Result));
99}
100
104 Result.reserve(Rs.size());
105 for (auto &R : Rs)
106 Result.push_back(ExecutorAddr::fromPtr(*R.toPtr<void **>()));
107 OnComplete(std::move(Result));
108}
109
113 Result.reserve(Rs.size());
114 for (auto &R : Rs) {
115 Result.push_back({});
116 Result.back().resize(R.size());
117 memcpy(Result.back().data(), R.Start.toPtr<char *>(), R.size());
118 }
119 OnComplete(std::move(Result));
120}
121
125 Result.reserve(Rs.size());
126 for (auto &R : Rs) {
127 Result.push_back({});
128 for (auto *P = R.toPtr<char *>(); *P; ++P)
129 Result.back().push_back(*P);
130 }
131 OnComplete(std::move(Result));
132}
133
134} // end namespace llvm::orc
#define P(N)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
size_t size() const
size - Get the array size.
Definition: ArrayRef.h:147
static ErrorSuccess success()
Create a success value.
Definition: Error.h:336
static ExecutorAddr fromPtr(T *Ptr, UnwrapFn &&Unwrap=UnwrapFn())
Create an ExecutorAddr from the given pointer.
void writePointersAsync(ArrayRef< tpctypes::PointerWrite > Ws, WriteResultFn OnWriteComplete) override
void readStringsAsync(ArrayRef< ExecutorAddr > Rs, OnReadStringsCompleteFn OnComplete) override
void writeUInt32sAsync(ArrayRef< tpctypes::UInt32Write > Ws, WriteResultFn OnWriteComplete) override
void writeUInt8sAsync(ArrayRef< tpctypes::UInt8Write > Ws, WriteResultFn OnWriteComplete) override
void readUInt64sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint64_t > OnComplete) override
void writeUInt16sAsync(ArrayRef< tpctypes::UInt16Write > Ws, WriteResultFn OnWriteComplete) override
void readUInt16sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint16_t > OnComplete) override
void readUInt8sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint8_t > OnComplete) override
void readPointersAsync(ArrayRef< ExecutorAddr > Rs, OnReadPointersCompleteFn OnComplete) override
void readUInt32sAsync(ArrayRef< ExecutorAddr > Rs, OnReadUIntsCompleteFn< uint32_t > OnComplete) override
void writeBuffersAsync(ArrayRef< tpctypes::BufferWrite > Ws, WriteResultFn OnWriteComplete) override
void readBuffersAsync(ArrayRef< ExecutorAddrRange > Rs, OnReadBuffersCompleteFn OnComplete) override
void writeUInt64sAsync(ArrayRef< tpctypes::UInt64Write > Ws, WriteResultFn OnWriteComplete) override
std::vector< std::string > ReadStringsResult
Definition: MemoryAccess.h:44
std::vector< ExecutorAddr > ReadPointersResult
Definition: MemoryAccess.h:36
std::vector< std::vector< uint8_t > > ReadBuffersResult
Definition: MemoryAccess.h:40
std::vector< T > ReadUIntsResult
Definition: MemoryAccess.h:31