From 344774a604b3643f3518aadf006970949a1e57dd Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Mon, 21 Oct 2024 16:25:28 -0400 Subject: Better calculation for sp offsets of DWARF local variables --- rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'rust/examples') diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs index 4c231a88..168ddaaa 100644 --- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -407,11 +407,17 @@ impl DebugInfoBuilder { }; let adjusted_offset; + let Some(adjustment_at_variable_lifetime_start) = lexical_block.and_then(|block_ranges| { block_ranges .unsorted_iter() .find_map(|x| self.range_data_offsets.values_overlap(x.start).next()) }).or_else(|| { + // Try using the offset at the adjustment 4 bytes after the function start, in case the function starts with a stack adjustment + // TODO: This is a decent heuristic but not perfect, since further adjustments could still be made + self.range_data_offsets.values_overlap(func_addr+4).next() + }).or_else(|| { + // If all else fails, use the function start address self.range_data_offsets.values_overlap(func_addr).next() }) else { // Unknown why, but this is happening with MachO + external dSYM -- cgit v1.3.1