()
| 323 | #[test] |
| 324 | #[ignore] |
| 325 | fn 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#" |
| 347 | rbreak Guest.*handle |
| 348 | c |
| 349 | bt |
| 350 | c |
| 351 | bt |
| 352 | c |
| 353 | bt |
| 354 | c |
| 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. |
nothing calls this directly
no test coverage detected