Skip to content

Commit

Permalink
fix(debugger): don't panic on pc-ic / sourcemap mismatch (foundry-rs#…
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored May 24, 2024
1 parent a03fed9 commit 10f1402
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions crates/debugger/src/tui/draw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -350,17 +350,18 @@ impl DebuggerContext<'_> {
} else {
contract_source.deployed_bytecode.bytecode.as_ref()?
};
let mut source_map = bytecode.source_map()?.ok()?;
let source_map = bytecode.source_map()?.ok()?;

let pc_ic_map = if is_create { create_map } else { rt_map };
let ic = pc_ic_map.get(pc)?;
let source_element = source_map.swap_remove(ic);
let source_element = source_map.get(ic)?;
// if the source element has an index, find the sourcemap for that index
source_element
.index
.and_then(|index|
// if index matches current file_id, return current source code
(index == file_id).then(|| (source_element.clone(), source_code)))
.and_then(|index| {
(index == file_id).then(|| (source_element.clone(), source_code))
})
.or_else(|| {
// otherwise find the source code for the element's index
self.debugger
Expand Down

0 comments on commit 10f1402

Please sign in to comment.