Skip to content

Commit

Permalink
add gdb_native_rust config to compiletest
Browse files Browse the repository at this point in the history
  • Loading branch information
TimNN committed Oct 31, 2016
1 parent 9253e12 commit 6554fb0
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/tools/compiletest/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ pub struct Config {
// Version of GDB
pub gdb_version: Option<String>,

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

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

Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
target: opt_str2(matches.opt_str("target")),
host: opt_str2(matches.opt_str("host")),
gdb_version: extract_gdb_version(matches.opt_str("gdb-version")),
gdb_native_rust: false,
lldb_version: extract_lldb_version(matches.opt_str("lldb-version")),
llvm_version: matches.opt_str("llvm-version"),
android_cross_path: opt_path(matches, "android-cross-path"),
Expand Down
48 changes: 32 additions & 16 deletions src/tools/compiletest/src/runtest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,23 @@ actual:\n\
}

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

let DebuggerCommands {
commands,
check_lines,
breakpoint_lines
} = self.parse_debugger_commands("gdb");
} = self.parse_debugger_commands(prefixes);
let mut cmds = commands.join("\n");

// compile test file (it should have 'compile-flags:-g' in the header)
Expand Down Expand Up @@ -731,7 +743,7 @@ actual:\n\
check_lines,
breakpoint_lines,
..
} = self.parse_debugger_commands("lldb");
} = self.parse_debugger_commands(&["lldb"]);

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

fn parse_debugger_commands(&self, debugger_prefix: &str) -> DebuggerCommands {
let command_directive = format!("{}-command", debugger_prefix);
let check_directive = format!("{}-check", debugger_prefix);
fn parse_debugger_commands(&self, debugger_prefixes: &[&str]) -> DebuggerCommands {
let directives = debugger_prefixes.iter().map(|prefix| (
format!("{}-command", prefix),
format!("{}-check", prefix),
)).collect::<Vec<_>>();

let mut breakpoint_lines = vec!();
let mut commands = vec!();
Expand All @@ -842,17 +856,19 @@ actual:\n\
breakpoint_lines.push(counter);
}

header::parse_name_value_directive(
&line,
&command_directive).map(|cmd| {
commands.push(cmd)
});

header::parse_name_value_directive(
&line,
&check_directive).map(|cmd| {
check_lines.push(cmd)
});
for &(ref command_directive, ref check_directive) in &directives {
header::parse_name_value_directive(
&line,
&command_directive).map(|cmd| {
commands.push(cmd)
});

header::parse_name_value_directive(
&line,
&check_directive).map(|cmd| {
check_lines.push(cmd)
});
}
}
Err(e) => {
self.fatal(&format!("Error while parsing debugger commands: {}", e))
Expand Down

0 comments on commit 6554fb0

Please sign in to comment.