Skip to content

Commit

Permalink
[PROF-10680] Use ELF virtual address instead of file offset (#680)
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 authored Oct 17, 2024
1 parent 2820fd0 commit e9a0af0
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 e9a0af0

Please sign in to comment.