diff options
author | edef <edef@unfathomable.blue> | 2022-07-27 23:23:39 +0000 |
---|---|---|
committer | edef <edef@unfathomable.blue> | 2022-07-27 23:23:39 +0000 |
commit | d457dd7314835ba43845462c6d81c5985b89f891 (patch) | |
tree | c8854acd999a88d90d89e81ece9311f7678aca1d /ripple | |
parent | e4d17e3ea3cbade54e0d9abdb185d61f9cdc1cb1 (diff) | |
download | unf-legacy-d457dd7314835ba43845462c6d81c5985b89f891.tar.zst |
ripple/minitrace: better errors for invalid syscall args
Change-Id: I26356c9b88c838e3c87e4083ac17f958c7c57bb7
Diffstat (limited to 'ripple')
-rw-r--r-- | ripple/minitrace/src/main.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs index 4e2368a..3d94288 100644 --- a/ripple/minitrace/src/main.rs +++ b/ripple/minitrace/src/main.rs @@ -108,14 +108,17 @@ macro_rules! define_syscalls { } impl $enum { - fn from_regs(regs: libc::user_regs_struct) -> Option<$enum> { - Some(match (regs.orig_rax, [regs.rdi, regs.rsi, regs.rdx, regs.r10, regs.r8, regs.r9]) { + fn from_regs(regs: libc::user_regs_struct) -> Result<$enum> { + Ok(match (regs.orig_rax, [regs.rdi, regs.rsi, regs.rdx, regs.r10, regs.r8, regs.r9]) { $( ($nr, [$($arg_id),*, ..]) => $enum::$id { - $($arg_id: SyscallArg::try_from_reg($arg_id)?),* + $($arg_id: match SyscallArg::try_from_reg($arg_id) { + Some(x) => x, + None => bail!("couldn't parse {}(2) {}: 0x{:08x}", stringify!($id), stringify!($arg_id), $arg_id) + }),* }, )* - _ => return None + (n, _) => bail!("unknown syscall number {n}") }) } } @@ -303,10 +306,10 @@ fn main() -> Result<()> { let regs = ptrace::getregs(event_tid.as_pid())?; let entry = match SyscallEntry::from_regs(regs) { - Some(entry) => entry, - None => { + Ok(entry) => entry, + Err(err) => { ptrace::kill(event_tid.as_pid())?; - panic!("unsupported syscall {:?}", regs.orig_rax); + panic!("{err}"); } }; |