Skip to content

Commit 2842552

Browse files
authored
Debugging: avoid re-patching code on single-step update when state doesn't change. (#12638)
When the setter for the single-step flag is given an `enable` boolean that matches the existing state (i.e., enabling when already enabled or disabling when already disabled), we should not loop through and re-patch all breakpoint patch sites. This is an optimization, not required for correctness, but a rather obvious optimization to make (and important when building higher-level APIs for e.g. a single-step command that always set the flag).
1 parent bc6483b commit 2842552

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

crates/wasmtime/src/runtime/debug.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,11 @@ impl<'a> BreakpointEdit<'a> {
10881088
"single_step({enabled}) with breakpoint set {:?}",
10891089
self.state.breakpoints
10901090
);
1091+
if self.state.single_step == enabled {
1092+
// No change to current state; don't go through the effort of re-patching and
1093+
// re-publishing code.
1094+
return Ok(());
1095+
}
10911096
let modules = self.registry.all_modules().cloned().collect::<Vec<_>>();
10921097
for module in modules {
10931098
let mem = Self::get_code_memory(self.registry, &mut self.dirty_modules, &module)?;

0 commit comments

Comments
 (0)