1818//! in `super::child` (namely `start_ffi()` and `end_ffi()`) to handle this. It is
1919//! trivially easy to cause a deadlock or crash by messing this up!
2020
21+ use std:: ops:: Range ;
22+
2123/// An IPC request sent by the child process to the parent.
2224///
2325/// The sender for this channel should live on the child process.
2426#[ derive( serde:: Serialize , serde:: Deserialize , Debug , Clone ) ]
25- pub ( super ) enum TraceRequest {
27+ pub enum TraceRequest {
2628 /// Requests that tracing begins. Following this being sent, the child must
2729 /// wait to receive a `Confirmation` on the respective channel and then
2830 /// `raise(SIGSTOP)`.
2931 ///
3032 /// To avoid possible issues while allocating memory for IPC channels, ending
3133 /// the tracing is instead done via `raise(SIGUSR1)`.
32- StartFfi ( super :: StartFfiInfo ) ,
34+ StartFfi ( StartFfiInfo ) ,
3335 /// Manually overrides the code that the supervisor will return upon exiting.
3436 /// Once set, it is permanent. This can be called again to change the value.
3537 OverrideRetcode ( i32 ) ,
3638}
3739
40+ /// Information needed to begin tracing.
41+ #[ derive( serde:: Serialize , serde:: Deserialize , Debug , Clone ) ]
42+ pub struct StartFfiInfo {
43+ /// A vector of page addresses. These should have been automatically obtained
44+ /// with `IsolatedAlloc::pages` and prepared with `IsolatedAlloc::prepare_ffi`.
45+ pub page_ptrs : Vec < usize > ,
46+ /// The address of an allocation that can serve as a temporary stack.
47+ /// This should be a leaked `Box<[u8; CALLBACK_STACK_SIZE]>` cast to an int.
48+ pub stack_ptr : usize ,
49+ }
50+
3851/// A marker type confirming that the supervisor has received the request to begin
3952/// tracing and is now waiting for a `SIGSTOP`.
4053///
4154/// The sender for this channel should live on the parent process.
4255#[ derive( serde:: Serialize , serde:: Deserialize , Debug ) ]
43- pub ( super ) struct Confirmation ;
56+ pub struct Confirmation ;
4457
4558/// The final results of an FFI trace, containing every relevant event detected
4659/// by the tracer. Sent by the supervisor after receiving a `SIGUSR1` signal.
@@ -53,5 +66,15 @@ pub struct MemEvents {
5366 /// pessimistically rounded up, and if the type (read/write/both) is uncertain
5467 /// it is reported as whatever would be safest to assume; i.e. a read + maybe-write
5568 /// becomes a read + write, etc.
56- pub acc_events : Vec < super :: AccessEvent > ,
69+ pub acc_events : Vec < AccessEvent > ,
70+ }
71+
72+ /// A single memory access, conservatively overestimated
73+ /// in case of ambiguity.
74+ #[ derive( serde:: Serialize , serde:: Deserialize , Debug ) ]
75+ pub enum AccessEvent {
76+ /// A read may have occurred on no more than the specified address range.
77+ Read ( Range < usize > ) ,
78+ /// A write may have occurred on no more than the specified address range.
79+ Write ( Range < usize > ) ,
5780}
0 commit comments