Skip to content

Commit caaf743

Browse files
authored
Rollup merge of rust-lang#76390 - MaulingMonkey:pr-min-cdb-version, r=petrochenkov
debuginfo: Ignore HashMap .natvis tests before cdb 10.0.18362.1 CDB <10.0.18362.1 chokes on casts within HashMap's natvis visualizers. This PR adds support for "min-cdb-version" (per existing "min-gdb-version" and "min-lldb-version" filters) and uses it. CI uses a more recent version of CDB for testing and thus should still run the tests. Credit to @petrochenkov per rust-lang#76352 for helping catch this. ### SDK Testing | Win 10 SDK | x64 CDB | rustc 1.47.0-nightly (bf43421 2020-08-25) built-in .natvis | Note | | --------------------------------------------------------------------- | ----------------- | ------------------------------------------------------------- | ---- | | [10.0.19041.0](https://go.microsoft.com/fwlink/p/?linkid=2120843) | 10.0.19041.1 | ✔️ | CI | [10.0.18362.1](https://go.microsoft.com/fwlink/?linkid=2083338) | 10.0.18362.1 | ✔️ | MaulingMonkey | [10.0.17763.0](https://go.microsoft.com/fwlink/p/?LinkID=2033908) | 10.0.17763.132 | ❌ `Unable to find type 'tuple<u64,u64> *' for cast.` | [10.0.17134.12](https://go.microsoft.com/fwlink/p/?linkid=870807) | 10.0.17134.12 | ❌ `Unable to find type 'tuple<u64,u64> *' for cast.` | [10.0.16299.91](https://go.microsoft.com/fwlink/p/?linkid=864422) | 10.0.16299.91 | ❌ `Unable to find type 'tuple<u64,u64> *' for cast.` | [10.0.15063.468](https://go.microsoft.com/fwlink/p/?LinkId=845298) | 10.0.15063.468 | ❌ `Unable to find type 'tuple<u64,u64> *' for cast.` | [10.0.14393.795](https://go.microsoft.com/fwlink/p/?LinkId=838916) | 10.0.14321.1024 | ❌ `Unable to find type 'tuple<u64,u64> *' for cast.` | petrochenkov | [10.0.10586.212](https://go.microsoft.com/fwlink/p/?LinkID=698771) | 10.0.10586.567 | ❌ `Expected ')' at '+ 1)].__1'` | [10.0.10240](https://go.microsoft.com/fwlink/p/?LinkId=619296) | 10.0.10240? | ❔ Untested ### Rust Testing ```cmd x.py test --stage 1 src/tools/tidy x.py test --stage 1 --build x86_64-pc-windows-msvc src\test\debuginfo ``` Also verified test still fails when intentionally broken w/ CDB version >= min-cdb-version.
2 parents d80185b + 4046f92 commit caaf743

File tree

4 files changed

+55
-6
lines changed

4 files changed

+55
-6
lines changed

