Skip to content

Commit d678890

Browse files
authored
Rollup merge of rust-lang#48488 - varkor:handle-gdb-error-compiletest, 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.
2 parents 70f1de1 + 70db41c commit d678890

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/tools/compiletest/src/main.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -736,17 +736,12 @@ fn analyze_gdb(gdb: Option<String>) -> (Option<String>, Option<u32>, bool) {
736736
Some(ref s) => s,
737737
};
738738

739-
let version_line = Command::new(gdb)
740-
.arg("--version")
741-
.output()
742-
.map(|output| {
743-
String::from_utf8_lossy(&output.stdout)
744-
.lines()
745-
.next()
746-
.unwrap()
747-
.to_string()
748-
})
749-
.ok();
739+
let mut version_line = None;
740+
if let Ok(output) = Command::new(gdb).arg("--version").output() {
741+
if let Some(first_line) = String::from_utf8_lossy(&output.stdout).lines().next() {
742+
version_line = Some(first_line.to_string());
743+
}
744+
}
750745

751746
let version = match version_line {
752747
Some(line) => extract_gdb_version(&line),

0 commit comments

Comments
 (0)