MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / gdb_with_script

Function gdb_with_script

tests/all/native_debug/gdb.rs:8–37  ·  view source on GitHub ↗
(args: &[&str], script: &str)

Source from the content-addressed store, hash-verified

6use wasmtime::{Result, bail, format_err};
7
8fn 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
39fn check_gdb_output(output: &str, directives: &str) -> Result<()> {
40 let mut builder = CheckerBuilder::new();

Callers 1

test_debug_dwarf_gdbFunction · 0.85

Calls 15

OkFunction · 0.85
as_bytesMethod · 0.80
to_strMethod · 0.80
outputMethod · 0.80
newFunction · 0.50
to_stringMethod · 0.45
argMethod · 0.45
writeMethod · 0.45
unwrapMethod · 0.45
pathMethod · 0.45
argsMethod · 0.45
expectMethod · 0.45

Tested by 1

test_debug_dwarf_gdbFunction · 0.68