Skip to content

Commit

Permalink
Use ELF virtual address instead of file offset
Browse files Browse the repository at this point in the history
When computing normalized address, use elf virtual addresses instead of
file offsets because file offset alone is not enough to perform
symbolization with split debug information.
  • Loading branch information
nsavoire committed Oct 17, 2024
1 parent 2820fd0 commit 3c0e636
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions crashtracker/src/crash_info/stacktrace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ pub struct NormalizedAddress {
#[cfg(unix)]
mod unix {
use super::*;
use anyhow::anyhow;
use blazesym::{
helper::ElfResolver,
normalize::{Normalizer, UserMeta},
symbolize::{Input, Source, Sym, Symbolized, Symbolizer},
symbolize::{Input, Source, Sym, Symbolized, Symbolizer, TranslateFileOffset},
Pid,
};

Expand Down Expand Up @@ -109,8 +111,16 @@ mod unix {
let normed = normalizer.normalize_user_addrs(pid, &[ip])?;
anyhow::ensure!(normed.outputs.len() == 1);
let (file_offset, meta_idx) = normed.outputs[0];
let meta = (&normed.meta[meta_idx]).into();
self.normalized_ip = Some(NormalizedAddress { file_offset, meta });
let meta = &normed.meta[meta_idx];
let elf = meta.elf().ok_or(anyhow::anyhow!("Not elf"))?;
let resolver = ElfResolver::open(&elf.path)?;
let virt_address = resolver
.file_offset_to_virt_offset(file_offset)?
.ok_or(anyhow!("No matching segment found"))?;
self.normalized_ip = Some(NormalizedAddress {
file_offset: virt_address,
meta: meta.into(),
});
}
Ok(())
}
Expand Down

0 comments on commit 3c0e636

Please sign in to comment.