1 // Copyright 2020 The ChromiumOS Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 use gdbstub::arch::Arch; 6 #[cfg(any(target_arch = "arm", target_arch = "aarch64"))] 7 use gdbstub_arch::aarch64::AArch64 as GdbArch; 8 #[cfg(target_arch = "riscv64")] 9 use gdbstub_arch::riscv::Riscv64 as GdbArch; 10 #[cfg(target_arch = "x86_64")] 11 use gdbstub_arch::x86::X86_64_SSE as GdbArch; 12 use vm_memory::GuestAddress; 13 14 /// Messages that can be sent to a vCPU to set/get its state from the debugger. 15 #[derive(Clone, Debug)] 16 pub enum VcpuDebug { 17 ReadMem(GuestAddress, usize), 18 ReadRegs, 19 ReadReg(<GdbArch as Arch>::RegId), 20 WriteRegs(Box<<GdbArch as Arch>::Registers>), 21 WriteReg(<GdbArch as Arch>::RegId, Vec<u8>), 22 WriteMem(GuestAddress, Vec<u8>), 23 EnableSinglestep, 24 GetHwBreakPointCount, 25 SetHwBreakPoint(Vec<GuestAddress>), 26 } 27 28 /// Messages that can be sent from a vCPU to update the state to the debugger. 29 #[allow(clippy::large_enum_variant)] 30 #[derive(Debug)] 31 pub enum VcpuDebugStatus { 32 RegValues(<GdbArch as Arch>::Registers), 33 RegValue(Vec<u8>), 34 MemoryRegion(Vec<u8>), 35 CommandComplete, 36 HwBreakPointCount(usize), 37 HitBreakPoint, 38 } 39 40 /// Pair of a vCPU ID and messages that can be sent from the vCPU to update the state to the 41 /// debugger. 42 #[derive(Debug)] 43 pub struct VcpuDebugStatusMessage { 44 pub cpu: usize, 45 pub msg: VcpuDebugStatus, 46 } 47