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

Function guest_debug_serve_breakpoint

tests/all/guest_debug/mod.rs:325–398  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

323#[test]
324#[ignore]
325fn guest_debug_serve_breakpoint() -> Result<()> {
326 let gdb_port = free_port();
327
328 let mut wt = WasmtimeWithGdbstub::spawn(
329 "serve",
330 gdb_port,
331 &[
332 "-Ccache=n",
333 "--addr=127.0.0.1:0",
334 "-Scli",
335 P2_CLI_SERVE_HELLO_WORLD_COMPONENT,
336 ],
337 Duration::from_secs(30),
338 )?;
339
340 // LLDB script: set a breakpoint on the incoming-handler Guest::handle,
341 // continue to start the server, then for each request: print backtrace
342 // at breakpoint and continue. We do this for 3 requests.
343 let lldb_handle = std::thread::spawn(move || {
344 lldb_with_gdbstub_script(
345 gdb_port,
346 r#"
347rbreak Guest.*handle
348c
349bt
350c
351bt
352c
353bt
354c
355"#,
356 )
357 });
358
359 // Wait for the HTTP server to start.
360 let line = wt.wait_for_stderr("Serving HTTP", Duration::from_secs(15))?;
361 let http_addr = parse_http_addr(&line)?;
362 eprintln!("HTTP address: {http_addr}");
363
364 // Send 3 requests. Each one will hit the breakpoint, LLDB prints
365 // the backtrace, then continues to let the response through.
366 for i in 1..=3 {
367 let resp = http_request(http_addr, "/")?;
368 eprintln!("Response {i}: {}", resp.lines().last().unwrap_or(""));
369 assert!(
370 resp.contains("Hello, WASI!"),
371 "request {i}: expected 'Hello, WASI!' in response, got:\n{resp}"
372 );
373 }
374
375 // Kill wasmtime to unblock LLDB.
376 wt.child.kill().ok();
377 wt.child.wait()?;
378
379 let lldb_output = lldb_handle.join().unwrap()?;
380
381 // Verify LLDB stopped at the breakpoint with the correct function
382 // in the backtrace, and that it happened multiple times.

Callers

nothing calls this directly

Calls 12

free_portFunction · 0.85
spawnFunction · 0.85
lldb_with_gdbstub_scriptFunction · 0.85
parse_http_addrFunction · 0.85
http_requestFunction · 0.85
check_outputFunction · 0.85
OkFunction · 0.85
wait_for_stderrMethod · 0.80
okMethod · 0.45
waitMethod · 0.45
unwrapMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected