Skip to content

Commit 6554fb0

Browse files
committed
add gdb_native_rust config to compiletest
1 parent 9253e12 commit 6554fb0

File tree

3 files changed

+36
-16
lines changed

3 files changed

+36
-16
lines changed

src/tools/compiletest/src/common.rs

+3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ pub struct Config {
149149
// Version of GDB
150150
pub gdb_version: Option<String>,
151151

152+
// Whether GDB has native rust support
153+
pub gdb_native_rust: bool,
154+
152155
// Version of LLDB
153156
pub lldb_version: Option<String>,
154157

src/tools/compiletest/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
172172
target: opt_str2(matches.opt_str("target")),
173173
host: opt_str2(matches.opt_str("host")),
174174
gdb_version: extract_gdb_version(matches.opt_str("gdb-version")),
175+
gdb_native_rust: false,
175176
lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
176177
llvm_version: matches.opt_str("llvm-version"),
177178
android_cross_path: opt_path(matches, "android-cross-path"),

src/tools/compiletest/src/runtest.rs

+32-16
Original file line numberDiff line numberDiff line change
@@ -430,11 +430,23 @@ actual:\n\
430430
}
431431

432432
fn run_debuginfo_gdb_test_no_opt(&self) {
433+
let prefixes = if self.config.gdb_native_rust {
434+
// GDB with Rust
435+
static PREFIXES: &'static [&'static str] = &["gdb", "gdbr"];
436+
println!("NOTE: compiletest thinks it is using GDB with native rust support");
437+
PREFIXES
438+
} else {
439+
// Generic GDB
440+
static PREFIXES: &'static [&'static str] = &["gdb", "gdbg"];
441+
println!("NOTE: compiletest thinks it is using GDB without native rust support");
442+
PREFIXES
443+
};
444+
433445
let DebuggerCommands {
434446
commands,
435447
check_lines,
436448
breakpoint_lines
437-
} = self.parse_debugger_commands("gdb");
449+
} = self.parse_debugger_commands(prefixes);
438450
let mut cmds = commands.join("\n");
439451

440452
// compile test file (it should have 'compile-flags:-g' in the header)
@@ -731,7 +743,7 @@ actual:\n\
731743
check_lines,
732744
breakpoint_lines,
733745
..
734-
} = self.parse_debugger_commands("lldb");
746+
} = self.parse_debugger_commands(&["lldb"]);
735747

736748
// Write debugger script:
737749
// We don't want to hang when calling `quit` while the process is still running
@@ -826,9 +838,11 @@ actual:\n\
826838
}
827839
}
828840

829-
fn parse_debugger_commands(&self, debugger_prefix: &str) -> DebuggerCommands {
830-
let command_directive = format!("{}-command", debugger_prefix);
831-
let check_directive = format!("{}-check", debugger_prefix);
841+
fn parse_debugger_commands(&self, debugger_prefixes: &[&str]) -> DebuggerCommands {
842+
let directives = debugger_prefixes.iter().map(|prefix| (
843+
format!("{}-command", prefix),
844+
format!("{}-check", prefix),
845+
)).collect::<Vec<_>>();
832846

833847
let mut breakpoint_lines = vec!();
834848
let mut commands = vec!();
@@ -842,17 +856,19 @@ actual:\n\
842856
breakpoint_lines.push(counter);
843857
}
844858

845-
header::parse_name_value_directive(
846-
&line,
847-
&command_directive).map(|cmd| {
848-
commands.push(cmd)
849-
});
850-
851-
header::parse_name_value_directive(
852-
&line,
853-
&check_directive).map(|cmd| {
854-
check_lines.push(cmd)
855-
});
859+
for &(ref command_directive, ref check_directive) in &directives {
860+
header::parse_name_value_directive(
861+
&line,
862+
&command_directive).map(|cmd| {
863+
commands.push(cmd)
864+
});
865+
866+
header::parse_name_value_directive(
867+
&line,
868+
&check_directive).map(|cmd| {
869+
check_lines.push(cmd)
870+
});
871+
}
856872
}
857873
Err(e) => {
858874
self.fatal(&format!("Error while parsing debugger commands: {}", e))

0 commit comments

Comments
 (0)