Skip to content

Commit

Permalink
Rollup merge of rust-lang#48488 - varkor:handle-gdb-error-compiletest…
Browse files Browse the repository at this point in the history
…, r=michaelwoerister

Handle gdb command failure gracefully in compiletest

Previously, if the gdb command was available, but threw an error, compiletest would panic.  This is obviously not good. Now, gdb is treated as missing if calling `gdb --version` does not output anything on stdout.
  • Loading branch information
kennytm committed Feb 28, 2018
2 parents 428f002 + 70db41c commit a3fecfb
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,17 +736,12 @@ fn analyze_gdb(gdb: Option<String>) -> (Option<String>, Option<u32>, bool) {
Some(ref s) => s,
};

let version_line = Command::new(gdb)
.arg("--version")
.output()
.map(|output| {
String::from_utf8_lossy(&output.stdout)
.lines()
.next()
.unwrap()
.to_string()
})
.ok();
let mut version_line = None;
if let Ok(output) = Command::new(gdb).arg("--version").output() {
if let Some(first_line) = String::from_utf8_lossy(&output.stdout).lines().next() {
version_line = Some(first_line.to_string());
}
}

let version = match version_line {
Some(line) => extract_gdb_version(&line),
Expand Down

0 comments on commit a3fecfb

Please sign in to comment.