@@ -69,36 +69,48 @@ inline std::string getWireProtectionFlagsStr(WireProtectionFlags WPF) {
69
69
return Result;
70
70
}
71
71
72
- struct SupportFunctionCall {
73
- using FnTy = shared::detail::CWrapperFunctionResult(const char *ArgData,
74
- size_t ArgSize);
72
+ struct WrapperFunctionCall {
75
73
ExecutorAddr Func;
76
- ExecutorAddrRange ArgDataRange ;
74
+ ExecutorAddrRange ArgData ;
77
75
78
- SupportFunctionCall () = default;
79
- SupportFunctionCall (ExecutorAddr Func, ExecutorAddr ArgData,
76
+ WrapperFunctionCall () = default ;
77
+ WrapperFunctionCall (ExecutorAddr Func, ExecutorAddr ArgData,
80
78
ExecutorAddrDiff ArgSize)
81
- : Func(Func), ArgDataRange(ArgData, ArgSize) {}
82
- SupportFunctionCall (ExecutorAddr Func, ExecutorAddrRange ArgDataRange)
83
- : Func(Func), ArgDataRange(ArgDataRange) {}
84
-
85
- Error run () {
86
- shared::WrapperFunctionResult WFR (Func.toPtr <FnTy *>()(
87
- ArgDataRange.Start .toPtr <const char *>(),
88
- static_cast <size_t >(ArgDataRange.size ().getValue ())));
79
+ : Func(Func), ArgData(ArgData, ArgSize) {}
80
+ WrapperFunctionCall (ExecutorAddr Func, ExecutorAddrRange ArgData)
81
+ : Func(Func), ArgData(ArgData) {}
82
+
83
+ shared::WrapperFunctionResult run () {
84
+ using FnTy = shared::detail::CWrapperFunctionResult (const char *ArgData,
85
+ size_t ArgSize);
86
+ return shared::WrapperFunctionResult (
87
+ Func.toPtr <FnTy *>()(ArgData.Start .toPtr <const char *>(),
88
+ static_cast <size_t >(ArgData.size ().getValue ())));
89
+ }
90
+
91
+ // / Run call and deserialize result using SPS.
92
+ template <typename SPSRetT, typename RetT> Error runWithSPSRet (RetT &RetVal) {
93
+ auto WFR = run ();
89
94
if (const char *ErrMsg = WFR.getOutOfBandError ())
90
95
return make_error<StringError>(ErrMsg, inconvertibleErrorCode ());
91
- if (!WFR.empty ())
92
- return make_error<StringError>(" Unexpected result bytes from "
93
- " support function call" ,
96
+ shared::SPSInputBuffer IB (WFR.data (), WFR.size ());
97
+ if (!shared::SPSSerializationTraits<SPSRetT, RetT>::deserialize (IB, RetVal))
98
+ return make_error<StringError>(" Could not deserialize result from "
99
+ " serialized wrapper function call" ,
94
100
inconvertibleErrorCode ());
95
101
return Error::success ();
96
102
}
103
+
104
+ // / Overload for SPS functions returning void.
105
+ Error runWithSPSRet () {
106
+ shared::SPSEmpty E;
107
+ return runWithSPSRet<shared::SPSEmpty>(E);
108
+ }
97
109
};
98
110
99
111
struct AllocationActionsPair {
100
- SupportFunctionCall Finalize;
101
- SupportFunctionCall Deallocate;
112
+ WrapperFunctionCall Finalize;
113
+ WrapperFunctionCall Deallocate;
102
114
};
103
115
104
116
struct SegFinalizeRequest {
@@ -155,14 +167,14 @@ namespace shared {
155
167
156
168
class SPSMemoryProtectionFlags {};
157
169
158
- using SPSSupportFunctionCall = SPSTuple<SPSExecutorAddr, SPSExecutorAddrRange>;
170
+ using SPSWrapperFunctionCall = SPSTuple<SPSExecutorAddr, SPSExecutorAddrRange>;
159
171
160
172
using SPSSegFinalizeRequest =
161
173
SPSTuple<SPSMemoryProtectionFlags, SPSExecutorAddr, uint64_t ,
162
174
SPSSequence<char >>;
163
175
164
176
using SPSAllocationActionsPair =
165
- SPSTuple<SPSSupportFunctionCall, SPSSupportFunctionCall >;
177
+ SPSTuple<SPSWrapperFunctionCall, SPSWrapperFunctionCall >;
166
178
167
179
using SPSFinalizeRequest = SPSTuple<SPSSequence<SPSSegFinalizeRequest>,
168
180
SPSSequence<SPSAllocationActionsPair>>;
@@ -201,23 +213,23 @@ class SPSSerializationTraits<SPSMemoryProtectionFlags,
201
213
};
202
214
203
215
template <>
204
- class SPSSerializationTraits <SPSSupportFunctionCall ,
205
- tpctypes::SupportFunctionCall > {
206
- using AL = SPSSupportFunctionCall ::AsArgList;
216
+ class SPSSerializationTraits <SPSWrapperFunctionCall ,
217
+ tpctypes::WrapperFunctionCall > {
218
+ using AL = SPSWrapperFunctionCall ::AsArgList;
207
219
208
220
public:
209
- static size_t size (const tpctypes::SupportFunctionCall &SFC ) {
210
- return AL::size (SFC .Func , SFC. ArgDataRange );
221
+ static size_t size (const tpctypes::WrapperFunctionCall &WFC ) {
222
+ return AL::size (WFC .Func , WFC. ArgData );
211
223
}
212
224
213
225
static bool serialize (SPSOutputBuffer &OB,
214
- const tpctypes::SupportFunctionCall &SFC ) {
215
- return AL::serialize (OB, SFC .Func , SFC. ArgDataRange );
226
+ const tpctypes::WrapperFunctionCall &WFC ) {
227
+ return AL::serialize (OB, WFC .Func , WFC. ArgData );
216
228
}
217
229
218
230
static bool deserialize (SPSInputBuffer &IB,
219
- tpctypes::SupportFunctionCall &SFC ) {
220
- return AL::deserialize (IB, SFC .Func , SFC. ArgDataRange );
231
+ tpctypes::WrapperFunctionCall &WFC ) {
232
+ return AL::deserialize (IB, WFC .Func , WFC. ArgData );
221
233
}
222
234
};
223
235
0 commit comments