diff options
| author | Josh Ferrell <josh@vector35.com> | 2024-10-21 16:25:28 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2024-10-21 16:25:28 -0400 |
| commit | 344774a604b3643f3518aadf006970949a1e57dd (patch) | |
| tree | ee5e6d6f6299fa1810c1ceb51bfbb220e93692d0 /rust/examples | |
| parent | 7801723743382232581312128048566092583042 (diff) | |
Better calculation for sp offsets of DWARF local variables
Diffstat (limited to 'rust/examples')
| -rw-r--r-- | rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs | 6 |
1 files changed, 6 insertions, 0 deletions
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 |
