From 55d001dab9877647715d1f413b550b9d642f2daf Mon Sep 17 00:00:00 2001 From: Syrus Date: Thu, 3 Dec 2020 21:17:55 -0800 Subject: [PATCH] Debug frameinfos --- lib/engine-jit/src/artifact.rs | 4 +--- lib/engine/src/trap/frame_info.rs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/engine-jit/src/artifact.rs b/lib/engine-jit/src/artifact.rs index e9d91e10bdc..b1cc5c610a2 100644 --- a/lib/engine-jit/src/artifact.rs +++ b/lib/engine-jit/src/artifact.rs @@ -99,9 +99,7 @@ impl JITArtifact { .collect::>() .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::>(); diff --git a/lib/engine/src/trap/frame_info.rs b/lib/engine/src/trap/frame_info.rs index 9d5585a03dc..67bc22adb65 100644 --- a/lib/engine/src/trap/frame_info.rs +++ b/lib/engine/src/trap/frame_info.rs @@ -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 { + 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), @@ -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 @@ -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,