From f3ca081e2d4eb1aee45f94fa8977aa7a7807a613 Mon Sep 17 00:00:00 2001 From: edef Date: Fri, 29 Jul 2022 16:56:01 +0000 Subject: ripple/minitrace: don't impl Copy for SyscallEntry We'd like to be able to have heap-allocated syscall data, which means we can't impl Copy. Change-Id: Ib40dcaf7f99baeaae0dae1153e80deae88d76978 --- ripple/minitrace/src/main.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 7ba6f96..eaabad0 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -97,7 +97,7 @@ macro_rules! define_syscalls { (enum $SyscallEntry:ident { $(fn $syscall:ident ( $($arg:ident : $Arg:ty),* ) -> $Ret:ty = $nr:literal ;)* }) => { - #[derive(Debug, Copy, Clone)] + #[derive(Debug, Clone)] #[allow(non_camel_case_types)] // TODO(edef): re-enable dead_code lint when we start fully interpreting syscall args #[allow(dead_code)] @@ -278,7 +278,7 @@ define_syscalls! { } } -#[derive(Debug, Copy, Clone)] +#[derive(Debug, Clone)] enum EntryExit { /// Process is about to enter a syscall Entry(SyscallEntry), @@ -336,12 +336,12 @@ fn main() -> Result<()> { } }; - syscall_state = Some(EntryExit::Entry(entry)); - - if !check_syscall(&process, entry) { + if !check_syscall(&process, &entry) { ptrace::kill(event_tid.as_pid())?; panic!("invalid syscall {entry:?}"); } + + syscall_state = Some(EntryExit::Entry(entry)); } (Some(EntryExit::Entry(entry)), WaitStatus::PtraceSyscall(event_tid)) => { let event_tid = Tid(event_tid.as_raw()); @@ -358,7 +358,9 @@ fn main() -> Result<()> { // TODO(edef): this only works for main thread break; } - _ => panic!("unknown status {status:?} with syscall_state = {syscall_state:?}"), + (syscall_state, status) => { + panic!("unknown status {status:?} with syscall_state = {syscall_state:?}") + } } } @@ -367,8 +369,8 @@ fn main() -> Result<()> { const AT_FDCWD: i32 = -100; -fn check_syscall(process: &Process, entry: SyscallEntry) -> bool { - match entry { +fn check_syscall(process: &Process, entry: &SyscallEntry) -> bool { + match *entry { SyscallEntry::mmap { addr: _, len: _, -- cgit 1.4.1