mirror of
https://github.com/facebookexperimental/reverie.git
synced 2025-02-09 21:56:13 +00:00
Summary: See rationale in the linked task I was planning to build a new CLI and decided to follow CLI Foundation recommentation. Since hermit is effectively not released it's a good time to migrate now which hasn't been hard mostly followed the fastmods on the task and and some manual fixes of the remaining code Reviewed By: jasonwhite Differential Revision: D39953166 fbshipit-source-id: 6e917c6a8ea2ee8258e7e6068e9c9e787ebf0989
59 lines
1.4 KiB
Rust
59 lines
1.4 KiB
Rust
/*
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
*
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
//! Runs a process, gathering metadata about all of the processes that were ran
|
|
//! and displays it as a tree using Graphviz.
|
|
|
|
mod event;
|
|
mod global_state;
|
|
mod tool;
|
|
|
|
use std::fs;
|
|
use std::io;
|
|
use std::path::PathBuf;
|
|
|
|
use anyhow::Context;
|
|
use clap::Parser;
|
|
use reverie::Error;
|
|
use reverie_util::CommonToolArguments;
|
|
use tool::ChromeTrace;
|
|
|
|
/// A tool to render a summary of the process tree.
|
|
#[derive(Debug, Parser)]
|
|
struct Args {
|
|
#[clap(flatten)]
|
|
common: CommonToolArguments,
|
|
|
|
/// The path to write out Chrome trace file. This can be loaded with
|
|
/// `chrome://tracing`.
|
|
#[clap(long)]
|
|
out: Option<PathBuf>,
|
|
}
|
|
|
|
#[tokio::main]
|
|
async fn main() -> Result<(), Error> {
|
|
let args = Args::from_args();
|
|
|
|
let log_guard = args.common.init_tracing();
|
|
let tracer = reverie_ptrace::TracerBuilder::<ChromeTrace>::new(args.common.into())
|
|
.spawn()
|
|
.await?;
|
|
let (status, global_state) = tracer.wait().await?;
|
|
|
|
if let Some(path) = args.out {
|
|
let mut f = io::BufWriter::new(fs::File::create(path)?);
|
|
global_state
|
|
.chrome_trace(&mut f)
|
|
.context("failed to generate Chrome trace")?;
|
|
}
|
|
|
|
// Flush logs before exiting.
|
|
drop(log_guard);
|
|
status.raise_or_exit()
|
|
}
|