Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions qemu-run/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,17 @@ fn notmain() -> Result<Option<i32>, anyhow::Error> {
// grab stdout
command.stdout(Stdio::piped());

println!("Running QEMU command: {}", pretty(&command));

//
// Run QEMU
//

let mut child = KillOnDrop(
command
.spawn()
.expect("Error running qemu-system-arm; perhaps you haven't installed it yet?"),
);
let mut child = match command.spawn() {
Ok(child) => KillOnDrop(child),
Err(e) => {
bail!("Error running QEMU: {}; perhaps you haven't installed it yet?", e);
}
};

//
// Decode stdout as defmt data
Expand Down Expand Up @@ -235,6 +237,20 @@ fn notmain() -> Result<Option<i32>, anyhow::Error> {
Ok(exit_code)
}

fn pretty(cmd: &Command) -> String {
let mut out = String::new();
if let Some(prog) = cmd.get_program().to_str() {
out.push_str(prog);
}
for arg in cmd.get_args() {
if let Some(s) = arg.to_str() {
out.push(' ');
out.push_str(s);
}
}
out
}

/// Pump the decoder and print any new frames
fn decode_and_print(
decoder: &mut dyn StreamDecoder,
Expand Down
Loading