Skip to content

Commit e72e4df

Browse files
debuginfo: Improve GDB version handling in compiletest tool
1 parent 849ae5d commit e72e4df

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/compiletest/compiletest.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,23 @@ pub fn make_metrics_test_closure(config: &Config, testfile: &Path) -> test::Test
381381

382382
fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
383383
match full_version_line {
384-
Some(full_version_line) => {
384+
Some(ref full_version_line)
385+
if full_version_line.as_slice().trim().len() > 0 => {
385386
let full_version_line = full_version_line.as_slice().trim();
386-
let re = Regex::new(r"[^0-9]([0-9]\.[0-9])([^0-9]|$)").unwrap();
387+
388+
let re = Regex::new(r"(^|[^0-9])([0-9]\.[0-9])([^0-9]|$)").unwrap();
387389

388390
match re.captures(full_version_line) {
389391
Some(captures) => {
390-
Some(captures.at(1).to_string())
392+
Some(captures.at(2).to_string())
393+
}
394+
None => {
395+
println!("Could not extract GDB version from line '{}'",
396+
full_version_line);
397+
None
391398
}
392-
None => None
393399
}
394400
},
395-
None => None
401+
_ => None
396402
}
397403
}

src/compiletest/runtest.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,9 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
473473

474474
match config.gdb_version {
475475
Some(ref version) => {
476+
println!("NOTE: compiletest thinks it is using GDB version {}",
477+
version.as_slice());
478+
476479
if header::gdb_version_to_int(version.as_slice()) >
477480
header::gdb_version_to_int("7.4") {
478481
// Add the directory containing the pretty printers to
@@ -488,7 +491,10 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
488491
.as_slice());
489492
}
490493
}
491-
_ => { /* nothing to do */ }
494+
_ => {
495+
println!("NOTE: compiletest does not know which version of \
496+
GDB it is using");
497+
}
492498
}
493499

494500
// Load the target executable

0 commit comments

Comments
 (0)