diff options
| author | Ralf Jung <post@ralfj.de> | 2025-06-28 11:55:41 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2025-06-28 11:55:46 +0200 |
| commit | 5e14d0f193d59c139bcde2c2c18cd7f5612c3c2b (patch) | |
| tree | 3bbcb39eaa8f0faf8dae017b990dffd789950547 | |
| parent | cde10120828ca805af2a5b012a5829d3468d36fd (diff) | |
| download | rust-5e14d0f193d59c139bcde2c2c18cd7f5612c3c2b.tar.gz rust-5e14d0f193d59c139bcde2c2c18cd7f5612c3c2b.zip | |
move all the message types into one place
4 files changed, 31 insertions, 31 deletions
diff --git a/src/tools/miri/src/shims/native_lib/trace/child.rs b/src/tools/miri/src/shims/native_lib/trace/child.rs index f4b0371f8d0..4961e875c77 100644 --- a/src/tools/miri/src/shims/native_lib/trace/child.rs +++ b/src/tools/miri/src/shims/native_lib/trace/child.rs @@ -5,9 +5,9 @@ use ipc_channel::ipc; use nix::sys::{ptrace, signal}; use nix::unistd; -use super::messages::{Confirmation, MemEvents, TraceRequest}; +use super::CALLBACK_STACK_SIZE; +use super::messages::{Confirmation, MemEvents, StartFfiInfo, TraceRequest}; use super::parent::{ChildListener, sv_loop}; -use super::{CALLBACK_STACK_SIZE, StartFfiInfo}; use crate::alloc::isolated_alloc::IsolatedAlloc; static SUPERVISOR: std::sync::Mutex<Option<Supervisor>> = std::sync::Mutex::new(None); diff --git a/src/tools/miri/src/shims/native_lib/trace/messages.rs b/src/tools/miri/src/shims/native_lib/trace/messages.rs index 1014ca750c8..8a83dab5c09 100644 --- a/src/tools/miri/src/shims/native_lib/trace/messages.rs +++ b/src/tools/miri/src/shims/native_lib/trace/messages.rs @@ -18,29 +18,42 @@ //! in `super::child` (namely `start_ffi()` and `end_ffi()`) to handle this. It is //! trivially easy to cause a deadlock or crash by messing this up! +use std::ops::Range; + /// An IPC request sent by the child process to the parent. /// /// The sender for this channel should live on the child process. #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] -pub(super) enum TraceRequest { +pub enum TraceRequest { /// Requests that tracing begins. Following this being sent, the child must /// wait to receive a `Confirmation` on the respective channel and then /// `raise(SIGSTOP)`. /// /// To avoid possible issues while allocating memory for IPC channels, ending /// the tracing is instead done via `raise(SIGUSR1)`. - StartFfi(super::StartFfiInfo), + StartFfi(StartFfiInfo), /// Manually overrides the code that the supervisor will return upon exiting. /// Once set, it is permanent. This can be called again to change the value. OverrideRetcode(i32), } +/// Information needed to begin tracing. +#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] +pub struct StartFfiInfo { + /// A vector of page addresses. These should have been automatically obtained + /// with `IsolatedAlloc::pages` and prepared with `IsolatedAlloc::prepare_ffi`. + pub page_ptrs: Vec<usize>, + /// The address of an allocation that can serve as a temporary stack. + /// This should be a leaked `Box<[u8; CALLBACK_STACK_SIZE]>` cast to an int. + pub stack_ptr: usize, +} + /// A marker type confirming that the supervisor has received the request to begin /// tracing and is now waiting for a `SIGSTOP`. /// /// The sender for this channel should live on the parent process. #[derive(serde::Serialize, serde::Deserialize, Debug)] -pub(super) struct Confirmation; +pub struct Confirmation; /// The final results of an FFI trace, containing every relevant event detected /// by the tracer. Sent by the supervisor after receiving a `SIGUSR1` signal. @@ -53,5 +66,15 @@ pub struct MemEvents { /// pessimistically rounded up, and if the type (read/write/both) is uncertain /// it is reported as whatever would be safest to assume; i.e. a read + maybe-write /// becomes a read + write, etc. - pub acc_events: Vec<super::AccessEvent>, + pub acc_events: Vec<AccessEvent>, +} + +/// A single memory access, conservatively overestimated +/// in case of ambiguity. +#[derive(serde::Serialize, serde::Deserialize, Debug)] +pub enum AccessEvent { + /// A read may have occurred on no more than the specified address range. + Read(Range<usize>), + /// A write may have occurred on no more than the specified address range. + Write(Range<usize>), } diff --git a/src/tools/miri/src/shims/native_lib/trace/mod.rs b/src/tools/miri/src/shims/native_lib/trace/mod.rs index 8ff96151600..174b06b3ac5 100644 --- a/src/tools/miri/src/shims/native_lib/trace/mod.rs +++ b/src/tools/miri/src/shims/native_lib/trace/mod.rs @@ -2,30 +2,7 @@ mod child; pub mod messages; mod parent; -use std::ops::Range; - pub use self::child::{Supervisor, init_sv, register_retcode_sv}; /// The size of the temporary stack we use for callbacks that the server executes in the client. const CALLBACK_STACK_SIZE: usize = 1024; - -/// Information needed to begin tracing. -#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] -struct StartFfiInfo { - /// A vector of page addresses. These should have been automatically obtained - /// with `IsolatedAlloc::pages` and prepared with `IsolatedAlloc::prepare_ffi`. - page_ptrs: Vec<usize>, - /// The address of an allocation that can serve as a temporary stack. - /// This should be a leaked `Box<[u8; CALLBACK_STACK_SIZE]>` cast to an int. - stack_ptr: usize, -} - -/// A single memory access, conservatively overestimated -/// in case of ambiguity. -#[derive(serde::Serialize, serde::Deserialize, Debug)] -pub enum AccessEvent { - /// A read may have occurred on no more than the specified address range. - Read(Range<usize>), - /// A write may have occurred on no more than the specified address range. - Write(Range<usize>), -} diff --git a/src/tools/miri/src/shims/native_lib/trace/parent.rs b/src/tools/miri/src/shims/native_lib/trace/parent.rs index 0a0415c6e10..1d968b7a974 100644 --- a/src/tools/miri/src/shims/native_lib/trace/parent.rs +++ b/src/tools/miri/src/shims/native_lib/trace/parent.rs @@ -4,8 +4,8 @@ use ipc_channel::ipc; use nix::sys::{ptrace, signal, wait}; use nix::unistd; -use super::messages::{Confirmation, MemEvents, TraceRequest}; -use super::{AccessEvent, CALLBACK_STACK_SIZE, StartFfiInfo}; +use super::CALLBACK_STACK_SIZE; +use super::messages::{AccessEvent, Confirmation, MemEvents, StartFfiInfo, TraceRequest}; /// The flags to use when calling `waitid()`. /// Since bitwise or on the nix version of these flags is implemented as a trait, |
