use nix::unistd::Pid;
use std::process::exit;
use sys_rs::{
diag::Result,
input::{args, env},
process, profile, trace,
};
struct Wrapper {
tracer: profile::Tracer,
}
impl Wrapper {
pub fn new(path: &str) -> Result<Self> {
Ok(Self {
tracer: profile::Tracer::new(path)?,
})
}
}
impl trace::Tracer for Wrapper {
fn trace(&self, pid: Pid) -> Result<i32> {
let process = process::Info::build(self.tracer.path(), pid)?;
profile::trace_with_default_print(&self.tracer, &process)
}
}
fn main() -> Result<()> {
let args = args()?;
exit(trace::run::<Wrapper>(
&Wrapper::new(args[0].to_str()?)?,
&args,
&env()?,
)?)
}