Rollup merge of #39039 - michaelwoerister:ignore-gdb-version, r=nrc

debuginfo: Ignore optimized enum tests for GDB versions that can't handle them.

Fixes https://github.com/rust-lang/rust/issues/38948.

r? @nrc
cc @Manishearth
This commit is contained in:
Guillaume Gomez 2017-01-19 11:56:03 +01:00 committed by GitHub
commit 7985ae0bb1
12 changed files with 54 additions and 9 deletions

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// ignore-lldb // ignore-lldb
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -9,6 +9,7 @@
// except according to those terms. // except according to those terms.
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -10,6 +10,7 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// min-lldb-version: 310 // min-lldb-version: 310
// ignore-gdb-version: 7.11.90 - 7.12
// compile-flags:-g // compile-flags:-g

View File

@ -73,19 +73,29 @@ fn ignore_gdb(config: &Config, line: &str) -> bool {
return false; return false;
} }
if parse_name_directive(line, "ignore-gdb") { if !line.contains("ignore-gdb-version") &&
parse_name_directive(line, "ignore-gdb") {
return true; return true;
} }
if let Some(actual_version) = config.gdb_version { if let Some(actual_version) = config.gdb_version {
if line.contains("min-gdb-version") { if line.contains("min-gdb-version") {
let min_version = line.trim() let (start_ver, end_ver) = extract_gdb_version_range(line);
.split(' ')
.last() if start_ver != end_ver {
.expect("Malformed GDB version directive"); panic!("Expected single GDB version")
}
// Ignore if actual version is smaller the minimum required // Ignore if actual version is smaller the minimum required
// version // version
actual_version < extract_gdb_version(min_version).unwrap() actual_version < start_ver
} else if line.contains("ignore-gdb-version") {
let (min_version, max_version) = extract_gdb_version_range(line);
if max_version < min_version {
panic!("Malformed GDB version range: max < min")
}
actual_version >= min_version && actual_version <= max_version
} else { } else {
false false
} }
@ -94,6 +104,34 @@ fn ignore_gdb(config: &Config, line: &str) -> bool {
} }
} }
// Takes a directive of the form "ignore-gdb-version <version1> [- <version2>]",
// returns the numeric representation of <version1> and <version2> as
// tuple: (<version1> as u32, <version2> as u32)
// If the <version2> part is omitted, the second component of the tuple
// is the same as <version1>.
fn extract_gdb_version_range(line: &str) -> (u32, u32) {
const ERROR_MESSAGE: &'static str = "Malformed GDB version directive";
let range_components = line.split(' ')
.flat_map(|word| word.split('-'))
.filter(|word| word.len() > 0)
.skip_while(|word| extract_gdb_version(word).is_none())
.collect::<Vec<&str>>();
match range_components.len() {
1 => {
let v = extract_gdb_version(range_components[0]).unwrap();
(v, v)
}
2 => {
let v_min = extract_gdb_version(range_components[0]).unwrap();
let v_max = extract_gdb_version(range_components[1]).expect(ERROR_MESSAGE);
(v_min, v_max)
}
_ => panic!(ERROR_MESSAGE),
}
}
fn ignore_lldb(config: &Config, line: &str) -> bool { fn ignore_lldb(config: &Config, line: &str) -> bool {
if config.mode != common::DebugInfoLldb { if config.mode != common::DebugInfoLldb {
return false; return false;

View File

@ -587,7 +587,6 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
return Some(((major * 1000) + minor) * 1000 + patch); return Some(((major * 1000) + minor) * 1000 + patch);
} }
println!("Could not extract GDB version from line '{}'", full_version_line);
None None
} }
@ -624,8 +623,6 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
}).collect::<String>(); }).collect::<String>();
if !vers.is_empty() { return Some(vers) } if !vers.is_empty() { return Some(vers) }
} }
println!("Could not extract LLDB version from line '{}'",
full_version_line);
} }
} }
None None