Skip to content
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

Delete debuginfo test suite infra for gdb without Rust support and lldb with Rust support #129218

Merged
merged 11 commits into from
Aug 19, 2024
1 change: 0 additions & 1 deletion src/tools/compiletest/src/command-list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"needs-relocation-model-pic",
"needs-run-enabled",
"needs-rust-lld",
"needs-rust-lldb",
"needs-sanitizer-address",
"needs-sanitizer-cfi",
"needs-sanitizer-dataflow",
Expand Down
6 changes: 0 additions & 6 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,9 @@ pub struct Config {
/// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
pub gdb_version: Option<u32>,

/// Whether GDB has native rust support
pub gdb_native_rust: bool,

/// Version of LLDB
pub lldb_version: Option<u32>,

/// Whether LLDB has native rust support
pub lldb_native_rust: bool,

/// Version of LLVM
pub llvm_version: Option<u32>,

Expand Down
7 changes: 1 addition & 6 deletions src/tools/compiletest/src/header/needs.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::common::{Config, Debugger, Sanitizer};
use crate::common::{Config, Sanitizer};
use crate::header::IgnoreDecision;

pub(super) fn handle_needs(
Expand Down Expand Up @@ -114,11 +114,6 @@ pub(super) fn handle_needs(
condition: cache.rust_lld,
ignore_reason: "ignored on targets without Rust's LLD",
},
Need {
name: "needs-rust-lldb",
condition: config.debugger != Some(Debugger::Lldb) || config.lldb_native_rust,
ignore_reason: "ignored on targets without Rust's LLDB",
},
Need {
name: "needs-dlltool",
condition: cache.dlltool,
Expand Down
36 changes: 11 additions & 25 deletions src/tools/compiletest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,14 +194,8 @@ 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, cdb_version) = 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) = matches
.opt_str("lldb-version")
.as_deref()
.and_then(extract_lldb_version)
.map(|(v, b)| (Some(v), b))
.unwrap_or((None, false));
let (gdb, gdb_version) = analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
let lldb_version = matches.opt_str("lldb-version").as_deref().and_then(extract_lldb_version);
let color = match matches.opt_str("color").as_deref() {
Some("auto") | None => ColorConfig::AutoColor,
Some("always") => ColorConfig::AlwaysColor,
Expand Down Expand Up @@ -298,9 +292,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
cdb_version,
gdb,
gdb_version,
gdb_native_rust,
lldb_version,
lldb_native_rust,
llvm_version,
system_llvm: matches.opt_present("system-llvm"),
android_cross_path,
Expand Down Expand Up @@ -1035,19 +1027,17 @@ fn extract_cdb_version(full_version_line: &str) -> Option<[u16; 4]> {
Some([major, minor, patch, build])
}

/// Returns (Path to GDB, GDB Version, GDB has Rust Support)
/// Returns (Path to GDB, GDB Version)
fn analyze_gdb(
gdb: Option<String>,
target: &str,
android_cross_path: &PathBuf,
) -> (Option<String>, Option<u32>, bool) {
) -> (Option<String>, Option<u32>) {
#[cfg(not(windows))]
const GDB_FALLBACK: &str = "gdb";
#[cfg(windows)]
const GDB_FALLBACK: &str = "gdb.exe";

const MIN_GDB_WITH_RUST: u32 = 7011010;

let fallback_gdb = || {
if is_android_gdb_target(target) {
let mut gdb_path = match android_cross_path.to_str() {
Expand Down Expand Up @@ -1076,12 +1066,10 @@ fn analyze_gdb(

let version = match version_line {
Some(line) => extract_gdb_version(&line),
None => return (None, None, false),
None => return (None, None),
};

let gdb_native_rust = version.map_or(false, |v| v >= MIN_GDB_WITH_RUST);

(Some(gdb), version, gdb_native_rust)
(Some(gdb), version)
}

fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
Expand Down Expand Up @@ -1131,8 +1119,8 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
Some(((major * 1000) + minor) * 1000 + patch)
}

/// Returns (LLDB version, LLDB is rust-enabled)
fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
/// Returns LLDB version
fn extract_lldb_version(full_version_line: &str) -> Option<u32> {
// Extract the major LLDB version from the given version string.
// LLDB version strings are different for Apple and non-Apple platforms.
// The Apple variant looks like this:
Expand All @@ -1149,9 +1137,7 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
// There doesn't seem to be a way to correlate the Apple version
// with the upstream version, and since the tests were originally
// written against Apple versions, we make a fake Apple version by
// multiplying the first number by 100. This is a hack, but
// normally fine because the only non-Apple version we test is
// rust-enabled.
// multiplying the first number by 100. This is a hack.

let full_version_line = full_version_line.trim();

Expand All @@ -1160,12 +1146,12 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
{
if let Some(idx) = apple_ver.find(not_a_digit) {
let version: u32 = apple_ver[..idx].parse().unwrap();
return Some((version, full_version_line.contains("rust-enabled")));
return Some(version);
}
} else if let Some(lldb_ver) = full_version_line.strip_prefix("lldb version ") {
if let Some(idx) = lldb_ver.find(not_a_digit) {
let version: u32 = lldb_ver[..idx].parse().ok()?;
return Some((version * 100, full_version_line.contains("rust-enabled")));
return Some(version * 100);
}
}
None
Expand Down
30 changes: 3 additions & 27 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,22 +856,10 @@ impl<'test> TestCx<'test> {
}

fn run_debuginfo_gdb_test_no_opt(&self) {
let prefixes = if self.config.gdb_native_rust {
// GDB with Rust
static PREFIXES: &[&str] = &["gdb", "gdbr"];
println!("NOTE: compiletest thinks it is using GDB with native rust support");
PREFIXES
} else {
// Generic GDB
static PREFIXES: &[&str] = &["gdb", "gdbg"];
println!("NOTE: compiletest thinks it is using GDB without native rust support");
PREFIXES
};

let dbg_cmds = DebuggerCommands::parse_from(
&self.testpaths.file,
self.config,
prefixes,
&["gdb"],
self.revision,
)
.unwrap_or_else(|e| self.fatal(&e));
Expand Down Expand Up @@ -1053,9 +1041,7 @@ impl<'test> TestCx<'test> {
.push_str(&format!("file {}\n", exe_file.to_str().unwrap().replace(r"\", r"\\")));

// Force GDB to print values in the Rust format.
if self.config.gdb_native_rust {
script_str.push_str("set language rust\n");
}
script_str.push_str("set language rust\n");

// Add line breakpoints
for line in &dbg_cmds.breakpoint_lines {
Expand Down Expand Up @@ -1140,21 +1126,11 @@ impl<'test> TestCx<'test> {
}
}

let prefixes = if self.config.lldb_native_rust {
static PREFIXES: &[&str] = &["lldb", "lldbr"];
println!("NOTE: compiletest thinks it is using LLDB with native rust support");
PREFIXES
} else {
static PREFIXES: &[&str] = &["lldb", "lldbg"];
println!("NOTE: compiletest thinks it is using LLDB without native rust support");
PREFIXES
};

// Parse debugger commands etc from test files
let dbg_cmds = DebuggerCommands::parse_from(
&self.testpaths.file,
self.config,
prefixes,
&["lldb"],
self.revision,
)
.unwrap_or_else(|e| self.fatal(&e));
Expand Down
8 changes: 4 additions & 4 deletions src/tools/compiletest/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ fn test_extract_gdb_version() {
#[test]
fn test_extract_lldb_version() {
// Apple variants
assert_eq!(extract_lldb_version("LLDB-179.5"), Some((179, false)));
assert_eq!(extract_lldb_version("lldb-300.2.51"), Some((300, false)));
assert_eq!(extract_lldb_version("LLDB-179.5"), Some(179));
assert_eq!(extract_lldb_version("lldb-300.2.51"), Some(300));

// Upstream versions
assert_eq!(extract_lldb_version("lldb version 6.0.1"), Some((600, false)));
assert_eq!(extract_lldb_version("lldb version 9.0.0"), Some((900, false)));
assert_eq!(extract_lldb_version("lldb version 6.0.1"), Some(600));
assert_eq!(extract_lldb_version("lldb version 9.0.0"), Some(900));
}

#[test]
Expand Down
37 changes: 11 additions & 26 deletions tests/debuginfo/associated-types.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
// Some versions of the non-rust-enabled LLDB print the wrong generic
// parameter type names in this test.
//@ needs-rust-lldb

//@ compile-flags:-g

// === GDB TESTS ===================================================================================
// gdb-command:run

// gdb-command:print arg
// gdbg-check:$1 = {b = -1, b1 = 0}
// gdbr-check:$1 = associated_types::Struct<i32> {b: -1, b1: 0}
// gdb-check:$1 = associated_types::Struct<i32> {b: -1, b1: 0}
// gdb-command:continue

// gdb-command:print inferred
Expand All @@ -23,8 +18,7 @@
// gdb-command:continue

// gdb-command:print arg
// gdbg-check:$5 = {__0 = 4, __1 = 5}
// gdbr-check:$5 = (4, 5)
// gdb-check:$5 = (4, 5)
// gdb-command:continue

// gdb-command:print a
Expand All @@ -43,42 +37,33 @@
// lldb-command:run

// lldb-command:v arg
// lldbg-check:[...] { b = -1, b1 = 0 }
// lldbr-check:(associated_types::Struct<i32>) arg = { b = -1, b1 = 0 }
// lldb-check:[...] { b = -1 b1 = 0 }
// lldb-command:continue

// lldb-command:v inferred
// lldbg-check:[...] 1
// lldbr-check:(i64) inferred = 1
// lldb-check:[...] 1
// lldb-command:v explicitly
// lldbg-check:[...] 1
// lldbr-check:(i64) explicitly = 1
// lldb-check:[...] 1
// lldb-command:continue

// lldb-command:v arg
// lldbg-check:[...] 2
// lldbr-check:(i64) arg = 2
// lldb-check:[...] 2
// lldb-command:continue

// lldb-command:v arg
// lldbg-check:[...] (4, 5)
// lldbr-check:((i32, i64)) arg = { = 4 = 5 }
// lldb-check:[...] { 0 = 4 1 = 5 }
// lldb-command:continue

// lldb-command:v a
// lldbg-check:[...] 6
// lldbr-check:(i32) a = 6
// lldb-check:[...] 6
// lldb-command:v b
// lldbg-check:[...] 7
// lldbr-check:(i64) b = 7
// lldb-check:[...] 7
// lldb-command:continue

// lldb-command:v a
// lldbg-check:[...] 8
// lldbr-check:(i64) a = 8
// lldb-check:[...] 8
// lldb-command:v b
// lldbg-check:[...] 9
// lldbr-check:(i32) b = 9
// lldb-check:[...] 9
// lldb-command:continue

#![allow(unused_variables)]
Expand Down
48 changes: 16 additions & 32 deletions tests/debuginfo/basic-types-globals-metadata.rs
Original file line number Diff line number Diff line change
@@ -1,51 +1,35 @@
//@ min-lldb-version: 310

//@ compile-flags:-g

// gdb-command:run
// gdbg-command:whatis 'basic_types_globals_metadata::B'
// gdbr-command:whatis basic_types_globals_metadata::B
// gdb-command:whatis basic_types_globals_metadata::B
// gdb-check:type = bool
// gdbg-command:whatis 'basic_types_globals_metadata::I'
// gdbr-command:whatis basic_types_globals_metadata::I
// gdb-command:whatis basic_types_globals_metadata::I
// gdb-check:type = isize
// gdbg-command:whatis 'basic_types_globals_metadata::C'
// gdbr-command:whatis basic_types_globals_metadata::C
// gdb-command:whatis basic_types_globals_metadata::C
// gdb-check:type = char
// gdbg-command:whatis 'basic_types_globals_metadata::I8'
// gdbr-command:whatis basic_types_globals_metadata::I8
// gdb-command:whatis basic_types_globals_metadata::I8
// gdb-check:type = i8
// gdbg-command:whatis 'basic_types_globals_metadata::I16'
// gdbr-command:whatis basic_types_globals_metadata::I16
// gdb-command:whatis basic_types_globals_metadata::I16
// gdb-check:type = i16
// gdbg-command:whatis 'basic_types_globals_metadata::I32'
// gdbr-command:whatis basic_types_globals_metadata::I32
// gdb-command:whatis basic_types_globals_metadata::I32
// gdb-check:type = i32
// gdbg-command:whatis 'basic_types_globals_metadata::I64'
// gdbr-command:whatis basic_types_globals_metadata::I64
// gdb-command:whatis basic_types_globals_metadata::I64
// gdb-check:type = i64
// gdbg-command:whatis 'basic_types_globals_metadata::U'
// gdbr-command:whatis basic_types_globals_metadata::U
// gdb-command:whatis basic_types_globals_metadata::U
// gdb-check:type = usize
// gdbg-command:whatis 'basic_types_globals_metadata::U8'
// gdbr-command:whatis basic_types_globals_metadata::U8
// gdb-command:whatis basic_types_globals_metadata::U8
// gdb-check:type = u8
// gdbg-command:whatis 'basic_types_globals_metadata::U16'
// gdbr-command:whatis basic_types_globals_metadata::U16
// gdb-command:whatis basic_types_globals_metadata::U16
// gdb-check:type = u16
// gdbg-command:whatis 'basic_types_globals_metadata::U32'
// gdbr-command:whatis basic_types_globals_metadata::U32
// gdb-command:whatis basic_types_globals_metadata::U32
// gdb-check:type = u32
// gdbg-command:whatis 'basic_types_globals_metadata::U64'
// gdbr-command:whatis basic_types_globals_metadata::U64
// gdb-command:whatis basic_types_globals_metadata::U64
// gdb-check:type = u64
// gdbg-command:whatis 'basic_types_globals_metadata::F16'
// gdbr-command:whatis basic_types_globals_metadata::F16
// gdb-command:whatis basic_types_globals_metadata::F16
// gdb-check:type = f16
// gdbg-command:whatis 'basic_types_globals_metadata::F32'
// gdbr-command:whatis basic_types_globals_metadata::F32
// gdb-command:whatis basic_types_globals_metadata::F32
// gdb-check:type = f32
// gdbg-command:whatis 'basic_types_globals_metadata::F64'
// gdbr-command:whatis basic_types_globals_metadata::F64
// gdb-command:whatis basic_types_globals_metadata::F64
// gdb-check:type = f64
// gdb-command:continue

Expand Down
Loading
Loading