Skip to content

Commit b924607

Browse files
authored
Unrolled build for rust-lang#134849
Rollup merge of rust-lang#134849 - Zalathar:debuginfo-prefixes, r=lqd,clubby789,jieyouxu compiletest: Slightly simplify the handling of debugger directive prefixes The `cdbg-` prefix is not used by any tests in `tests/debuginfo`, and perhaps there never were any tests that used it. Getting rid of it also lets us get rid of the code for parsing multiple prefixes at the same time, since every debugger now has exactly one prefix.
2 parents b76036c + 2f8824a commit b924607

File tree

2 files changed

+11
-26
lines changed

2 files changed

+11
-26
lines changed

src/tools/compiletest/src/runtest/debugger.rs

+8-17
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,9 @@ pub(super) struct DebuggerCommands {
1919
}
2020

2121
impl DebuggerCommands {
22-
pub fn parse_from(
23-
file: &Path,
24-
config: &Config,
25-
debugger_prefixes: &[&str],
26-
) -> Result<Self, String> {
27-
let directives = debugger_prefixes
28-
.iter()
29-
.map(|prefix| (format!("{prefix}-command"), format!("{prefix}-check")))
30-
.collect::<Vec<_>>();
22+
pub fn parse_from(file: &Path, config: &Config, debugger_prefix: &str) -> Result<Self, String> {
23+
let command_directive = format!("{debugger_prefix}-command");
24+
let check_directive = format!("{debugger_prefix}-check");
3125

3226
let mut breakpoint_lines = vec![];
3327
let mut commands = vec![];
@@ -48,14 +42,11 @@ impl DebuggerCommands {
4842
continue;
4943
};
5044

51-
for &(ref command_directive, ref check_directive) in &directives {
52-
config
53-
.parse_name_value_directive(&line, command_directive)
54-
.map(|cmd| commands.push(cmd));
55-
56-
config
57-
.parse_name_value_directive(&line, check_directive)
58-
.map(|cmd| check_lines.push((line_no, cmd)));
45+
if let Some(command) = config.parse_name_value_directive(&line, &command_directive) {
46+
commands.push(command);
47+
}
48+
if let Some(pattern) = config.parse_name_value_directive(&line, &check_directive) {
49+
check_lines.push((line_no, pattern));
5950
}
6051
}
6152

src/tools/compiletest/src/runtest/debuginfo.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,8 @@ impl TestCx<'_> {
5959
return;
6060
}
6161

62-
let prefixes = {
63-
static PREFIXES: &[&str] = &["cdb", "cdbg"];
64-
// No "native rust support" variation for CDB yet.
65-
PREFIXES
66-
};
67-
6862
// Parse debugger commands etc from test files
69-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes)
63+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "cdb")
7064
.unwrap_or_else(|e| self.fatal(&e));
7165

7266
// https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands
@@ -137,7 +131,7 @@ impl TestCx<'_> {
137131
}
138132

139133
fn run_debuginfo_gdb_test_no_opt(&self) {
140-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["gdb"])
134+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "gdb")
141135
.unwrap_or_else(|e| self.fatal(&e));
142136
let mut cmds = dbg_cmds.commands.join("\n");
143137

@@ -403,7 +397,7 @@ impl TestCx<'_> {
403397
}
404398

405399
// Parse debugger commands etc from test files
406-
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["lldb"])
400+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, "lldb")
407401
.unwrap_or_else(|e| self.fatal(&e));
408402

409403
// Write debugger script:

0 commit comments

Comments
 (0)