mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
vmm: Implement GDB event handler to enable --gdb flag
This commit adds event fds and the event handler to send/receive requests and responses from the GDB thread. It also adds `--gdb` flag to enable GDB stub feature. Signed-off-by: Akira Moroo <retrage01@gmail.com>
This commit is contained in:
committed by
Rob Bradford
parent
23bb629241
commit
2451c4d833
+18
-1
@@ -14,7 +14,7 @@
|
||||
use crate::config::CpusConfig;
|
||||
use crate::device_manager::DeviceManager;
|
||||
#[cfg(feature = "gdb")]
|
||||
use crate::gdb::{Debuggable, DebuggableError};
|
||||
use crate::gdb::{get_raw_tid, Debuggable, DebuggableError};
|
||||
use crate::memory_manager::MemoryManager;
|
||||
use crate::seccomp_filters::{get_seccomp_filter, Thread};
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
@@ -405,6 +405,8 @@ pub struct CpuManager {
|
||||
exit_evt: EventFd,
|
||||
#[cfg_attr(target_arch = "aarch64", allow(dead_code))]
|
||||
reset_evt: EventFd,
|
||||
#[cfg(feature = "gdb")]
|
||||
vm_debug_evt: EventFd,
|
||||
vcpu_states: Vec<VcpuState>,
|
||||
selected_cpu: u8,
|
||||
vcpus: Vec<Arc<Mutex<Vcpu>>>,
|
||||
@@ -557,6 +559,7 @@ impl CpuManager {
|
||||
vm: Arc<dyn hypervisor::Vm>,
|
||||
exit_evt: EventFd,
|
||||
reset_evt: EventFd,
|
||||
#[cfg(feature = "gdb")] vm_debug_evt: EventFd,
|
||||
hypervisor: Arc<dyn hypervisor::Hypervisor>,
|
||||
seccomp_action: SeccompAction,
|
||||
vmmops: Arc<dyn VmmOps>,
|
||||
@@ -635,6 +638,8 @@ impl CpuManager {
|
||||
vcpu_states,
|
||||
exit_evt,
|
||||
reset_evt,
|
||||
#[cfg(feature = "gdb")]
|
||||
vm_debug_evt,
|
||||
selected_cpu: 0,
|
||||
vcpus: Vec::with_capacity(usize::from(config.max_vcpus)),
|
||||
seccomp_action,
|
||||
@@ -773,6 +778,8 @@ impl CpuManager {
|
||||
) -> Result<()> {
|
||||
let reset_evt = self.reset_evt.try_clone().unwrap();
|
||||
let exit_evt = self.exit_evt.try_clone().unwrap();
|
||||
#[cfg(feature = "gdb")]
|
||||
let vm_debug_evt = self.vm_debug_evt.try_clone().unwrap();
|
||||
let panic_exit_evt = self.exit_evt.try_clone().unwrap();
|
||||
let vcpu_kill_signalled = self.vcpus_kill_signalled.clone();
|
||||
let vcpu_pause_signalled = self.vcpus_pause_signalled.clone();
|
||||
@@ -904,6 +911,16 @@ impl CpuManager {
|
||||
// vcpu.run() returns false on a triple-fault so trigger a reset
|
||||
match vcpu.run() {
|
||||
Ok(run) => match run {
|
||||
#[cfg(all(target_arch = "x86_64", feature = "kvm"))]
|
||||
VmExit::Debug => {
|
||||
info!("VmExit::Debug");
|
||||
#[cfg(feature = "gdb")]
|
||||
{
|
||||
vcpu_pause_signalled.store(true, Ordering::SeqCst);
|
||||
let raw_tid = get_raw_tid(vcpu_id as usize);
|
||||
vm_debug_evt.write(raw_tid as u64).unwrap();
|
||||
}
|
||||
}
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
VmExit::IoapicEoi(vector) => {
|
||||
if let Some(interrupt_controller) =
|
||||
|
||||
Reference in New Issue
Block a user