mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
This commit adds initial gdb.rs implementation for `Debuggable` trait to describe a debuggable component. Some part of the trait bound implementations is based on the crosvm GDB stub code [1]. [1] https://github.com/google/crosvm/blob/main/src/gdb.rs Signed-off-by: Akira Moroo <retrage01@gmail.com>
54 lines
1.7 KiB
Rust
54 lines
1.7 KiB
Rust
// Copyright 2022 Akira Moroo.
|
|
// Portions Copyright 2020 The Chromium OS Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE-BSD-3-Clause file.
|
|
//
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
#[cfg(target_arch = "x86_64")]
|
|
use gdbstub_arch::x86::reg::X86_64CoreRegs as CoreRegs;
|
|
use vm_memory::GuestAddress;
|
|
|
|
#[derive(Debug)]
|
|
pub enum DebuggableError {
|
|
SetDebug(hypervisor::HypervisorCpuError),
|
|
Pause(vm_migration::MigratableError),
|
|
Resume(vm_migration::MigratableError),
|
|
ReadRegs(crate::cpu::Error),
|
|
WriteRegs(crate::cpu::Error),
|
|
ReadMem(hypervisor::HypervisorVmError),
|
|
WriteMem(hypervisor::HypervisorVmError),
|
|
TranslateGva(crate::cpu::Error),
|
|
PoisonedState,
|
|
}
|
|
|
|
pub trait Debuggable: vm_migration::Pausable {
|
|
fn set_guest_debug(
|
|
&self,
|
|
cpu_id: usize,
|
|
addrs: &[GuestAddress],
|
|
singlestep: bool,
|
|
) -> Result<(), DebuggableError>;
|
|
fn debug_pause(&mut self) -> std::result::Result<(), DebuggableError>;
|
|
fn debug_resume(&mut self) -> std::result::Result<(), DebuggableError>;
|
|
fn read_regs(&self, cpu_id: usize) -> std::result::Result<CoreRegs, DebuggableError>;
|
|
fn write_regs(
|
|
&self,
|
|
cpu_id: usize,
|
|
regs: &CoreRegs,
|
|
) -> std::result::Result<(), DebuggableError>;
|
|
fn read_mem(
|
|
&self,
|
|
cpu_id: usize,
|
|
vaddr: GuestAddress,
|
|
len: usize,
|
|
) -> std::result::Result<Vec<u8>, DebuggableError>;
|
|
fn write_mem(
|
|
&self,
|
|
cpu_id: usize,
|
|
vaddr: &GuestAddress,
|
|
data: &[u8],
|
|
) -> std::result::Result<(), DebuggableError>;
|
|
fn active_vcpus(&self) -> usize;
|
|
}
|