Skip to content

Commit 4fe1e2b

Browse files
committed
Auto merge of #129218 - saethlin:gdb-supports-rust-now, r=jieyouxu
Delete debuginfo test suite infra for gdb without Rust support and lldb with Rust support Implements #128953 I also deleted all the `min-lldb-version: 310` comments, because the oldest compatible distro I can find is Ubuntu 16.04 which ships lldb 3.8, though of course the package that the Ubuntu maintainers put together for that is broken. Rocky Linux 8 amusingly ships lldb 17, even though it has a similar glibc and kernel version. This PR is multiple highly mechanical changes. Some of the commits were created by just running `sed`. You may find it easier to review each commit separately.
2 parents 45fbf41 + b2dae98 commit 4fe1e2b

File tree

125 files changed

+1210
-2567
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

125 files changed

+1210
-2567
lines changed

src/tools/compiletest/src/command-list.rs

-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
145145
"needs-relocation-model-pic",
146146
"needs-run-enabled",
147147
"needs-rust-lld",
148-
"needs-rust-lldb",
149148
"needs-sanitizer-address",
150149
"needs-sanitizer-cfi",
151150
"needs-sanitizer-dataflow",

src/tools/compiletest/src/common.rs

-6
Original file line numberDiff line numberDiff line change
@@ -296,15 +296,9 @@ pub struct Config {
296296
/// Version of GDB, encoded as ((major * 1000) + minor) * 1000 + patch
297297
pub gdb_version: Option<u32>,
298298

299-
/// Whether GDB has native rust support
300-
pub gdb_native_rust: bool,
301-
302299
/// Version of LLDB
303300
pub lldb_version: Option<u32>,
304301

305-
/// Whether LLDB has native rust support
306-
pub lldb_native_rust: bool,
307-
308302
/// Version of LLVM
309303
pub llvm_version: Option<u32>,
310304

src/tools/compiletest/src/header/needs.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::common::{Config, Debugger, Sanitizer};
1+
use crate::common::{Config, Sanitizer};
22
use crate::header::IgnoreDecision;
33

44
pub(super) fn handle_needs(
@@ -114,11 +114,6 @@ pub(super) fn handle_needs(
114114
condition: cache.rust_lld,
115115
ignore_reason: "ignored on targets without Rust's LLD",
116116
},
117-
Need {
118-
name: "needs-rust-lldb",
119-
condition: config.debugger != Some(Debugger::Lldb) || config.lldb_native_rust,
120-
ignore_reason: "ignored on targets without Rust's LLDB",
121-
},
122117
Need {
123118
name: "needs-dlltool",
124119
condition: cache.dlltool,

src/tools/compiletest/src/lib.rs

+11-25
Original file line numberDiff line numberDiff line change
@@ -194,14 +194,8 @@ pub fn parse_config(args: Vec<String>) -> Config {
194194
let target = opt_str2(matches.opt_str("target"));
195195
let android_cross_path = opt_path(matches, "android-cross-path");
196196
let (cdb, cdb_version) = analyze_cdb(matches.opt_str("cdb"), &target);
197-
let (gdb, gdb_version, gdb_native_rust) =
198-
analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
199-
let (lldb_version, lldb_native_rust) = matches
200-
.opt_str("lldb-version")
201-
.as_deref()
202-
.and_then(extract_lldb_version)
203-
.map(|(v, b)| (Some(v), b))
204-
.unwrap_or((None, false));
197+
let (gdb, gdb_version) = analyze_gdb(matches.opt_str("gdb"), &target, &android_cross_path);
198+
let lldb_version = matches.opt_str("lldb-version").as_deref().and_then(extract_lldb_version);
205199
let color = match matches.opt_str("color").as_deref() {
206200
Some("auto") | None => ColorConfig::AutoColor,
207201
Some("always") => ColorConfig::AlwaysColor,
@@ -298,9 +292,7 @@ pub fn parse_config(args: Vec<String>) -> Config {
298292
cdb_version,
299293
gdb,
300294
gdb_version,
301-
gdb_native_rust,
302295
lldb_version,
303-
lldb_native_rust,
304296
llvm_version,
305297
system_llvm: matches.opt_present("system-llvm"),
306298
android_cross_path,
@@ -1035,19 +1027,17 @@ fn extract_cdb_version(full_version_line: &str) -> Option<[u16; 4]> {
10351027
Some([major, minor, patch, build])
10361028
}
10371029

1038-
/// Returns (Path to GDB, GDB Version, GDB has Rust Support)
1030+
/// Returns (Path to GDB, GDB Version)
10391031
fn analyze_gdb(
10401032
gdb: Option<String>,
10411033
target: &str,
10421034
android_cross_path: &PathBuf,
1043-
) -> (Option<String>, Option<u32>, bool) {
1035+
) -> (Option<String>, Option<u32>) {
10441036
#[cfg(not(windows))]
10451037
const GDB_FALLBACK: &str = "gdb";
10461038
#[cfg(windows)]
10471039
const GDB_FALLBACK: &str = "gdb.exe";
10481040

1049-
const MIN_GDB_WITH_RUST: u32 = 7011010;
1050-
10511041
let fallback_gdb = || {
10521042
if is_android_gdb_target(target) {
10531043
let mut gdb_path = match android_cross_path.to_str() {
@@ -1076,12 +1066,10 @@ fn analyze_gdb(
10761066

10771067
let version = match version_line {
10781068
Some(line) => extract_gdb_version(&line),
1079-
None => return (None, None, false),
1069+
None => return (None, None),
10801070
};
10811071

1082-
let gdb_native_rust = version.map_or(false, |v| v >= MIN_GDB_WITH_RUST);
1083-
1084-
(Some(gdb), version, gdb_native_rust)
1072+
(Some(gdb), version)
10851073
}
10861074

10871075
fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
@@ -1131,8 +1119,8 @@ fn extract_gdb_version(full_version_line: &str) -> Option<u32> {
11311119
Some(((major * 1000) + minor) * 1000 + patch)
11321120
}
11331121

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

11561142
let full_version_line = full_version_line.trim();
11571143

@@ -1160,12 +1146,12 @@ fn extract_lldb_version(full_version_line: &str) -> Option<(u32, bool)> {
11601146
{
11611147
if let Some(idx) = apple_ver.find(not_a_digit) {
11621148
let version: u32 = apple_ver[..idx].parse().unwrap();
1163-
return Some((version, full_version_line.contains("rust-enabled")));
1149+
return Some(version);
11641150
}
11651151
} else if let Some(lldb_ver) = full_version_line.strip_prefix("lldb version ") {
11661152
if let Some(idx) = lldb_ver.find(not_a_digit) {
11671153
let version: u32 = lldb_ver[..idx].parse().ok()?;
1168-
return Some((version * 100, full_version_line.contains("rust-enabled")));
1154+
return Some(version * 100);
11691155
}
11701156
}
11711157
None

src/tools/compiletest/src/runtest.rs

+3-27
Original file line numberDiff line numberDiff line change
@@ -856,22 +856,10 @@ impl<'test> TestCx<'test> {
856856
}
857857

858858
fn run_debuginfo_gdb_test_no_opt(&self) {
859-
let prefixes = if self.config.gdb_native_rust {
860-
// GDB with Rust
861-
static PREFIXES: &[&str] = &["gdb", "gdbr"];
862-
println!("NOTE: compiletest thinks it is using GDB with native rust support");
863-
PREFIXES
864-
} else {
865-
// Generic GDB
866-
static PREFIXES: &[&str] = &["gdb", "gdbg"];
867-
println!("NOTE: compiletest thinks it is using GDB without native rust support");
868-
PREFIXES
869-
};
870-
871859
let dbg_cmds = DebuggerCommands::parse_from(
872860
&self.testpaths.file,
873861
self.config,
874-
prefixes,
862+
&["gdb"],
875863
self.revision,
876864
)
877865
.unwrap_or_else(|e| self.fatal(&e));
@@ -1053,9 +1041,7 @@ impl<'test> TestCx<'test> {
10531041
.push_str(&format!("file {}\n", exe_file.to_str().unwrap().replace(r"\", r"\\")));
10541042

10551043
// Force GDB to print values in the Rust format.
1056-
if self.config.gdb_native_rust {
1057-
script_str.push_str("set language rust\n");
1058-
}
1044+
script_str.push_str("set language rust\n");
10591045

10601046
// Add line breakpoints
10611047
for line in &dbg_cmds.breakpoint_lines {
@@ -1140,21 +1126,11 @@ impl<'test> TestCx<'test> {
11401126
}
11411127
}
11421128

1143-
let prefixes = if self.config.lldb_native_rust {
1144-
static PREFIXES: &[&str] = &["lldb", "lldbr"];
1145-
println!("NOTE: compiletest thinks it is using LLDB with native rust support");
1146-
PREFIXES
1147-
} else {
1148-
static PREFIXES: &[&str] = &["lldb", "lldbg"];
1149-
println!("NOTE: compiletest thinks it is using LLDB without native rust support");
1150-
PREFIXES
1151-
};
1152-
11531129
// Parse debugger commands etc from test files
11541130
let dbg_cmds = DebuggerCommands::parse_from(
11551131
&self.testpaths.file,
11561132
self.config,
1157-
prefixes,
1133+
&["lldb"],
11581134
self.revision,
11591135
)
11601136
.unwrap_or_else(|e| self.fatal(&e));

src/tools/compiletest/src/tests.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ fn test_extract_gdb_version() {
4848
#[test]
4949
fn test_extract_lldb_version() {
5050
// Apple variants
51-
assert_eq!(extract_lldb_version("LLDB-179.5"), Some((179, false)));
52-
assert_eq!(extract_lldb_version("lldb-300.2.51"), Some((300, false)));
51+
assert_eq!(extract_lldb_version("LLDB-179.5"), Some(179));
52+
assert_eq!(extract_lldb_version("lldb-300.2.51"), Some(300));
5353

5454
// Upstream versions
55-
assert_eq!(extract_lldb_version("lldb version 6.0.1"), Some((600, false)));
56-
assert_eq!(extract_lldb_version("lldb version 9.0.0"), Some((900, false)));
55+
assert_eq!(extract_lldb_version("lldb version 6.0.1"), Some(600));
56+
assert_eq!(extract_lldb_version("lldb version 9.0.0"), Some(900));
5757
}
5858

5959
#[test]

tests/debuginfo/associated-types.rs

+11-26
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
// Some versions of the non-rust-enabled LLDB print the wrong generic
2-
// parameter type names in this test.
3-
//@ needs-rust-lldb
4-
51
//@ compile-flags:-g
62

73
// === GDB TESTS ===================================================================================
84
// gdb-command:run
95

106
// gdb-command:print arg
11-
// gdbg-check:$1 = {b = -1, b1 = 0}
12-
// gdbr-check:$1 = associated_types::Struct<i32> {b: -1, b1: 0}
7+
// gdb-check:$1 = associated_types::Struct<i32> {b: -1, b1: 0}
138
// gdb-command:continue
149

1510
// gdb-command:print inferred
@@ -23,8 +18,7 @@
2318
// gdb-command:continue
2419

2520
// gdb-command:print arg
26-
// gdbg-check:$5 = {__0 = 4, __1 = 5}
27-
// gdbr-check:$5 = (4, 5)
21+
// gdb-check:$5 = (4, 5)
2822
// gdb-command:continue
2923

3024
// gdb-command:print a
@@ -43,42 +37,33 @@
4337
// lldb-command:run
4438

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

5043
// lldb-command:v inferred
51-
// lldbg-check:[...] 1
52-
// lldbr-check:(i64) inferred = 1
44+
// lldb-check:[...] 1
5345
// lldb-command:v explicitly
54-
// lldbg-check:[...] 1
55-
// lldbr-check:(i64) explicitly = 1
46+
// lldb-check:[...] 1
5647
// lldb-command:continue
5748

5849
// lldb-command:v arg
59-
// lldbg-check:[...] 2
60-
// lldbr-check:(i64) arg = 2
50+
// lldb-check:[...] 2
6151
// lldb-command:continue
6252

6353
// lldb-command:v arg
64-
// lldbg-check:[...] (4, 5)
65-
// lldbr-check:((i32, i64)) arg = { = 4 = 5 }
54+
// lldb-check:[...] { 0 = 4 1 = 5 }
6655
// lldb-command:continue
6756

6857
// lldb-command:v a
69-
// lldbg-check:[...] 6
70-
// lldbr-check:(i32) a = 6
58+
// lldb-check:[...] 6
7159
// lldb-command:v b
72-
// lldbg-check:[...] 7
73-
// lldbr-check:(i64) b = 7
60+
// lldb-check:[...] 7
7461
// lldb-command:continue
7562

7663
// lldb-command:v a
77-
// lldbg-check:[...] 8
78-
// lldbr-check:(i64) a = 8
64+
// lldb-check:[...] 8
7965
// lldb-command:v b
80-
// lldbg-check:[...] 9
81-
// lldbr-check:(i32) b = 9
66+
// lldb-check:[...] 9
8267
// lldb-command:continue
8368

8469
#![allow(unused_variables)]

tests/debuginfo/basic-types-globals-metadata.rs

+16-32
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,35 @@
1-
//@ min-lldb-version: 310
2-
31
//@ compile-flags:-g
2+
43
// gdb-command:run
5-
// gdbg-command:whatis 'basic_types_globals_metadata::B'
6-
// gdbr-command:whatis basic_types_globals_metadata::B
4+
// gdb-command:whatis basic_types_globals_metadata::B
75
// gdb-check:type = bool
8-
// gdbg-command:whatis 'basic_types_globals_metadata::I'
9-
// gdbr-command:whatis basic_types_globals_metadata::I
6+
// gdb-command:whatis basic_types_globals_metadata::I
107
// gdb-check:type = isize
11-
// gdbg-command:whatis 'basic_types_globals_metadata::C'
12-
// gdbr-command:whatis basic_types_globals_metadata::C
8+
// gdb-command:whatis basic_types_globals_metadata::C
139
// gdb-check:type = char
14-
// gdbg-command:whatis 'basic_types_globals_metadata::I8'
15-
// gdbr-command:whatis basic_types_globals_metadata::I8
10+
// gdb-command:whatis basic_types_globals_metadata::I8
1611
// gdb-check:type = i8
17-
// gdbg-command:whatis 'basic_types_globals_metadata::I16'
18-
// gdbr-command:whatis basic_types_globals_metadata::I16
12+
// gdb-command:whatis basic_types_globals_metadata::I16
1913
// gdb-check:type = i16
20-
// gdbg-command:whatis 'basic_types_globals_metadata::I32'
21-
// gdbr-command:whatis basic_types_globals_metadata::I32
14+
// gdb-command:whatis basic_types_globals_metadata::I32
2215
// gdb-check:type = i32
23-
// gdbg-command:whatis 'basic_types_globals_metadata::I64'
24-
// gdbr-command:whatis basic_types_globals_metadata::I64
16+
// gdb-command:whatis basic_types_globals_metadata::I64
2517
// gdb-check:type = i64
26-
// gdbg-command:whatis 'basic_types_globals_metadata::U'
27-
// gdbr-command:whatis basic_types_globals_metadata::U
18+
// gdb-command:whatis basic_types_globals_metadata::U
2819
// gdb-check:type = usize
29-
// gdbg-command:whatis 'basic_types_globals_metadata::U8'
30-
// gdbr-command:whatis basic_types_globals_metadata::U8
20+
// gdb-command:whatis basic_types_globals_metadata::U8
3121
// gdb-check:type = u8
32-
// gdbg-command:whatis 'basic_types_globals_metadata::U16'
33-
// gdbr-command:whatis basic_types_globals_metadata::U16
22+
// gdb-command:whatis basic_types_globals_metadata::U16
3423
// gdb-check:type = u16
35-
// gdbg-command:whatis 'basic_types_globals_metadata::U32'
36-
// gdbr-command:whatis basic_types_globals_metadata::U32
24+
// gdb-command:whatis basic_types_globals_metadata::U32
3725
// gdb-check:type = u32
38-
// gdbg-command:whatis 'basic_types_globals_metadata::U64'
39-
// gdbr-command:whatis basic_types_globals_metadata::U64
26+
// gdb-command:whatis basic_types_globals_metadata::U64
4027
// gdb-check:type = u64
41-
// gdbg-command:whatis 'basic_types_globals_metadata::F16'
42-
// gdbr-command:whatis basic_types_globals_metadata::F16
28+
// gdb-command:whatis basic_types_globals_metadata::F16
4329
// gdb-check:type = f16
44-
// gdbg-command:whatis 'basic_types_globals_metadata::F32'
45-
// gdbr-command:whatis basic_types_globals_metadata::F32
30+
// gdb-command:whatis basic_types_globals_metadata::F32
4631
// gdb-check:type = f32
47-
// gdbg-command:whatis 'basic_types_globals_metadata::F64'
48-
// gdbr-command:whatis basic_types_globals_metadata::F64
32+
// gdb-command:whatis basic_types_globals_metadata::F64
4933
// gdb-check:type = f64
5034
// gdb-command:continue
5135

0 commit comments

Comments
 (0)