Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions crates/debugger/src/host/opaque.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,15 +519,21 @@ impl<T: Send + 'static> OpaqueDebugger for crate::Debuggee<T> {
#[cfg(feature = "threads")]
Memory::Shared(_) => return Err(wit::Error::UnsupportedType.into()),
};
self.with_store(move |mut store| -> Result<()> {
self.with_store(move |store| -> Result<()> {
let size = u64::try_from(memory.data_size(&store)).unwrap();
let end = addr
.checked_add(len)
.filter(|&end| end <= size)
.ok_or(wit::Error::OutOfBounds)?;
memory
.debug_watch(&mut store, addr..end, watch)
.map_err(|_| wit::Error::OutOfBounds)?;
let mut breakpoints = store
.edit_breakpoints()
.ok_or(wit::Error::UnsupportedType)?;
let result = if watch {
breakpoints.watch(memory, addr..end)
} else {
breakpoints.unwatch(memory, addr..end)
};
result.map_err(|_| wit::Error::OutOfBounds)?;
Ok(())
})
.await?
Expand Down
10 changes: 7 additions & 3 deletions crates/debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -749,7 +749,7 @@ mod test {
// Watch bytes [8, 12): the first store is just below the
// range, the second overlaps it partially, the third is just
// above it, and the fill covers all of it.
memory.debug_watch(&mut store, 8..12, true)?;
store.edit_breakpoints().unwrap().watch(memory, 8..12)?;

let mut debuggee = Debuggee::new(store, move |store| {
Box::pin(async move {
Expand Down Expand Up @@ -792,13 +792,17 @@ mod test {
}
);
debuggee
.with_store(move |mut store| {
.with_store(move |store| {
// The previous write has now happened, but not the
// fill.
assert_eq!(&memory.data(&store)[6..10], &0x11223344_u32.to_le_bytes());
assert_eq!(memory.data(&store)[12], 2);
// Stop watching; the rest of execution runs freely.
memory.debug_watch(&mut store, 0..16, false).unwrap();
store
.edit_breakpoints()
.unwrap()
.unwatch(memory, 0..16)
.unwrap();
})
.await?;

Expand Down
Loading
Loading