Skip to content

Commit 895aac9

Browse files
debuginfo: Add LLDB version handling to test infrastructure.
1 parent 593174b commit 895aac9

File tree

6 files changed

+95
-3
lines changed

6 files changed

+95
-3
lines changed

configure

+5-1
Original file line numberDiff line numberDiff line change
@@ -535,13 +535,17 @@ probe CFG_LLDB lldb
535535

536536
if [ ! -z "$CFG_GDB" ]
537537
then
538-
# Extract the version
538+
# Store GDB's version
539539
CFG_GDB_VERSION=$($CFG_GDB --version 2>/dev/null | head -1)
540540
putvar CFG_GDB_VERSION
541541
fi
542542

543543
if [ ! -z "$CFG_LLDB" ]
544544
then
545+
# Store LLDB's version
546+
CFG_LLDB_VERSION=$($CFG_LLDB --version 2>/dev/null | head -1)
547+
putvar CFG_LLDB_VERSION
548+
545549
# If CFG_LLDB_PYTHON_DIR is not already set from the outside and valid, try to read it from
546550
# LLDB via the -P commandline options.
547551
if [ -z "$CFG_LLDB_PYTHON_DIR" ] || [ ! -d "$CFG_LLDB_PYTHON_DIR" ]

mk/tests.mk

+1
Original file line numberDiff line numberDiff line change
@@ -625,6 +625,7 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
625625
--target $(2) \
626626
--host $(3) \
627627
--gdb-version="$(CFG_GDB_VERSION)" \
628+
--lldb-version="$(CFG_LLDB_VERSION)" \
628629
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
629630
--adb-path=$(CFG_ADB) \
630631
--adb-test-dir=$(CFG_ADB_TEST_DIR) \

src/compiletest/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,9 @@ pub struct Config {
133133
// Version of GDB
134134
pub gdb_version: Option<String>,
135135

136+
// Version of LLDB
137+
pub lldb_version: Option<String>,
138+
136139
// Path to the android tools
137140
pub android_cross_path: Path,
138141

src/compiletest/compiletest.rs

+37-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ pub fn parse_config(args: Vec<String> ) -> Config {
7171
optflag("", "jit", "run tests under the JIT"),
7272
optopt("", "target", "the target to build for", "TARGET"),
7373
optopt("", "host", "the host to build for", "HOST"),
74-
optopt("", "gdb-version", "the version of GDB used", "MAJOR.MINOR"),
74+
optopt("", "gdb-version", "the version of GDB used", "VERSION STRING"),
75+
optopt("", "lldb-version", "the version of LLDB used", "VERSION STRING"),
7576
optopt("", "android-cross-path", "Android NDK standalone path", "PATH"),
7677
optopt("", "adb-path", "path to the android debugger", "PATH"),
7778
optopt("", "adb-test-dir", "path to tests for the android debugger", "PATH"),
@@ -149,6 +150,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
149150
target: opt_str2(matches.opt_str("target")),
150151
host: opt_str2(matches.opt_str("host")),
151152
gdb_version: extract_gdb_version(matches.opt_str("gdb-version")),
153+
lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
152154
android_cross_path: opt_path(matches, "android-cross-path"),
153155
adb_path: opt_str2(matches.opt_str("adb-path")),
154156
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> {
391393
_ => None
392394
}
393395
}
396+
397+
fn extract_lldb_version(full_version_line: Option<String>) -> Option<String> {
398+
// Extract the major LLDB version from the given version string.
399+
// LLDB version strings are different for Apple and non-Apple platforms.
400+
// At the moment, this function only supports the Apple variant, which looks
401+
// like this:
402+
//
403+
// LLDB-179.5 (older versions)
404+
// lldb-300.2.51 (new versions)
405+
//
406+
// We are only interested in the major version number, so this function
407+
// will return `Some("179")` and `Some("300")` respectively.
408+
409+
match full_version_line {
410+
Some(ref full_version_line)
411+
if full_version_line.as_slice().trim().len() > 0 => {
412+
let full_version_line = full_version_line.as_slice().trim();
413+
414+
let re = Regex::new(r"[Ll][Ll][Dd][Bb]-([0-9]+)").unwrap();
415+
416+
match re.captures(full_version_line) {
417+
Some(captures) => {
418+
Some(captures.at(1).to_string())
419+
}
420+
None => {
421+
println!("Could not extract LLDB version from line '{}'",
422+
full_version_line);
423+
None
424+
}
425+
}
426+
},
427+
_ => None
428+
}
429+
}

src/compiletest/header.rs

+38-1
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,42 @@ pub fn is_test_ignored(config: &Config, testfile: &Path) -> bool {
181181
}
182182
}
183183

184+
fn ignore_lldb(config: &Config, line: &str) -> bool {
185+
if config.mode != common::DebugInfoLldb {
186+
return false;
187+
}
188+
189+
if parse_name_directive(line, "ignore-lldb") {
190+
return true;
191+
}
192+
193+
match config.lldb_version {
194+
Some(ref actual_version) => {
195+
if line.contains("min-lldb-version") {
196+
let min_version = line.trim()
197+
.split(' ')
198+
.last()
199+
.expect("Malformed lldb version directive");
200+
// Ignore if actual version is smaller the minimum required
201+
// version
202+
lldb_version_to_int(actual_version.as_slice()) <
203+
lldb_version_to_int(min_version.as_slice())
204+
} else {
205+
false
206+
}
207+
}
208+
None => false
209+
}
210+
}
211+
184212
let val = iter_header(testfile, |ln| {
185213
!parse_name_directive(ln, "ignore-test") &&
186214
!parse_name_directive(ln, ignore_target(config).as_slice()) &&
187215
!parse_name_directive(ln, ignore_stage(config).as_slice()) &&
188216
!(config.mode == common::Pretty && parse_name_directive(ln, "ignore-pretty")) &&
189217
!(config.target != config.host && parse_name_directive(ln, "ignore-cross-compile")) &&
190218
!ignore_gdb(config, ln) &&
191-
!(config.mode == common::DebugInfoLldb && parse_name_directive(ln, "ignore-lldb"))
219+
!ignore_lldb(config, ln)
192220
});
193221

194222
!val
@@ -330,3 +358,12 @@ pub fn gdb_version_to_int(version_string: &str) -> int {
330358

331359
return major * 1000 + minor;
332360
}
361+
362+
pub fn lldb_version_to_int(version_string: &str) -> int {
363+
let error_string = format!(
364+
"Encountered LLDB version string with unexpected format: {}",
365+
version_string);
366+
let error_string = error_string.as_slice();
367+
let major: int = FromStr::from_str(version_string).expect(error_string);
368+
return major;
369+
}

src/compiletest/runtest.rs

+11
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,17 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
626626

627627
let exe_file = make_exe_name(config, testfile);
628628

629+
match config.lldb_version {
630+
Some(ref version) => {
631+
println!("NOTE: compiletest thinks it is using LLDB version {}",
632+
version.as_slice());
633+
}
634+
_ => {
635+
println!("NOTE: compiletest does not know which version of \
636+
LLDB it is using");
637+
}
638+
}
639+
629640
// Parse debugger commands etc from test files
630641
let DebuggerCommands {
631642
commands,

0 commit comments

Comments
 (0)