src/test/debuginfo/pretty-std-collections-hash.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// CDB doesn't like how libstd.natvis casts to tuples before this version.
2+
// https://github.com/rust-lang/rust/issues/76352#issuecomment-687640746
3+
// min-cdb-version: 10.0.18362.1
4+
15
// cdb-only
26
// compile-flags:-g
37

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,9 @@ pub struct Config {
261261
/// Path to / name of the Microsoft Console Debugger (CDB) executable
262262
pub cdb: Option<OsString>,
263263

264+
/// Version of CDB
265+
pub cdb_version: Option<[u16; 4]>,
266+
264267
/// Path to / name of the GDB executable
265268
pub gdb: Option<String>,
266269

src/tools/compiletest/src/header.rs

+22-3
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use std::path::{Path, PathBuf};
88
use tracing::*;
99

1010
use crate::common::{CompareMode, Config, Debugger, FailMode, Mode, PassMode};
11-
use crate::extract_gdb_version;
1211
use crate::util;
12+
use crate::{extract_cdb_version, extract_gdb_version};
1313

1414
#[cfg(test)]
1515
mod tests;
@@ -105,6 +105,10 @@ impl EarlyProps {
105105
props.ignore = true;
106106
}
107107

108+
if config.debugger == Some(Debugger::Cdb) && ignore_cdb(config, ln) {
109+
props.ignore = true;
110+
}
111+
108112
if config.debugger == Some(Debugger::Gdb) && ignore_gdb(config, ln) {
109113
props.ignore = true;
110114
}
@@ -131,6 +135,21 @@ impl EarlyProps {
131135

132136
return props;
133137

138+
fn ignore_cdb(config: &Config, line: &str) -> bool {
139+
if let Some(actual_version) = config.cdb_version {
140+
if let Some(min_version) = line.strip_prefix("min-cdb-version:").map(str::trim) {
141+
let min_version = extract_cdb_version(min_version).unwrap_or_else(|| {
142+
panic!("couldn't parse version range: {:?}", min_version);
143+
});
144+
145+
// Ignore if actual version is smaller than the minimum
146+
// required version
147+
return actual_version < min_version;
148+
}
149+
}
150+
false
151+
}
152+
134153
fn ignore_gdb(config: &Config, line: &str) -> bool {
135154
if let Some(actual_version) = config.gdb_version {
136155
if let Some(rest) = line.strip_prefix("min-gdb-version:").map(str::trim) {
@@ -142,8 +161,8 @@ impl EarlyProps {
142161
if start_ver != end_ver {
143162
panic!("Expected single GDB version")
144163
}
145-
// Ignore if actual version is smaller the minimum required
146-
// version
164+
// Ignore if actual version is smaller than the minimum
165+
// required version
147166
return actual_version < start_ver;
148167
} else if let Some(rest) = line.strip_prefix("ignore-gdb-version:").map(str::trim) {
149168
let (min_version, max_version) =

src/tools/compiletest/src/main.rs

+26-3
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
163163

164164
let target = opt_str2(matches.opt_str("target"));
165165
let android_cross_path = opt_path(matches, "android-cross-path");
166-
let cdb = analyze_cdb(matches.opt_str("cdb"), &target);
166+
let (cdb, cdb_version) = analyze_cdb(matches.opt_str("cdb"), &target);
167167
let (gdb, gdb_version, gdb_native_rust) =
168168
analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
169169
let (lldb_version, lldb_native_rust) = matches
@@ -216,6 +216,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
216216
target,
217217
host: opt_str2(matches.opt_str("host")),
218218
cdb,
219+
cdb_version,
219220
gdb,
220221
gdb_version,
221222
gdb_native_rust,
@@ -773,8 +774,30 @@ fn find_cdb(target: &str) -> Option<OsString> {
773774
}
774775

775776
/// Returns Path to CDB
776-
fn analyze_cdb(cdb: Option<String>, target: &str) -> Option<OsString> {
777-
cdb.map(OsString::from).or_else(|| find_cdb(target))
777+
fn analyze_cdb(cdb: Option<String>, target: &str) -> (Option<OsString>, Option<[u16; 4]>) {
778+
let cdb = cdb.map(OsString::from).or_else(|| find_cdb(target));
779+
780+
let mut version = None;
781+
if let Some(cdb) = cdb.as_ref() {
782+
if let Ok(output) = Command::new(cdb).arg("/version").output() {
783+
if let Some(first_line) = String::from_utf8_lossy(&output.stdout).lines().next() {
784+
version = extract_cdb_version(&first_line);
785+
}
786+
}
787+
}
788+
789+
(cdb, version)
790+
}
791+
792+
fn extract_cdb_version(full_version_line: &str) -> Option<[u16; 4]> {
793+
// Example full_version_line: "cdb version 10.0.18362.1"
794+
let version = full_version_line.rsplit(' ').next()?;
795+
let mut components = version.split('.');
796+
let major: u16 = components.next().unwrap().parse().unwrap();
797+
let minor: u16 = components.next().unwrap().parse().unwrap();
798+
let patch: u16 = components.next().unwrap_or("0").parse().unwrap();
799+
let build: u16 = components.next().unwrap_or("0").parse().unwrap();
800+
Some([major, minor, patch, build])
778801
}
779802

780803
/// Returns (Path to GDB, GDB Version, GDB has Rust Support)

0 commit comments

Comments
 (0)