summary refs log tree commit diff
path: root/ripple/minitrace/src
diff options
context:
space:
mode:
Diffstat (limited to 'ripple/minitrace/src')
-rw-r--r--ripple/minitrace/src/main.rs72
1 files changed, 68 insertions, 4 deletions
diff --git a/ripple/minitrace/src/main.rs b/ripple/minitrace/src/main.rs
index 362be9c..60ef287 100644
--- a/ripple/minitrace/src/main.rs
+++ b/ripple/minitrace/src/main.rs
@@ -106,7 +106,6 @@ fn main() -> anyhow::Result<()> {
 		}
 
 		let status = waitpid(tid.as_pid(), Some(WaitPidFlag::__WALL))?;
-		println!("{:?}", status);
 
 		match (syscall_state, status) {
 			(None, WaitStatus::PtraceSyscall(event_tid)) => {
@@ -117,7 +116,11 @@ fn main() -> anyhow::Result<()> {
 				let entry = SyscallEntry::from_regs(regs);
 
 				syscall_state = Some(EntryExit::Entry(entry));
-				println!("entry: {:?}", regs);
+
+				if !check_syscall(entry) {
+					ptrace::kill(event_tid.as_pid())?;
+					panic!("unsupported syscall {:?}", entry);
+				}
 			}
 			(Some(EntryExit::Entry(entry)), WaitStatus::PtraceSyscall(event_tid)) => {
 				let event_tid = Tid(event_tid.as_raw());
@@ -126,8 +129,6 @@ fn main() -> anyhow::Result<()> {
 				let regs = ptrace::getregs(event_tid.as_pid())?;
 				let ret = regs.rax as i64;
 				syscall_state = Some(EntryExit::Exit(entry, ret));
-
-				println!("syscall returned {:?} with {:?}", ret, regs);
 			}
 			(_, WaitStatus::Exited(event_tid, _)) => {
 				let event_tid = Tid(event_tid.as_raw());
@@ -145,3 +146,66 @@ fn main() -> anyhow::Result<()> {
 
 	Ok(())
 }
+
+fn check_syscall(entry: SyscallEntry) -> bool {
+	match entry.number {
+		// read
+		0 => {}
+
+		// write
+		1 => {}
+
+		// close
+		3 => {}
+
+		// mmap
+		9 => {}
+
+		// mprotect
+		10 => {}
+
+		// brk
+		12 => {}
+
+		// rt_sigaction
+		13 => {}
+
+		// ioctl
+		16 => {}
+
+		// pread64
+		17 => {}
+
+		// access
+		21 => {}
+
+		// getcwd
+		79 => {}
+
+		// readlink
+		89 => {}
+
+		// sysinfo
+		99 => {}
+
+		// times
+		100 => {}
+
+		// arch_prctl
+		158 => {}
+
+		// exit_group
+		231 => {}
+
+		// openat
+		257 => {}
+
+		// newfstatat
+		262 => {}
+
+		// prlimit64
+		302 => {}
+		_ => return false,
+	}
+	true
+}