Extract MemoryAccess into separate crate

Summary: This removes the need for `safeptrace` to depend on `reverie-syscalls`, which is a somewhat heavyweight library.

Reviewed By: VladimirMakaev

Differential Revision: D41751372

fbshipit-source-id: 36f601c7f441b070cd3a0678621649c4fb12b28e
This commit is contained in:
Jason White 2022-12-07 18:06:56 -08:00 committed by Facebook GitHub Bot
parent 9515dfe3c2
commit dba0b5b9b7
12 changed files with 31 additions and 19 deletions

View file

@ -2,8 +2,10 @@
members = [
"reverie",
"reverie-examples",
"reverie-memory",
"reverie-process",
"reverie-ptrace",
"reverie-syscalls",
"reverie-util",
"safeptrace",
]

11
reverie-memory/Cargo.toml Normal file
View file

@ -0,0 +1,11 @@
# @generated by autocargo
[package]
name = "reverie-memory"
version = "0.1.0"
authors = ["Meta Platforms"]
edition = "2021"
license = "BSD-2-Clause"
[dependencies]
syscalls = { version = "0.6.7", features = ["serde"] }

View file

@ -18,8 +18,7 @@ pub use addr::AddrMut;
pub use addr::AddrSlice;
pub use addr::AddrSliceMut;
pub use local::LocalMemory;
use crate::Errno;
use syscalls::Errno;
/// Trait for accessing potentially remote memory.
pub trait MemoryAccess {

View file

@ -13,5 +13,6 @@ derive_more = "0.99.17"
libc = "0.2.137"
nix = "0.25"
paste = "1.0"
reverie-memory = { version = "0.1.0", path = "../reverie-memory" }
serde = { version = "1.0.136", features = ["derive", "rc"] }
syscalls = { version = "0.6.7", features = ["serde"] }

View file

@ -26,10 +26,10 @@ use nix::sys::timerfd::TimerFlags;
use nix::sys::wait::WaitPidFlag;
use nix::unistd::Pid;
use crate::memory::Addr;
use crate::memory::AddrMut;
use crate::memory::MemoryAccess;
use crate::Addr;
use crate::AddrMut;
use crate::Errno;
use crate::MemoryAccess;
/// A wrapper that combines an address space and a syscall. This is useful for
/// displaying the contents of syscall pointer inputs.

View file

@ -23,17 +23,16 @@ mod macros;
mod args;
mod display;
mod memory;
mod raw;
mod syscalls;
// Re-export the only things that might be needed from the syscalls crate
pub use ::reverie_memory::*;
pub use ::syscalls::Errno;
pub use ::syscalls::SyscallArgs;
pub use ::syscalls::Sysno;
pub use crate::args::*;
pub use crate::display::*;
pub use crate::memory::*;
pub use crate::raw::*;
pub use crate::syscalls::*;

View file

@ -17,9 +17,9 @@ use crate::args::ClockId;
use crate::args::CloneFlags;
use crate::args::StatPtr;
use crate::args::Timespec;
use crate::memory::Addr;
use crate::memory::AddrMut;
use crate::memory::MemoryAccess;
use crate::Addr;
use crate::AddrMut;
use crate::MemoryAccess;
/// Represents the `[p]read{64,v,v2}` family of syscalls. All of these syscalls
/// have an associated file descriptor.

View file

@ -43,9 +43,9 @@ use crate::args::TimespecMutPtr;
use crate::args::TimevalMutPtr;
use crate::args::Timezone;
use crate::display::Displayable;
use crate::memory::Addr;
use crate::memory::AddrMut;
use crate::raw::FromToRaw;
use crate::Addr;
use crate::AddrMut;
/// A trait that all syscalls implement.
pub trait SyscallInfo: Displayable + Copy + Send {

View file

@ -14,8 +14,8 @@ lazy_static = "1.4"
libc = "0.2.137"
nix = "0.25"
parking_lot = { version = "0.11.2", features = ["send_guard"] }
reverie-memory = { version = "0.1.0", path = "../reverie-memory" }
reverie-process = { version = "0.1.0", path = "../reverie-process" }
reverie-syscalls = { version = "0.1.0", path = "../reverie-syscalls" }
syscalls = { version = "0.6.7", features = ["serde"] }
thiserror = "1.0.36"

View file

@ -10,12 +10,12 @@ use core::mem;
use std::io;
use nix::sys::ptrace;
use reverie_syscalls::Addr;
use reverie_syscalls::AddrMut;
use reverie_syscalls::AddrSlice;
use reverie_syscalls::AddrSliceMut;
use reverie_syscalls::Errno;
use reverie_syscalls::MemoryAccess;
use reverie_memory::Addr;
use reverie_memory::AddrMut;
use reverie_memory::AddrSlice;
use reverie_memory::AddrSliceMut;
use reverie_memory::MemoryAccess;
use syscalls::Errno;
use super::Stopped;