| 15 | foreach_dwarf!(assert_test_exists); |
| 16 | |
| 17 | fn lldb_with_script(args: &[&str], script: &str) -> Result<String> { |
| 18 | let _ = env_logger::try_init(); |
| 19 | |
| 20 | let lldb_path = env::var("LLDB").unwrap_or("lldb".to_string()); |
| 21 | let mut cmd = Command::new(&lldb_path); |
| 22 | |
| 23 | cmd.arg("--batch"); |
| 24 | if cfg!(target_os = "macos") { |
| 25 | cmd.args(&["-o", "settings set plugin.jit-loader.gdb.enable on"]); |
| 26 | } |
| 27 | let mut script_file = NamedTempFile::new()?; |
| 28 | script_file.write(script.as_bytes())?; |
| 29 | let script_path = script_file.path().to_str().unwrap(); |
| 30 | cmd.args(&["-s", &script_path]); |
| 31 | |
| 32 | let mut me = std::env::current_exe().expect("current_exe specified"); |
| 33 | me.pop(); // chop off the file name |
| 34 | me.pop(); // chop off `deps` |
| 35 | if cfg!(target_os = "windows") { |
| 36 | me.push("wasmtime.exe"); |
| 37 | } else { |
| 38 | me.push("wasmtime"); |
| 39 | } |
| 40 | cmd.arg(me); |
| 41 | |
| 42 | cmd.arg("--"); |
| 43 | cmd.args(args); |
| 44 | |
| 45 | log::trace!("Running command: {cmd:?}"); |
| 46 | let output = cmd.output().expect("success"); |
| 47 | |
| 48 | let stdout = String::from_utf8(output.stdout)?; |
| 49 | log::trace!("--- sdout ---\n{stdout}"); |
| 50 | |
| 51 | let stderr = String::from_utf8(output.stderr)?; |
| 52 | log::trace!("--- sderr ---\n{stderr}"); |
| 53 | |
| 54 | if !output.status.success() { |
| 55 | bail!( |
| 56 | "failed to execute {cmd:?}:\n\ |
| 57 | --- stderr ---\n\ |
| 58 | {stderr}\n\ |
| 59 | --- stdout ---\n\ |
| 60 | {stdout}", |
| 61 | ); |
| 62 | } |
| 63 | Ok(stdout) |
| 64 | } |
| 65 | |
| 66 | fn check_lldb_output(output: &str, directives: &str) -> Result<()> { |
| 67 | let mut builder = CheckerBuilder::new(); |