Skip to content

Commit 1467dee

Browse files
committed
Stop using line_directive in runtest::debugger
This also removes unused support for `[rev]` in debugger commands, and makes breakpoint detection slightly more sensible.
1 parent f225713 commit 1467dee

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

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

+6-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::io::{BufRead, BufReader};
44
use std::path::{Path, PathBuf};
55

66
use crate::common::Config;
7-
use crate::header::line_directive;
87
use crate::runtest::ProcRes;
98

109
/// Representation of information to invoke a debugger and check its output
@@ -24,7 +23,6 @@ impl DebuggerCommands {
2423
file: &Path,
2524
config: &Config,
2625
debugger_prefixes: &[&str],
27-
rev: Option<&str>,
2826
) -> Result<Self, String> {
2927
let directives = debugger_prefixes
3028
.iter()
@@ -39,18 +37,17 @@ impl DebuggerCommands {
3937
for (line_no, line) in reader.lines().enumerate() {
4038
counter += 1;
4139
let line = line.map_err(|e| format!("Error while parsing debugger commands: {}", e))?;
42-
let (lnrev, line) = line_directive("//", &line).unwrap_or((None, &line));
43-
44-
// Skip any revision specific directive that doesn't match the current
45-
// revision being tested
46-
if lnrev.is_some() && lnrev != rev {
47-
continue;
48-
}
4940

41+
// Breakpoints appear on lines with actual code, typically at the end of the line.
5042
if line.contains("#break") {
5143
breakpoint_lines.push(counter);
44+
continue;
5245
}
5346

47+
let Some(line) = line.trim_start().strip_prefix("//").map(str::trim_start) else {
48+
continue;
49+
};
50+
5451
for &(ref command_directive, ref check_directive) in &directives {
5552
config
5653
.parse_name_value_directive(&line, command_directive)

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

+6-21
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,8 @@ impl TestCx<'_> {
6666
};
6767

6868
// Parse debugger commands etc from test files
69-
let dbg_cmds = DebuggerCommands::parse_from(
70-
&self.testpaths.file,
71-
self.config,
72-
prefixes,
73-
self.revision,
74-
)
75-
.unwrap_or_else(|e| self.fatal(&e));
69+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, prefixes)
70+
.unwrap_or_else(|e| self.fatal(&e));
7671

7772
// https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-commands
7873
let mut script_str = String::with_capacity(2048);
@@ -142,13 +137,8 @@ impl TestCx<'_> {
142137
}
143138

144139
fn run_debuginfo_gdb_test_no_opt(&self) {
145-
let dbg_cmds = DebuggerCommands::parse_from(
146-
&self.testpaths.file,
147-
self.config,
148-
&["gdb"],
149-
self.revision,
150-
)
151-
.unwrap_or_else(|e| self.fatal(&e));
140+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["gdb"])
141+
.unwrap_or_else(|e| self.fatal(&e));
152142
let mut cmds = dbg_cmds.commands.join("\n");
153143

154144
// compile test file (it should have 'compile-flags:-g' in the header)
@@ -413,13 +403,8 @@ impl TestCx<'_> {
413403
}
414404

415405
// Parse debugger commands etc from test files
416-
let dbg_cmds = DebuggerCommands::parse_from(
417-
&self.testpaths.file,
418-
self.config,
419-
&["lldb"],
420-
self.revision,
421-
)
422-
.unwrap_or_else(|e| self.fatal(&e));
406+
let dbg_cmds = DebuggerCommands::parse_from(&self.testpaths.file, self.config, &["lldb"])
407+
.unwrap_or_else(|e| self.fatal(&e));
423408

424409
// Write debugger script:
425410
// We don't want to hang when calling `quit` while the process is still running

0 commit comments

Comments
 (0)