Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ humility = { path = "./humility-core", package = "humility-core" }
humility-arch-arm = { path = "./humility-arch-arm" }
humility-auxflash = { path = "./humility-auxflash" }
humility-cortex = { path = "./humility-arch-cortex" }
humility-cmd = { path = "./humility-cmd", default-features = false }
humility-cli = { path = "./humility-cli" }
humility-cmd = { path = "./humility-cmd" }
humility-cli = { path = "./humility-cli", default-features = false }
humility-dump-agent = { path = "./humility-dump-agent" }
humility-doppel = { path = "./humility-doppel" }
humility-hiffy = { path = "./humility-hiffy" }
Expand Down
3 changes: 1 addition & 2 deletions DEVELOPING.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ So you've decided to add a subcommand to Humility. Here's what you need to do.

2. Review the settings in the `init` routine you cribbed from to make sure they
reflect your subcommand. In particular, the name must appear a second time in
the `name:` field, and `kind` should reflect whether you need an attached
target and archive, or not.
the `name:` field.

3. Cite your new subcommand from the root `Cargo.toml`. This needs to happen in
three places using two different names: in the `workspace.members` element
Expand Down
18 changes: 4 additions & 14 deletions cmd/auxflash/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ use anyhow::Result;
use clap::{CommandFactory, Parser};
use colored::Colorize;
use humility_cli::ExecutionContext;
use humility_cmd::CommandKind;

use humility_auxflash::AuxFlashHandler;
use humility_cmd::{Archive, Attach, Command, Validate};
use humility_cmd::Command;

#[derive(Parser, Debug)]
#[clap(name = "auxflash", about = env!("CARGO_PKG_DESCRIPTION"))]
Expand Down Expand Up @@ -99,9 +98,9 @@ fn auxflash_status(mut worker: AuxFlashHandler, verbose: bool) -> Result<()> {
}

