1 use super::prelude::*; 2 use crate::arch::Arch; 3 use crate::protocol::commands::_QCatchSyscalls::QCatchSyscalls; 4 use crate::protocol::commands::ext::CatchSyscalls; 5 use crate::target::ext::catch_syscalls::SyscallNumbers; 6 7 impl<T: Target, C: Connection> GdbStubImpl<T, C> { handle_catch_syscalls( &mut self, _res: &mut ResponseWriter<'_, C>, target: &mut T, command: CatchSyscalls<'_>, ) -> Result<HandlerStatus, Error<T::Error, C::Error>>8 pub(crate) fn handle_catch_syscalls( 9 &mut self, 10 _res: &mut ResponseWriter<'_, C>, 11 target: &mut T, 12 command: CatchSyscalls<'_>, 13 ) -> Result<HandlerStatus, Error<T::Error, C::Error>> { 14 let ops = match target.support_catch_syscalls() { 15 Some(ops) => ops, 16 None => return Ok(HandlerStatus::Handled), 17 }; 18 19 crate::__dead_code_marker!("catch_syscalls", "impl"); 20 21 let handler_status = match command { 22 CatchSyscalls::QCatchSyscalls(cmd) => { 23 match cmd { 24 QCatchSyscalls::Disable => ops.disable_catch_syscalls().handle_error()?, 25 QCatchSyscalls::Enable(sysno) => { 26 let mut error = false; 27 let mut filter = sysno 28 .into_iter() 29 .map(<T::Arch as Arch>::Usize::from_be_bytes) 30 .take_while(|x| { 31 error = x.is_none(); 32 !error 33 }) 34 .flatten(); 35 ops.enable_catch_syscalls(Some(SyscallNumbers { inner: &mut filter })) 36 .handle_error()?; 37 if error { 38 return Err(Error::TargetMismatch); 39 } 40 } 41 QCatchSyscalls::EnableAll => ops.enable_catch_syscalls(None).handle_error()?, 42 } 43 HandlerStatus::NeedsOk 44 } 45 }; 46 47 Ok(handler_status) 48 } 49 } 50