| 6 | use wasmtime::{Result, bail, format_err}; |
| 7 | |
| 8 | fn gdb_with_script(args: &[&str], script: &str) -> Result<String> { |
| 9 | let lldb_path = env::var("GDB").unwrap_or("gdb".to_string()); |
| 10 | let mut cmd = Command::new(&lldb_path); |
| 11 | |
| 12 | cmd.arg("--batch"); |
| 13 | let mut script_file = NamedTempFile::new()?; |
| 14 | script_file.write(script.as_bytes())?; |
| 15 | let script_path = script_file.path().to_str().unwrap(); |
| 16 | cmd.args(&["-x", &script_path]); |
| 17 | |
| 18 | cmd.arg("--args"); |
| 19 | |
| 20 | let mut me = std::env::current_exe().expect("current_exe specified"); |
| 21 | me.pop(); // chop off the file name |
| 22 | me.pop(); // chop off `deps` |
| 23 | me.push("wasmtime"); |
| 24 | cmd.arg(me); |
| 25 | |
| 26 | cmd.args(args); |
| 27 | |
| 28 | let output = cmd.output().expect("success"); |
| 29 | if !output.status.success() { |
| 30 | bail!( |
| 31 | "failed to execute {:?}: {}", |
| 32 | cmd, |
| 33 | String::from_utf8_lossy(&output.stderr), |
| 34 | ); |
| 35 | } |
| 36 | Ok(String::from_utf8(output.stdout)?) |
| 37 | } |
| 38 | |
| 39 | fn check_gdb_output(output: &str, directives: &str) -> Result<()> { |
| 40 | let mut builder = CheckerBuilder::new(); |