fn auxflash(context: &mut ExecutionContext) -> Result<()> {
let core = &mut **context.core.as_mut().unwrap();
let subargs = AuxFlashArgs::try_parse_from(&context.cli.cmd)?;
let hubris = context.archive.as_ref().unwrap();
let hubris = &context.cli.archive()?;
let core = &mut *context.cli.attach_live_booted(hubris)?;
let mut worker = AuxFlashHandler::new(hubris, core, subargs.timeout)?;

match subargs.cmd {
Expand Down Expand Up @@ -132,14 +131,5 @@ fn auxflash(context: &mut ExecutionContext) -> Result<()> {
}

pub fn init() -> Command {
Command {
app: AuxFlashArgs::command(),
name: "auxflash",
run: auxflash,
kind: CommandKind::Attached {
archive: Archive::Required,
attach: Attach::LiveOnly,
validate: Validate::Booted,
},
}
Command { app: AuxFlashArgs::command(), name: "auxflash", run: auxflash }
}
7 changes: 1 addition & 6 deletions cmd/console-proxy/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::path::PathBuf;

use clap::{CommandFactory, Parser};

use humility_cmd::{Archive, Attach, Command, CommandKind, Validate};
use humility_cmd::Command;

#[cfg(not(windows))]
mod posix;
Expand Down Expand Up @@ -113,10 +113,5 @@ pub fn init() -> Command {
app: UartConsoleArgs::command(),
name: "console-proxy",
run: console_proxy,
kind: CommandKind::Attached {
archive: Archive::Required,
attach: Attach::LiveOnly,
validate: Validate::Booted,
},
}
}
4 changes: 2 additions & 2 deletions cmd/console-proxy/src/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,9 @@ impl UnrawTermiosGuard {
}

pub(super) fn console_proxy(context: &mut ExecutionContext) -> Result<()> {
let core = &mut **context.core.as_mut().unwrap();
let subargs = UartConsoleArgs::try_parse_from(&context.cli.cmd)?;
let hubris = context.archive.as_ref().unwrap();
let hubris = &context.cli.archive()?;
let core = &mut *context.cli.attach_live_booted(hubris)?;
let mut worker = UartConsoleHandler::new(
hubris,
core,
Expand Down
19 changes: 5 additions & 14 deletions cmd/counters/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ use humility::core::Core;
use humility::hubris::*;
use humility::reflect::{self, Load, Value};
use humility_cli::ExecutionContext;
use humility_cmd::{Archive, Attach, Command, CommandKind, Validate};
use humility_cmd::Command;
use humility_doppel::{CountedRingbuf, CounterVariant, Counters};
use indexmap::IndexMap;
use std::collections::BTreeMap;
Expand Down Expand Up @@ -324,12 +324,11 @@ const LIST_HINT: &str = "use `humility counters list` to list all \
available counters";

fn counters(context: &mut ExecutionContext) -> Result<()> {
let core = &mut **context.core.as_mut().unwrap();
let hubris = context.archive.as_ref().unwrap();

let hubris = &context.cli.archive()?;
let subargs = CountersArgs::try_parse_from(&context.cli.cmd)?;

if let Some(Subcmd::Ipc(ipc)) = subargs.command {
let core = &mut *context.cli.attach_live_or_dump_match(hubris)?;
return ipc.ipc_counter_dump(hubris, core);
}
let name = subargs.name();
Expand Down Expand Up @@ -428,6 +427,7 @@ fn counters(context: &mut ExecutionContext) -> Result<()> {
}

let mut json: IndexMap<&str, IndexMap<_, _>> = IndexMap::new();
let core = &mut *context.cli.attach_live_or_dump_match(hubris)?;
for (t, ctrs) in counters {
// Try not to use `?` here, because it causes one bad counter to make
// them all unavailable. Instead, construct an iterator of
Expand Down Expand Up @@ -623,14 +623,5 @@ fn hint() -> impl std::fmt::Display {
}

pub fn init() -> Command {
Command {
app: CountersArgs::command(),
name: "counters",
run: counters,
kind: CommandKind::Attached {
archive: Archive::Required,
attach: Attach::Any,
validate: Validate::Match,
},
}
Command { app: CountersArgs::command(), name: "counters", run: counters }
}
20 changes: 5 additions & 15 deletions cmd/dashboard/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use hif::*;
use humility::core::Core;
use humility::hubris::*;
use humility_cli::ExecutionContext;
use humility_cmd::{Archive, Attach, Command, CommandKind, Validate};
use humility_cmd::Command;
use humility_hiffy::*;
use humility_idol::{self as idol, HubrisIdol};
use ratatui::{
Expand Down Expand Up @@ -736,11 +736,10 @@ where
}

fn dashboard(context: &mut ExecutionContext) -> Result<()> {
let hubris = context.archive.as_ref().unwrap();

let core = &mut **context.core.as_mut().unwrap();

let subargs = DashboardArgs::try_parse_from(&context.cli.cmd)?;
let hubris = &context.cli.archive()?;
let core = &mut *context.cli.attach_live_booted(hubris)?;

let dashboard = Dashboard::new(hubris, core, &subargs)?;

// setup terminal
Expand All @@ -767,16 +766,7 @@ fn dashboard(context: &mut ExecutionContext) -> Result<()> {
}

pub fn init() -> Command {
Command {
app: DashboardArgs::command(),
name: "dashboard",
run: dashboard,
kind: CommandKind::Attached {
archive: Archive::Required,
attach: Attach::LiveOnly,
validate: Validate::Booted,
},
}
Command { app: DashboardArgs::command(), name: "dashboard", run: dashboard }
}

fn sensor_ops(
Expand Down
3 changes: 1 addition & 2 deletions cmd/debugmailbox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use anyhow::{Context, Result, bail};
use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
use clap::{CommandFactory, Parser};
use humility_cli::ExecutionContext;
use humility_cmd::{Archive, Command, CommandKind};
use humility_cmd::Command;
use probe_rs::{
DebugProbeError, DebugProbeSelector, Probe,
architecture::arm::{ApAddress, ArmProbeInterface, DapError, DpAddress},
Expand Down Expand Up @@ -464,6 +464,5 @@ pub fn init() -> Command {
app: DebugMailboxArgs::command(),
name: "debugmailbox",
run: debugmailboxcmd,
kind: CommandKind::Unattached { archive: Archive::Ignored },
}
}
19 changes: 4 additions & 15 deletions cmd/diagnose/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,14 @@ use clap::{CommandFactory, Parser};
use humility::core::Core;
use humility::hubris::*;
use humility_cli::ExecutionContext;
use humility_cmd::CommandKind;
use humility_cmd::{Archive, Attach, Command, Validate};
use humility_cmd::Command;
use humility_doppel::{GenOrRestartCount, Task, TaskDesc, TaskState};
use std::num::NonZeroU32;
use std::time::Duration;

/// Command registration.
pub fn init() -> Command {
Command {
app: DiagnoseArgs::command(),
name: "diagnose",
run: diagnose,
kind: CommandKind::Attached {
archive: Archive::Required,
attach: Attach::Any,
validate: Validate::Booted,
},
}
Command { app: DiagnoseArgs::command(), name: "diagnose", run: diagnose }
}

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -83,10 +73,9 @@ fn section(title: &str) {
}

fn diagnose(context: &mut ExecutionContext) -> Result<()> {
let core = &mut **context.core.as_mut().unwrap();
let hubris = context.archive.as_ref().unwrap();

let subargs = DiagnoseArgs::try_parse_from(&context.cli.cmd)?;
let hubris = &context.cli.archive()?;
let core = &mut *context.cli.attach_live_or_dump_booted(hubris)?;

section("Initial Inspection");

Expand Down
7 changes: 3 additions & 4 deletions cmd/discover/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use colored::Colorize;
use hubpack::SerializedSize;
use humility::net::decode_iface;
use humility_cli::ExecutionContext;
use humility_cmd::{Archive, Command, CommandKind};
use humility_cmd::Command;
use serde::{Deserialize, Serialize};

#[derive(Parser, Debug)]
Expand Down Expand Up @@ -313,9 +313,9 @@ fn discover_dump(seen: BTreeSet<Target>, image_id: Option<&[u8]>) {

fn discover_run(context: &mut ExecutionContext) -> Result<()> {
let subargs = DiscoverArgs::try_parse_from(&context.cli.cmd)?;
let hubris = context.archive.as_ref().unwrap();
let hubris = &context.cli.try_archive()?;

let image_id = hubris.image_id();
let image_id = hubris.as_ref().and_then(|h| h.image_id());
if image_id.is_none() {
humility::warn!("no archive provided; not checking for compatibility");
}
Expand All @@ -330,6 +330,5 @@ pub fn init() -> Command {
app: DiscoverArgs::command(),
name: "discover",
run: discover_run,
kind: CommandKind::Detached { archive: Archive::Optional },
}
}
9 changes: 2 additions & 7 deletions cmd/doc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use anyhow::{Result, bail};
use clap::{CommandFactory, Parser};
use humility_cli::ExecutionContext;
use humility_cmd::{Archive, Command, CommandKind};
use humility_cmd::Command;
use std::collections::HashMap;
use termimad::*;

Expand Down Expand Up @@ -64,10 +64,5 @@ fn doc(context: &mut ExecutionContext) -> Result<()> {
}

pub fn init() -> Command {
Command {
app: DocArgs::command(),
name: "doc",
run: doc,
kind: CommandKind::Unattached { archive: Archive::Ignored },
}
Command { app: DocArgs::command(), name: "doc", run: doc }
}
18 changes: 4 additions & 14 deletions cmd/dump/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ use humility::core::Core;
use humility::hubris::*;
use humility_arch_arm::ARMRegister;
use humility_cli::ExecutionContext;
use humility_cmd::{Archive, Attach, Command, CommandKind, Validate};
use humility_cmd::Command;
use humility_dump_agent::{
DumpAgent, DumpAgentCore, DumpAgentExt, DumpArea, DumpBreakdown,
HiffyDumpAgent, UdpDumpAgent, task_areas,
Expand Down Expand Up @@ -855,10 +855,9 @@ fn dump_agent_status(
}

fn dumpcmd(context: &mut ExecutionContext) -> Result<()> {
let core = &mut **context.core.as_mut().unwrap();
let hubris = context.archive.as_ref().unwrap();

let subargs = DumpArgs::try_parse_from(&context.cli.cmd)?;
let hubris = &context.cli.archive()?;
let core = &mut *context.cli.attach_live_match(hubris)?;
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we care about the ability to dump from a dump? Probably not, but it was previously possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like if we actually want that we're probably going to want other tooling


if subargs.force_dump_agent && core.is_net() {
bail!("can only force the dump agent when attached via debug probe");
Expand Down Expand Up @@ -903,14 +902,5 @@ fn dumpcmd(context: &mut ExecutionContext) -> Result<()> {
}

pub fn init() -> Command {
Command {
app: DumpArgs::command(),
name: "dump",
run: dumpcmd,
kind: CommandKind::Attached {
archive: Archive::Required,
attach: Attach::Any,
validate: Validate::Match,
},
}
Command { app: DumpArgs::command(), name: "dump", run: dumpcmd }
}
18 changes: 4 additions & 14 deletions cmd/ereport/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use humility::{
hubris::{HubrisArchive, HubrisTask},
};
use humility_cli::ExecutionContext;
use humility_cmd::{Archive, Attach, Command, CommandKind, Validate};
use humility_cmd::Command;

use anyhow::{Context, Result, anyhow};
use std::collections::VecDeque;
Expand Down Expand Up @@ -337,25 +337,15 @@ fn pretty_print_value(value: &ciborium::Value, indent: usize, is_key: bool) {
}

fn ereport(context: &mut ExecutionContext) -> Result<()> {
let core = &mut **context.core.as_mut().unwrap();
let hubris = context.archive.as_ref().unwrap();

let subargs = EreportArgs::try_parse_from(&context.cli.cmd)?;
let hubris = &context.cli.archive()?;
let core = &mut *context.cli.attach_live_or_dump_booted(hubris)?;

match subargs.cmd {
EreportCmd::Dump { flags } => ereport_print(hubris, core, flags),
}
}

pub fn init() -> Command {
Command {
app: EreportArgs::command(),
name: "ereport",
run: ereport,
kind: CommandKind::Attached {
archive: Archive::Required,
attach: Attach::Any,
validate: Validate::Booted,
},
}
Command { app: EreportArgs::command(), name: "ereport", run: ereport }
}
Loading
Loading