mirror of
https://github.com/obhq/obliteration.git
synced 2024-11-23 11:19:56 +00:00
Implements read_registers for x86_64 (#1050)
Co-authored-by: tompro <tomas.prochazka@apertia.cz>
This commit is contained in:
parent
c2f486fa46
commit
9df9f3bcf7
@ -1,4 +1,5 @@
|
|||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||||
|
use super::controller::CpuController;
|
||||||
use super::CpuManager;
|
use super::CpuManager;
|
||||||
use crate::vmm::hv::Hypervisor;
|
use crate::vmm::hv::Hypervisor;
|
||||||
use crate::vmm::screen::Screen;
|
use crate::vmm::screen::Screen;
|
||||||
@ -9,14 +10,27 @@ use gdbstub::target::ext::breakpoints::{
|
|||||||
Breakpoints, BreakpointsOps, SwBreakpoint, SwBreakpointOps,
|
Breakpoints, BreakpointsOps, SwBreakpoint, SwBreakpointOps,
|
||||||
};
|
};
|
||||||
use gdbstub::target::ext::thread_extra_info::{ThreadExtraInfo, ThreadExtraInfoOps};
|
use gdbstub::target::ext::thread_extra_info::{ThreadExtraInfo, ThreadExtraInfoOps};
|
||||||
use gdbstub::target::TargetResult;
|
use gdbstub::target::{TargetError as GdbTargetError, TargetResult};
|
||||||
use gdbstub_arch::x86::reg::X86_64CoreRegs;
|
use gdbstub_arch::x86::reg::X86_64CoreRegs;
|
||||||
use gdbstub_arch::x86::X86_64_SSE;
|
use gdbstub_arch::x86::X86_64_SSE;
|
||||||
use std::num::NonZero;
|
use std::num::NonZero;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
|
const ENOENT: u8 = 2;
|
||||||
|
|
||||||
pub type GdbRegs = gdbstub_arch::x86::reg::X86_64CoreRegs;
|
pub type GdbRegs = gdbstub_arch::x86::reg::X86_64CoreRegs;
|
||||||
|
|
||||||
|
impl<H: Hypervisor, S: Screen> CpuManager<H, S> {
|
||||||
|
fn get_cpu(&mut self, tid: Tid) -> TargetResult<&mut CpuController, Self> {
|
||||||
|
let cpu = self
|
||||||
|
.cpus
|
||||||
|
.get_mut(tid.get() as usize - 1)
|
||||||
|
.ok_or(GdbTargetError::Errno(ENOENT))?;
|
||||||
|
|
||||||
|
Ok(cpu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<H: Hypervisor, S: Screen> gdbstub::target::Target for CpuManager<H, S> {
|
impl<H: Hypervisor, S: Screen> gdbstub::target::Target for CpuManager<H, S> {
|
||||||
type Arch = X86_64_SSE;
|
type Arch = X86_64_SSE;
|
||||||
type Error = TargetError;
|
type Error = TargetError;
|
||||||
@ -32,10 +46,18 @@ impl<H: Hypervisor, S: Screen> gdbstub::target::Target for CpuManager<H, S> {
|
|||||||
|
|
||||||
impl<H: Hypervisor, S: Screen> MultiThreadBase for CpuManager<H, S> {
|
impl<H: Hypervisor, S: Screen> MultiThreadBase for CpuManager<H, S> {
|
||||||
fn read_registers(&mut self, regs: &mut X86_64CoreRegs, tid: Tid) -> TargetResult<(), Self> {
|
fn read_registers(&mut self, regs: &mut X86_64CoreRegs, tid: Tid) -> TargetResult<(), Self> {
|
||||||
todo!()
|
let mut cpu = self.get_cpu(tid)?;
|
||||||
|
|
||||||
|
let current_regs = cpu.debug_mut().unwrap().lock();
|
||||||
|
|
||||||
|
*regs = current_regs.clone();
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_registers(&mut self, regs: &X86_64CoreRegs, tid: Tid) -> TargetResult<(), Self> {
|
fn write_registers(&mut self, regs: &X86_64CoreRegs, tid: Tid) -> TargetResult<(), Self> {
|
||||||
|
let mut _cpu = self.get_cpu(tid)?;
|
||||||
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,10 +67,14 @@ impl<H: Hypervisor, S: Screen> MultiThreadBase for CpuManager<H, S> {
|
|||||||
data: &mut [u8],
|
data: &mut [u8],
|
||||||
tid: Tid,
|
tid: Tid,
|
||||||
) -> TargetResult<usize, Self> {
|
) -> TargetResult<usize, Self> {
|
||||||
|
let mut _cpu = self.get_cpu(tid)?;
|
||||||
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_addrs(&mut self, start_addr: u64, data: &[u8], tid: Tid) -> TargetResult<(), Self> {
|
fn write_addrs(&mut self, start_addr: u64, data: &[u8], tid: Tid) -> TargetResult<(), Self> {
|
||||||
|
let mut _cpu = self.get_cpu(tid)?;
|
||||||
|
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user