stracers

Trace system calls and signals on Linux, inspired by strace.

v0.1.0 MITApache-2.0
Install
cargo install stracers
GitLab ↗ GitHub ↗

stracers is a system call tracer for Linux written in Rust, inspired by strace. It runs a program, or attaches to a running one, and prints every system call it makes along with the arguments and result. It is a separate tool with its own output format rather than a drop-in replacement, and comes with stracers-core, a library for building your own tracers. It is at an early stage and supports x86_64 and aarch64.

strace

Every interaction between a program and the outside world, from opening a file to sending a packet, goes through a system call into the kernel. Watching those calls is often the fastest way to find out why a program fails: which file it couldn't find, which permission it was denied, where it is stuck.

strace has been the standard tool for this for over thirty years. Paul Kranenburg wrote it for SunOS in 1991, and Branko Lankester ported it to Linux in 1992. Since 2009 it has been maintained by Dmitry Levin. It is built on ptrace, the system call that lets one process observe and control another. It first appeared in Version 6 Unix, and debuggers rely on it as well. strace is licensed under LGPL-2.1-or-later.

This project

stracers uses ptrace too, through a library that handles spawning or attaching to processes, following forks, and decoding syscall arguments into something readable: file paths, flags, signal names and error codes like ENOENT. The command-line tool is a thin layer on top. The decoded syscalls cover the common path through a typical program, and syscalls it doesn't decode yet are shown as raw register values.

Example

# Trace a command
stracers ls /tmp

# Trace a build, including every process it starts
stracers -f make

# Attach to a process that is already running
sudo stracers -p 1234