MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / gdb_thread

Function gdb_thread

vmm/src/gdb.rs:509–558  ·  view source on GitHub ↗
(mut gdbstub: GdbStub, path: &std::path::Path)

Source from the content-addressed store, hash-verified

507}
508
509pub fn gdb_thread(mut gdbstub: GdbStub, path: &std::path::Path) {
510 let listener = match UnixListener::bind(path) {
511 Ok(s) => s,
512 Err(e) => {
513 error!("Failed to create a Unix domain socket listener: {e}");
514 return;
515 }
516 };
517 info!("Waiting for a GDB connection on {}...", path.display());
518
519 let (stream, addr) = match listener.accept() {
520 Ok(v) => v,
521 Err(e) => {
522 error!("Failed to accept a connection from GDB: {e}");
523 return;
524 }
525 };
526 info!("GDB connected from {addr:?}");
527
528 let connection: Box<dyn ConnectionExt<Error = std::io::Error>> = Box::new(stream);
529 let gdb = gdbstub::stub::GdbStub::new(connection);
530
531 match gdb.run_blocking::<GdbEventLoop>(&mut gdbstub) {
532 Ok(disconnect_reason) => match disconnect_reason {
533 DisconnectReason::Disconnect => {
534 info!("GDB client has disconnected. Running...");
535
536 if let Err(e) = gdbstub.vm_request(GdbRequestPayload::SetSingleStep(false), 0) {
537 error!("Failed to disable single step: {e:?}");
538 }
539
540 if let Err(e) =
541 gdbstub.vm_request(GdbRequestPayload::SetHwBreakPoint(Vec::new()), 0)
542 {
543 error!("Failed to remove breakpoints: {e:?}");
544 }
545
546 if let Err(e) = gdbstub.vm_request(GdbRequestPayload::Resume, 0) {
547 error!("Failed to resume the VM: {e:?}");
548 }
549 }
550 _ => {
551 error!("Target exited or terminated");
552 }
553 },
554 Err(e) => {
555 error!("error occurred in GDB session: {e}");
556 }
557 }
558}

Callers 1

start_vmm_threadFunction · 0.85

Calls 3

newFunction · 0.85
vm_requestMethod · 0.80
acceptMethod · 0.45

Tested by

no test coverage detected