Skip to content

Commit

Permalink
fix: Handle edge case when mapping source lines into opcodes
Browse files Browse the repository at this point in the history
If a source breakpoint is set at the end of the file, it may occur *after* all
lines that are mapped to an opcode. Do not set any breakpoint in that case.
  • Loading branch information
ggiraldez committed Feb 5, 2024
1 parent d6ebb19 commit fa28d31
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tooling/debugger/src/dap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,12 @@ impl<'a, R: Read, W: Write, B: BlackBoxFunctionSolver> DapSession<'a, R, W, B> {
};
let found_index = match line_to_opcodes.binary_search_by(|x| x.0.cmp(&line)) {
Ok(index) => line_to_opcodes[index].1,
Err(index) => line_to_opcodes[index].1,
Err(index) => {
if index >= line_to_opcodes.len() {
return None;
}
line_to_opcodes[index].1
}
};
Some(found_index)
}
Expand Down

0 comments on commit fa28d31

Please sign in to comment.