-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This command enables ProcessLimbo and runs the debugger, expecting something to crash in the near future. When the debugging session eventually ends, ProcessLimbo is disabled again. Change-Id: Icbdadcbe24b27ba2bfa2c681af6de5272b08167a Reviewed-on: https://fuchsia-review.googlesource.com/c/fuchsia/+/965623 Reviewed-by: Adam Barth <[email protected]> Commit-Queue: Jacob Rutherford <[email protected]> Reviewed-by: Clayton Wilkinson <[email protected]>
- Loading branch information
Showing
6 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Copyright 2023 The Fuchsia Authors. All rights reserved. | ||
# Use of this source code is governed by a BSD-style license that can be | ||
# found in the LICENSE file. | ||
|
||
import("//src/developer/ffx/build/ffx_plugin.gni") | ||
|
||
ffx_plugin("ffx_debug_crash") { | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
args_sources = [ "src/args.rs" ] | ||
sources = [ "src/lib.rs" ] | ||
|
||
deps = [ | ||
"//sdk/fidl/fuchsia.debugger:fuchsia.debugger_rust", | ||
"//sdk/fidl/fuchsia.exception:fuchsia.exception_rust", | ||
"//src/developer/debug/ffx_zxdb", | ||
"//src/developer/ffx/lib/fho:lib", | ||
"//third_party/rust_crates:anyhow", | ||
"//third_party/rust_crates:async-trait", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2023 The Fuchsia Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
use argh::{ArgsInfo, FromArgs}; | ||
use ffx_core::ffx_command; | ||
|
||
#[ffx_command()] | ||
#[derive(ArgsInfo, FromArgs, PartialEq, Debug)] | ||
#[argh(subcommand, name = "crash", description = "catch a crashing process on the target")] | ||
pub struct CrashCommand {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright 2023 The Fuchsia Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use ffx_debug_crash_args::CrashCommand; | ||
use ffx_zxdb::Debugger; | ||
use fho::{moniker, FfxMain, FfxTool, SimpleWriter}; | ||
use fidl_fuchsia_debugger as fdebugger; | ||
use fidl_fuchsia_exception::ProcessLimboProxy; | ||
|
||
#[derive(FfxTool)] | ||
pub struct CrashTool { | ||
#[command] | ||
_cmd: CrashCommand, | ||
#[with(moniker("/core/exceptions"))] | ||
limbo_proxy: ProcessLimboProxy, | ||
#[with(moniker("/core/debugger"))] | ||
launcher_proxy: fdebugger::LauncherProxy, | ||
} | ||
|
||
fho::embedded_plugin!(CrashTool); | ||
|
||
#[async_trait(?Send)] | ||
impl FfxMain for CrashTool { | ||
type Writer = SimpleWriter; | ||
|
||
async fn main(self, mut _writer: Self::Writer) -> fho::Result<()> { | ||
crash_tool_impl(self.limbo_proxy, self.launcher_proxy).await?; | ||
Ok(()) | ||
} | ||
} | ||
|
||
async fn run_debugger(launcher_proxy: fdebugger::LauncherProxy) -> Result<()> { | ||
let mut debugger = Debugger::launch(launcher_proxy).await?; | ||
debugger.command.push_str("--auto-attach-limbo"); | ||
debugger.run().await | ||
} | ||
|
||
async fn crash_tool_impl( | ||
limbo_proxy: ProcessLimboProxy, | ||
launcher_proxy: fdebugger::LauncherProxy, | ||
) -> Result<()> { | ||
limbo_proxy.set_active(true).await?; | ||
let run_result = run_debugger(launcher_proxy).await; | ||
limbo_proxy.set_active(false).await?; | ||
|
||
run_result?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/developer/ffx/tests/cli-goldens/goldens/ffx/debug/crash.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "crash", | ||
"description": "catch a crashing process on the target", | ||
"examples": [], | ||
"flags": [ | ||
{ | ||
"kind": "Switch", | ||
"optionality": "optional", | ||
"long": "--help", | ||
"short": null, | ||
"description": "display usage information", | ||
"hidden": false | ||
} | ||
], | ||
"notes": [], | ||
"commands": [], | ||
"positionals": [], | ||
"error_codes": [] | ||
} |