diff options
Diffstat (limited to 'examples/armv4t/gdb/breakpoints.rs')
-rw-r--r-- | examples/armv4t/gdb/breakpoints.rs | 54 |
1 files changed, 36 insertions, 18 deletions
diff --git a/examples/armv4t/gdb/breakpoints.rs b/examples/armv4t/gdb/breakpoints.rs index 1512943..6fa3038 100644 --- a/examples/armv4t/gdb/breakpoints.rs +++ b/examples/armv4t/gdb/breakpoints.rs @@ -6,12 +6,16 @@ use crate::emu::Emu; impl target::ext::breakpoints::Breakpoints for Emu { #[inline(always)] - fn sw_breakpoint(&mut self) -> Option<target::ext::breakpoints::SwBreakpointOps<Self>> { + fn support_sw_breakpoint( + &mut self, + ) -> Option<target::ext::breakpoints::SwBreakpointOps<'_, Self>> { Some(self) } #[inline(always)] - fn hw_watchpoint(&mut self) -> Option<target::ext::breakpoints::HwWatchpointOps<Self>> { + fn support_hw_watchpoint( + &mut self, + ) -> Option<target::ext::breakpoints::HwWatchpointOps<'_, Self>> { Some(self) } } @@ -41,27 +45,41 @@ impl target::ext::breakpoints::SwBreakpoint for Emu { } impl target::ext::breakpoints::HwWatchpoint for Emu { - fn add_hw_watchpoint(&mut self, addr: u32, kind: WatchKind) -> TargetResult<bool, Self> { - match kind { - WatchKind::Write => self.watchpoints.push(addr), - WatchKind::Read => self.watchpoints.push(addr), - WatchKind::ReadWrite => self.watchpoints.push(addr), - }; + fn add_hw_watchpoint( + &mut self, + addr: u32, + len: u32, + kind: WatchKind, + ) -> TargetResult<bool, Self> { + for addr in addr..(addr + len) { + match kind { + WatchKind::Write => self.watchpoints.push(addr), + WatchKind::Read => self.watchpoints.push(addr), + WatchKind::ReadWrite => self.watchpoints.push(addr), + }; + } Ok(true) } - fn remove_hw_watchpoint(&mut self, addr: u32, kind: WatchKind) -> TargetResult<bool, Self> { - let pos = match self.watchpoints.iter().position(|x| *x == addr) { - None => return Ok(false), - Some(pos) => pos, - }; + fn remove_hw_watchpoint( + &mut self, + addr: u32, + len: u32, + kind: WatchKind, + ) -> TargetResult<bool, Self> { + for addr in addr..(addr + len) { + let pos = match self.watchpoints.iter().position(|x| *x == addr) { + None => return Ok(false), + Some(pos) => pos, + }; - match kind { - WatchKind::Write => self.watchpoints.remove(pos), - WatchKind::Read => self.watchpoints.remove(pos), - WatchKind::ReadWrite => self.watchpoints.remove(pos), - }; + match kind { + WatchKind::Write => self.watchpoints.remove(pos), + WatchKind::Read => self.watchpoints.remove(pos), + WatchKind::ReadWrite => self.watchpoints.remove(pos), + }; + } Ok(true) } |