Expand description
lurk is a pretty (simple) alternative to strace.
§Installation
Add the following dependencies to your Cargo.toml
[dependencies]
lurk-cli = "0.3.6"
nix = { version = "0.27.1", features = ["ptrace", "signal"] }
console = "0.15.8"
§Usage
First crate a tracee using run_tracee
method. Then you can construct a Tracer
struct to trace the system calls via calling run_tracer
.
§Examples
use anyhow::{bail, Result};
use console::Style;
use lurk_cli::{args::Args, style::StyleConfig, Tracer};
use nix::unistd::{fork, ForkResult};
use std::io;
fn main() -> Result<()> {
let command = String::from("/usr/bin/ls");
let pid = match unsafe { fork() } {
Ok(ForkResult::Child) => {
return lurk_cli::run_tracee(&[command], &[], &None);
}
Ok(ForkResult::Parent { child }) => child,
Err(err) => bail!("fork() failed: {err}"),
};
let args = Args::default();
let output = io::stdout();
let style = StyleConfig {
pid: Style::new().cyan(),
syscall: Style::new().white().bold(),
success: Style::new().green(),
error: Style::new().red(),
result: Style::new().yellow(),
use_colors: true,
};
Tracer::new(pid, args, output, style)?.run_tracer()
}