summaryrefslogtreecommitdiff
path: root/src/trace.rs
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2023-10-16 22:41:38 +0200
committerSanto Cariotti <santo@dcariotti.me>2023-10-16 22:41:38 +0200
commit1d8941667906dced913a308c9a39fd055ac5186f (patch)
treeb016664c7243eb67014509860385aa6182a0cd78 /src/trace.rs
parent38e07fae8b3d06cd43b4c9793c07c2048b32d095 (diff)
Filter sys calls
Diffstat (limited to 'src/trace.rs')
-rw-r--r--src/trace.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/trace.rs b/src/trace.rs
index cbb52c3..2341394 100644
--- a/src/trace.rs
+++ b/src/trace.rs
@@ -59,9 +59,17 @@ pub fn trace(pid: Pid, args: &Args) -> anyhow::Result<Vec<RegistersData>> {
// because it could be equals except for the `rax` register.
let mut have_to_print = true;
+ let filters: Vec<&str> = match &args.filter {
+ Some(filter) => filter.split(",").collect::<Vec<&str>>(),
+ None => vec![],
+ };
while let Some(reg) = trace_next(pid)? {
have_to_print ^= true;
if have_to_print {
+ if !filters.is_empty() && !filters.contains(&reg.rax()) {
+ continue;
+ }
+
if let Some(ref mut f) = f {
writeln!(f, "{}", reg.output())?;
}