reverie/reverie-examples/chrome-trace/main.rs
Vladimir Makaev 03cbd6044d update hermetic_infra/** files with correct license header - 1/x
Summary:
Followed guide here https://www.internalfb.com/intern/wiki/Linting/License_Lint/ to add fbcode/hermetic_infra/** code to license linter. As we have parts of our code shipped as Open Source it's important to get this automated

This diff is updating existing file's licenses to not get conflict after lint rule enablement

Reviewed By: jasonwhite

Differential Revision: D40674080

fbshipit-source-id: da6ecac036f8964619cf7912058f3a911558e7b1
2022-10-26 12:18:14 -07:00

58 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()
}