2021-12-30 00:14:23 +00:00
|
|
|
/*
|
2022-10-26 19:18:14 +00:00
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
* All rights reserved.
|
2021-12-30 00:14:23 +00:00
|
|
|
*
|
2022-10-26 19:18:14 +00:00
|
|
|
* This source code is licensed under the BSD-style license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
2021-12-30 00:14:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
mod config;
|
|
|
|
mod filter;
|
|
|
|
mod global_state;
|
|
|
|
mod tool;
|
|
|
|
|
2022-10-03 19:18:55 +00:00
|
|
|
use clap::Parser;
|
2021-12-30 00:14:23 +00:00
|
|
|
use config::Config;
|
|
|
|
use filter::Filter;
|
|
|
|
use reverie::Error;
|
|
|
|
use reverie_util::CommonToolArguments;
|
2022-08-06 15:21:44 +00:00
|
|
|
use tool::Strace;
|
2021-12-30 00:14:23 +00:00
|
|
|
|
|
|
|
/// A tool to trace system calls.
|
2022-10-03 19:18:55 +00:00
|
|
|
#[derive(Parser, Debug)]
|
2021-12-30 00:14:23 +00:00
|
|
|
struct Opts {
|
2022-10-03 19:18:55 +00:00
|
|
|
#[clap(flatten)]
|
2021-12-30 00:14:23 +00:00
|
|
|
common: CommonToolArguments,
|
|
|
|
|
|
|
|
/// The set of syscalls to trace. By default, all syscalls are traced. If
|
|
|
|
/// this is used, then only the specified syscalls are traced. By limiting
|
|
|
|
/// the set of traced syscalls, we can reduce the overhead of the tracer.
|
2022-10-03 19:18:55 +00:00
|
|
|
#[clap(long)]
|
2021-12-30 00:14:23 +00:00
|
|
|
trace: Vec<Filter>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::main]
|
|
|
|
async fn main() -> Result<(), Error> {
|
|
|
|
let args = Opts::from_args();
|
|
|
|
|
|
|
|
let config = Config {
|
|
|
|
filters: args.trace,
|
|
|
|
};
|
|
|
|
|
|
|
|
let log_guard = args.common.init_tracing();
|
|
|
|
let tracer = reverie_ptrace::TracerBuilder::<Strace>::new(args.common.into())
|
|
|
|
.config(config)
|
|
|
|
.spawn()
|
|
|
|
.await?;
|
|
|
|
let (status, _) = tracer.wait().await?;
|
|
|
|
drop(log_guard); // Flush logs before exiting.
|
|
|
|
status.raise_or_exit()
|
|
|
|
}
|