reverie/reverie-examples/debug.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

52 lines
1.5 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.
*/
//! This instrumentation tool does nothing except acting as a gdbserver.
use clap::Parser;
use reverie::Error;
use reverie::Subscription;
use reverie::Tool;
use reverie_util::CommonToolArguments;
use serde::Deserialize;
use serde::Serialize;
#[derive(Debug, Default, Serialize, Deserialize)]
struct DebugTool;
impl Tool for DebugTool {
fn subscriptions(_cfg: &()) -> Subscription {
Subscription::none()
}
}
/// A tool that acts as a GDB server. The process will start in a stopped state,
/// waiting for a GDB client to connect. Once the connection is complete,
/// execution of the guest process will continue.
#[derive(Debug, Parser)]
struct Args {
#[clap(flatten)]
common_opts: CommonToolArguments,
/// Launch gdbserver on a given port
#[clap(long, default_value = "1234")]
port: u16,
}
#[tokio::main]
async fn main() -> Result<(), Error> {
let args = Args::from_args();
let port = args.port;
let log_guard = args.common_opts.init_tracing();
eprintln!("Listening on port {}", port);
let tracer = reverie_ptrace::TracerBuilder::<DebugTool>::new(args.common_opts.into())
.gdbserver(port)
.spawn()
.await?;
let (status, _global_state) = tracer.wait().await?;
drop(log_guard); // Flush logs before exiting.
status.raise_or_exit()
}