Skip to content

Commit 7985ae0

Browse files
Rollup merge of rust-lang#39039 - michaelwoerister:ignore-gdb-version, r=nrc
debuginfo: Ignore optimized enum tests for GDB versions that can't handle them. Fixes rust-lang#38948. r? @nrc cc @Manishearth
2 parents 223e084 + 30ba990 commit 7985ae0

12 files changed

+54
-9
lines changed

src/test/debuginfo/borrowed-enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/test/debuginfo/generic-struct-style-enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/test/debuginfo/generic-tuple-style-enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/test/debuginfo/packed-struct.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/test/debuginfo/recursive-struct.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// ignore-lldb
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/test/debuginfo/struct-in-enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/test/debuginfo/struct-style-enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/test/debuginfo/tuple-style-enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/test/debuginfo/union-smoke.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
// min-lldb-version: 310
12+
// ignore-gdb-version: 7.11.90 - 7.12
1213

1314
// compile-flags:-g
1415

src/test/debuginfo/unique-enum.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// ignore-tidy-linelength
1212
// min-lldb-version: 310
13+
// ignore-gdb-version: 7.11.90 - 7.12
1314

1415
// compile-flags:-g
1516

src/tools/compiletest/src/header.rs

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,29 @@ impl EarlyProps {
7373
return false;
7474
}
7575

76-
if parse_name_directive(line, "ignore-gdb") {
76+
if !line.contains("ignore-gdb-version") &&
77+
parse_name_directive(line, "ignore-gdb") {
7778
return true;
7879
}
7980

8081
if let Some(actual_version) = config.gdb_version {
8182
if line.contains("min-gdb-version") {
82-
let min_version = line.trim()
83-
.split(' ')
84-
.last()
85-
.expect("Malformed GDB version directive");
83+
let (start_ver, end_ver) = extract_gdb_version_range(line);
84+
85+
if start_ver != end_ver {
86+
panic!("Expected single GDB version")
87+
}
8688
// Ignore if actual version is smaller the minimum required
8789
// version
88-
actual_version < extract_gdb_version(min_version).unwrap()
90+
actual_version < start_ver
91+
} else if line.contains("ignore-gdb-version") {
92+
let (min_version, max_version) = extract_gdb_version_range(line);
93+
94+
if max_version < min_version {
95+
panic!("Malformed GDB version range: max < min")
96+
}
97+
98+
actual_version >= min_version && actual_version <= max_version
8999
} else {
90100
false
91101
}
@@ -94,6 +104,34 @@ impl EarlyProps {
94104
}
95105
}
96106

107+
// Takes a directive of the form "ignore-gdb-version <version1> [- <version2>]",
108+
// returns the numeric representation of <version1> and <version2> as
109+
// tuple: (<version1> as u32, <version2> as u32)
110+
// If the <version2> part is omitted, the second component of the tuple
111+
// is the same as <version1>.
112+
fn extract_gdb_version_range(line: &str) -> (u32, u32) {
113+
const ERROR_MESSAGE: &'static str = "Malformed GDB version directive";
114+
115+
let range_components = line.split(' ')
116+
.flat_map(|word| word.split('-'))
117+
.filter(|word| word.len() > 0)
118+
.skip_while(|word| extract_gdb_version(word).is_none())
119+
.collect::<Vec<&str>>();
120+
121+
match range_components.len() {
122+
1 => {
123+
let v = extract_gdb_version(range_components[0]).unwrap();
124+
(v, v)
125+
}
126+
2 => {
127+
let v_min = extract_gdb_version(range_components[0]).unwrap();
128+
let v_max = extract_gdb_version(range_components[1]).expect(ERROR_MESSAGE);
129+
(v_min, v_max)
130+
}
131+
_ => panic!(ERROR_MESSAGE),
132+
}
133+
}
134+
97135
fn ignore_lldb(config: &Config, line: &str) -> bool {
98136
if config.mode != common::DebugInfoLldb {
99137
return false;

src/tools/compiletest/src/main.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,6 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
587587
return Some(((major * 1000) + minor) * 1000 + patch);
588588
}
589589

590-
println!("Could not extract GDB version from line '{}'", full_version_line);
591590
None
592591
}
593592

@@ -624,8 +623,6 @@ fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
624623
}).collect::<String>();
625624
if !vers.is_empty() { return Some(vers) }
626625
}
627-
println!("Could not extract LLDB version from line '{}'",
628-
full_version_line);
629626
}
630627
}
631628
None

0 commit comments

Comments
 (0)