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

Method wait_for_stop_reason

vmm/src/gdb.rs:451–494  ·  view source on GitHub ↗
(
        target: &mut Self::Target,
        conn: &mut Self::Connection,
    )

Source from the content-addressed store, hash-verified

449 type StopReason = MultiThreadStopReason<ArchUsize>;
450
451 fn wait_for_stop_reason(
452 target: &mut Self::Target,
453 conn: &mut Self::Connection,
454 ) -> Result<
455 run_blocking::Event<Self::StopReason>,
456 run_blocking::WaitForStopReasonError<
457 <Self::Target as Target>::Error,
458 <Self::Connection as Connection>::Error,
459 >,
460 > {
461 // Polling
462 loop {
463 // This read is non-blocking.
464 match target.vm_event.read() {
465 Ok(tid) => {
466 target
467 .vm_request(GdbRequestPayload::Pause, 0)
468 .map_err(|_| {
469 run_blocking::WaitForStopReasonError::Target(
470 "Failed to pause VM".to_owned(),
471 )
472 })?;
473 let stop_reason = if target.single_step {
474 MultiThreadStopReason::DoneStep
475 } else {
476 MultiThreadStopReason::HwBreak(Tid::new(tid as usize).unwrap())
477 };
478 return Ok(run_blocking::Event::TargetStopped(stop_reason));
479 }
480 Err(e) => {
481 if e.kind() != std::io::ErrorKind::WouldBlock {
482 return Err(run_blocking::WaitForStopReasonError::Connection(e));
483 }
484 }
485 }
486
487 if conn.peek().map_or(true, |b| b.is_some()) {
488 let byte = conn
489 .read()
490 .map_err(run_blocking::WaitForStopReasonError::Connection)?;
491 return Ok(run_blocking::Event::IncomingData(byte));
492 }
493 }
494 }
495
496 fn on_interrupt(
497 target: &mut Self::Target,

Callers

nothing calls this directly

Calls 5

newFunction · 0.85
vm_requestMethod · 0.80
kindMethod · 0.80
peekMethod · 0.80
readMethod · 0.45

Tested by

no test coverage detected