Run an LLDB debug script against a gdbstub endpoint. Connects LLDB to `127.0.0.1: ` using the Wasm plugin, executes the given script commands, and returns LLDB's stdout.
(port: u16, script: &str)
| 126 | /// Connects LLDB to `127.0.0.1:<port>` using the Wasm plugin, |
| 127 | /// executes the given script commands, and returns LLDB's stdout. |
| 128 | fn lldb_with_gdbstub_script(port: u16, script: &str) -> Result<String> { |
| 129 | let _ = env_logger::try_init(); |
| 130 | |
| 131 | let mut cmd = Command::new(lldb_path()); |
| 132 | cmd.arg("--batch"); |
| 133 | cmd.arg("-o").arg(format!( |
| 134 | "process connect --plugin wasm connect://127.0.0.1:{port}" |
| 135 | )); |
| 136 | for line in script.lines() { |
| 137 | let line = line.trim(); |
| 138 | if !line.is_empty() { |
| 139 | cmd.arg("-o").arg(line); |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | eprintln!("Running LLDB: {cmd:?}"); |
| 144 | let output = cmd.output()?; |
| 145 | |
| 146 | let stdout = String::from_utf8(output.stdout)?; |
| 147 | let stderr = String::from_utf8(output.stderr)?; |
| 148 | eprintln!("--- LLDB stdout ---\n{stdout}"); |
| 149 | eprintln!("--- LLDB stderr ---\n{stderr}"); |
| 150 | |
| 151 | Ok(stdout) |
| 152 | } |
| 153 | |
| 154 | /// Validate output against FileCheck-style directives. |
| 155 | fn check_output(output: &str, directives: &str) -> Result<()> { |
no test coverage detected