Skip to content

Commit

Permalink
Debug frameinfos
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Dec 4, 2020
1 parent 7745875 commit 55d001d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/engine-jit/src/artifact.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@ impl JITArtifact {
.collect::<Vec<_>>()
.into_boxed_slice();

let frame_infos = compilation
.get_frame_info()
.values()
let frame_infos = dbg!(compilation.get_frame_info().values())
.map(|frame_info| SerializableFunctionFrameInfo::Processed(frame_info.clone()))
.collect::<PrimaryMap<LocalFunctionIndex, _>>();

Expand Down
16 changes: 13 additions & 3 deletions lib/engine/src/trap/frame_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,22 @@ impl GlobalFrameInfo {
/// Returns an object if this `pc` is known to some previously registered
/// module, or returns `None` if no information can be found.
pub fn lookup_frame_info(&self, pc: usize) -> Option<FrameInfo> {
dbg!(pc);
let module = self.module_info(pc)?;
println!("lookup_frame_info::module_info success");
let func = module.function_info(pc)?;
println!("lookup_frame_info::function_info success");

// Use our relative position from the start of the function to find the
// machine instruction that corresponds to `pc`, which then allows us to
// map that to a wasm original source location.
let rel_pos = pc - func.start;
let rel_pos = dbg!(pc - func.start);
let instr_map = &module
.processed_function_frame_info(func.local_index)
.address_map;
let pos = match instr_map
let pos = match dbg!(instr_map
.instructions
.binary_search_by_key(&rel_pos, |map| map.code_offset)
.binary_search_by_key(&rel_pos, |map| map.code_offset))
{
// Exact hit!
Ok(pos) => Some(pos),
Expand All @@ -144,6 +147,8 @@ impl GlobalFrameInfo {
}
};

dbg!(pos);

// In debug mode for now assert that we found a mapping for `pc` within
// the function, because otherwise something is buggy along the way and
// not accounting for all the instructions. This isn't super critical
Expand Down Expand Up @@ -277,6 +282,11 @@ pub fn register(
assert!(*prev_end < min);
}

println!(
"Frame info ranges for this Module info are ({}, {})",
min, max
);

// ... then insert our range and assert nothing was there previously
let prev = info.ranges.insert(
max,
Expand Down

0 comments on commit 55d001d

Please sign in to comment.