use crate::arch::Arch;
use crate::target::Target;
use crate::target::TargetResult;
pub trait Breakpoints: Target {
#[inline(always)]
fn support_sw_breakpoint(&mut self) -> Option<SwBreakpointOps<'_, Self>> {
None
}
#[inline(always)]
fn support_hw_breakpoint(&mut self) -> Option<HwBreakpointOps<'_, Self>> {
None
}
#[inline(always)]
fn support_hw_watchpoint(&mut self) -> Option<HwWatchpointOps<'_, Self>> {
None
}
}
define_ext!(BreakpointsOps, Breakpoints);
pub trait SwBreakpoint: Target + Breakpoints {
fn add_sw_breakpoint(
&mut self,
addr: <Self::Arch as Arch>::Usize,
kind: <Self::Arch as Arch>::BreakpointKind,
) -> TargetResult<bool, Self>;
fn remove_sw_breakpoint(
&mut self,
addr: <Self::Arch as Arch>::Usize,
kind: <Self::Arch as Arch>::BreakpointKind,
) -> TargetResult<bool, Self>;
}
define_ext!(SwBreakpointOps, SwBreakpoint);
pub trait HwBreakpoint: Target + Breakpoints {
fn add_hw_breakpoint(
&mut self,
addr: <Self::Arch as Arch>::Usize,
kind: <Self::Arch as Arch>::BreakpointKind,
) -> TargetResult<bool, Self>;
fn remove_hw_breakpoint(
&mut self,
addr: <Self::Arch as Arch>::Usize,
kind: <Self::Arch as Arch>::BreakpointKind,
) -> TargetResult<bool, Self>;
}
define_ext!(HwBreakpointOps, HwBreakpoint);
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum WatchKind {
Write,
Read,
ReadWrite,
}
pub trait HwWatchpoint: Target + Breakpoints {
fn add_hw_watchpoint(
&mut self,
addr: <Self::Arch as Arch>::Usize,
len: <Self::Arch as Arch>::Usize,
kind: WatchKind,
) -> TargetResult<bool, Self>;
fn remove_hw_watchpoint(
&mut self,
addr: <Self::Arch as Arch>::Usize,
len: <Self::Arch as Arch>::Usize,
kind: WatchKind,
) -> TargetResult<bool, Self>;
}
define_ext!(HwWatchpointOps, HwWatchpoint);