-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add basic CDB support to debuginfo compiletest s, to help catch *.natvis
regressions, like those fixed in #60687.
#60970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bors
merged 3 commits into
rust-lang:master
from
MaulingMonkey:pr-compiletest-cdb-support
May 23, 2019
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#![crate_name = "compiletest"] | ||
#![feature(test)] | ||
#![feature(path_buf_capacity)] | ||
#![feature(vec_remove_item)] | ||
#![deny(warnings, rust_2018_idioms)] | ||
|
||
|
@@ -8,7 +9,7 @@ extern crate test; | |
use crate::common::CompareMode; | ||
use crate::common::{expected_output_path, output_base_dir, output_relative_path, UI_EXTENSIONS}; | ||
use crate::common::{Config, TestPaths}; | ||
use crate::common::{DebugInfoBoth, DebugInfoGdb, DebugInfoLldb, Mode, Pretty}; | ||
use crate::common::{DebugInfoCdb, DebugInfoGdbLldb, DebugInfoGdb, DebugInfoLldb, Mode, Pretty}; | ||
use getopts::Options; | ||
use std::env; | ||
use std::ffi::OsString; | ||
|
@@ -164,6 +165,12 @@ pub fn parse_config(args: Vec<String>) -> Config { | |
.optopt("", "logfile", "file to log test execution to", "FILE") | ||
.optopt("", "target", "the target to build for", "TARGET") | ||
.optopt("", "host", "the host to build for", "HOST") | ||
.optopt( | ||
"", | ||
"cdb", | ||
"path to CDB to use for CDB debuginfo tests", | ||
"PATH", | ||
) | ||
.optopt( | ||
"", | ||
"gdb", | ||
|
@@ -273,6 +280,7 @@ pub fn parse_config(args: Vec<String>) -> Config { | |
|
||
let target = opt_str2(matches.opt_str("target")); | ||
let android_cross_path = opt_path(matches, "android-cross-path"); | ||
let cdb = analyze_cdb(matches.opt_str("cdb"), &target); | ||
let (gdb, gdb_version, gdb_native_rust) = analyze_gdb(matches.opt_str("gdb"), &target, | ||
&android_cross_path); | ||
let (lldb_version, lldb_native_rust) = extract_lldb_version(matches.opt_str("lldb-version")); | ||
|
@@ -319,6 +327,7 @@ pub fn parse_config(args: Vec<String>) -> Config { | |
target_rustcflags: matches.opt_str("target-rustcflags"), | ||
target: target, | ||
host: opt_str2(matches.opt_str("host")), | ||
cdb, | ||
gdb, | ||
gdb_version, | ||
gdb_native_rust, | ||
|
@@ -421,7 +430,7 @@ pub fn opt_str2(maybestr: Option<String>) -> String { | |
|
||
pub fn run_tests(config: &Config) { | ||
if config.target.contains("android") { | ||
if config.mode == DebugInfoGdb || config.mode == DebugInfoBoth { | ||
if config.mode == DebugInfoGdb || config.mode == DebugInfoGdbLldb { | ||
println!( | ||
"{} debug-info test uses tcp 5039 port.\ | ||
please reserve it", | ||
|
@@ -440,8 +449,8 @@ pub fn run_tests(config: &Config) { | |
|
||
match config.mode { | ||
// Note that we don't need to emit the gdb warning when | ||
// DebugInfoBoth, so it is ok to list that here. | ||
DebugInfoBoth | DebugInfoLldb => { | ||
// DebugInfoGdbLldb, so it is ok to list that here. | ||
DebugInfoGdbLldb | DebugInfoLldb => { | ||
if let Some(lldb_version) = config.lldb_version.as_ref() { | ||
if is_blacklisted_lldb_version(&lldb_version[..]) { | ||
println!( | ||
|
@@ -470,7 +479,8 @@ pub fn run_tests(config: &Config) { | |
return; | ||
} | ||
} | ||
_ => { /* proceed */ } | ||
|
||
DebugInfoCdb | _ => { /* proceed */ } | ||
} | ||
|
||
// FIXME(#33435) Avoid spurious failures in codegen-units/partitioning tests. | ||
|
@@ -667,7 +677,7 @@ pub fn make_test(config: &Config, testpaths: &TestPaths) -> Vec<test::TestDescAn | |
&early_props, | ||
revision.map(|s| s.as_str()), | ||
) | ||
|| ((config.mode == DebugInfoBoth || | ||
|| ((config.mode == DebugInfoGdbLldb || config.mode == DebugInfoCdb || | ||
config.mode == DebugInfoGdb || config.mode == DebugInfoLldb) | ||
&& config.target.contains("emscripten")) | ||
|| (config.mode == DebugInfoGdb && !early_props.ignore.can_run_gdb()) | ||
|
@@ -815,7 +825,7 @@ fn make_test_closure( | |
revision: Option<&String>, | ||
) -> test::TestFn { | ||
let mut config = config.clone(); | ||
if config.mode == DebugInfoBoth { | ||
if config.mode == DebugInfoGdbLldb { | ||
// If both gdb and lldb were ignored, then the test as a whole | ||
// would be ignored. | ||
if !ignore.can_run_gdb() { | ||
|
@@ -841,6 +851,48 @@ fn is_android_gdb_target(target: &String) -> bool { | |
} | ||
} | ||
|
||
/// Returns `true` if the given target is a MSVC target for the purpouses of CDB testing. | ||
fn is_pc_windows_msvc_target(target: &String) -> bool { | ||
target.ends_with("-pc-windows-msvc") | ||
} | ||
|
||
fn find_cdb(target: &String) -> Option<OsString> { | ||
if cfg!(windows) && is_pc_windows_msvc_target(target) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could this be inverted to reduce indentation? e.g.: if !current_condition {
return None;
}
// ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
let pf86 = env::var_os("ProgramFiles(x86)").or(env::var_os("ProgramFiles"))?; | ||
let cdb_arch = if cfg!(target_arch="x86") { | ||
"x86" | ||
} else if cfg!(target_arch="x86_64") { | ||
"x64" | ||
} else if cfg!(target_arch="aarch64") { | ||
"arm64" | ||
} else if cfg!(target_arch="arm") { | ||
"arm" | ||
} else { | ||
return None; // No compatible CDB.exe in the Windows 10 SDK | ||
}; | ||
|
||
let mut path = PathBuf::with_capacity(64); | ||
path.push(pf86); | ||
path.push(r"Windows Kits\10\Debuggers"); // We could check 8.1 etc. too? | ||
path.push(cdb_arch); | ||
path.push(r"cdb.exe"); | ||
|
||
if path.exists() { | ||
Some(path.into_os_string()) | ||
} else { | ||
None | ||
} | ||
} | ||
else { | ||
None | ||
} | ||
} | ||
|
||
/// Returns Path to CDB | ||
fn analyze_cdb(cdb: Option<String>, target: &String) -> Option<OsString> { | ||
cdb.map(|s| OsString::from(s)).or(find_cdb(target)) | ||
} | ||
|
||
/// Returns (Path to GDB, GDB Version, GDB has Rust Support) | ||
fn analyze_gdb(gdb: Option<String>, target: &String, android_cross_path: &PathBuf) | ||
-> (Option<String>, Option<u32>, bool) { | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this use existing stable methods instead of adding a new unstable feature?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! Can't reserve capacity without it, but that's an unimportant optimization at best.