debuginfo: Add LLDB version handling to test infrastructure.

This commit is contained in:
Michael Woerister 2014-10-02 11:35:24 +02:00
parent 593174b42d
commit 895aac9935
6 changed files with 95 additions and 3 deletions

6
configure vendored
View File

@ -535,13 +535,17 @@ probe CFG_LLDB lldb
if [ ! -z "$CFG_GDB" ]
then
# Extract the version
# Store GDB's version
CFG_GDB_VERSION=$($CFG_GDB --version 2>/dev/null | head -1)
putvar CFG_GDB_VERSION
fi
if [ ! -z "$CFG_LLDB" ]
then
# Store LLDB's version
CFG_LLDB_VERSION=$($CFG_LLDB --version 2>/dev/null | head -1)
putvar CFG_LLDB_VERSION
# If CFG_LLDB_PYTHON_DIR is not already set from the outside and valid, try to read it from
# LLDB via the -P commandline options.
if [ -z "$CFG_LLDB_PYTHON_DIR" ] || [ ! -d "$CFG_LLDB_PYTHON_DIR" ]

View File

@ -625,6 +625,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
--target $(2) \
--host $(3) \
--gdb-version="$(CFG_GDB_VERSION)" \
--lldb-version="$(CFG_LLDB_VERSION)" \
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
--adb-path=$(CFG_ADB) \
--adb-test-dir=$(CFG_ADB_TEST_DIR) \

View File

@ -133,6 +133,9 @@ pub struct Config {
// Version of GDB
pub gdb_version: Option<String>,
// Version of LLDB
pub lldb_version: Option<String>,
// Path to the android tools
pub android_cross_path: Path,

View File

@ -71,7 +71,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
optflag("", "jit", "run tests under the JIT"),
optopt("", "target", "the target to build for", "TARGET"),
optopt("", "host", "the host to build for", "HOST"),
optopt("", "gdb-version", "the version of GDB used", "MAJOR.MINOR"),
optopt("", "gdb-version", "the version of GDB used", "VERSION STRING"),
optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING"),
optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
optopt("", "adb-path", "path to the android debugger", "PATH"),
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
@ -149,6 +150,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
target: opt_str2(matches.opt_str("target")),
host: opt_str2(matches.opt_str("host")),
gdb_version: extract_gdb_version(matches.opt_str("gdb-version")),
lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
android_cross_path: opt_path(matches, "android-cross-path"),
adb_path: opt_str2(matches.opt_str("adb-path")),
adb_test_dir: opt_str2(matches.opt_str("adb-test-dir")),
@ -391,3 +393,37 @@ fn extract_gdb_version(full_version_line: Option<String>) -> Option<String> {
_ => None
}
}
fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
// Extract the major LLDB version from the given version string.
// LLDB version strings are different for Apple and non-Apple platforms.
// At the moment, this function only supports the Apple variant, which looks
// like this:
//
// LLDB-179.5 (older versions)
// lldb-300.2.51 (new versions)
//
// We are only interested in the major version number, so this function
// will return `Some("179")` and `Some("300")` respectively.
match full_version_line {
Some(ref full_version_line)
if full_version_line.as_slice().trim().len() > 0 => {
let full_version_line = full_version_line.as_slice().trim();
let re = Regex::new(r"[Ll][Ll][Dd][Bb]-([0-9]+)").unwrap();
match re.captures(full_version_line) {
Some(captures) => {
Some(captures.at(1).to_string())
}
None => {
println!("Could not extract LLDB version from line '{}'",
full_version_line);
None
}
}
},
_ => None
}
}

View File

@ -181,6 +181,34 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
}
}
fn ignore_lldb(config: &Config, line: &str) -> bool {
if config.mode != common::DebugInfoLldb {
return false;
}
if parse_name_directive(line, "ignore-lldb") {
return true;
}
match config.lldb_version {
Some(ref actual_version) => {
if line.contains("min-lldb-version") {
let min_version = line.trim()
.split(' ')
.last()
.expect("Malformed lldb version directive");
// Ignore if actual version is smaller the minimum required
// version
lldb_version_to_int(actual_version.as_slice()) <
lldb_version_to_int(min_version.as_slice())
} else {
false
}
}
None => false
}
}
let val = iter_header(testfile, |ln| {
!parse_name_directive(ln, "ignore-test") &&
!parse_name_directive(ln, ignore_target(config).as_slice()) &&
@ -188,7 +216,7 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
!(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) &&
!(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) &&
!ignore_gdb(config, ln) &&
!(config.mode == common::DebugInfoLldb && parse_name_directive(ln, "ignore-lldb"))
!ignore_lldb(config, ln)
});
!val
@ -330,3 +358,12 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
return major * 1000 + minor;
}
pub fn lldb_version_to_int(version_string: &str) -> int {
let error_string = format!(
"Encountered LLDB version string with unexpected format: {}",
version_string);
let error_string = error_string.as_slice();
let major: int = FromStr::from_str(version_string).expect(error_string);
return major;
}

View File

@ -626,6 +626,17 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
let exe_file = make_exe_name(config, testfile);
match config.lldb_version {
Some(ref version) => {
println!("NOTE: compiletest thinks it is using LLDB version {}",
version.as_slice());
}
_ => {
println!("NOTE: compiletest does not know which version of \
LLDB it is using");
}
}
// Parse debugger commands etc from test files
let DebuggerCommands {
commands,