Skip to content

Commit af674ae

Browse files
philipcalexcrichton
andcommitted
Update addr2line to 0.11.0 (#273)
* Update addr2line to 0.11.0 Fixes gimli performance issues. * Add a missing import on Windows Co-authored-by: Alex Crichton <alex@alexcrichton.com>
1 parent af148bf commit af674ae

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ rustc-serialize = { version = "0.3", optional = true }
3434
cpp_demangle = { default-features = false, version = "0.2.3", optional = true }
3535

3636
# Optional dependencies enabled through the `gimli-symbolize` feature
37-
addr2line = { version = "0.10.0", optional = true, default-features = false, features = ['std'] }
37+
addr2line = { version = "0.11.0", optional = true, default-features = false, features = ['std'] }
3838
findshlibs = { version = "0.5.0", optional = true }
3939
memmap = { version = "0.7.0", optional = true }
4040
goblin = { version = "0.1.3", optional = true, default-features = false, features = ['elf32', 'elf64', 'mach32', 'mach64', 'pe32', 'pe64', 'std'] }

src/symbolize/gimli.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use crate::symbolize::ResolveWhat;
1111
use crate::types::BytesOrWideString;
1212
use crate::SymbolName;
1313
use addr2line::gimli;
14-
use core::convert::TryFrom;
1514
use core::mem;
1615
use core::u32;
1716
use findshlibs::{self, Segment, SharedLibrary};
@@ -83,9 +82,10 @@ fn mmap(path: &Path) -> Option<Mmap> {
8382

8483
cfg_if::cfg_if! {
8584
if #[cfg(windows)] {
86-
use std::cmp;
8785
use goblin::pe::{self, PE};
8886
use goblin::strtab::Strtab;
87+
use std::cmp;
88+
use std::convert::TryFrom;
8989

9090
struct Object<'a> {
9191
pe: PE<'a>,
@@ -542,14 +542,11 @@ pub unsafe fn resolve(what: ResolveWhat, cb: &mut FnMut(&super::Symbol)) {
542542
None => return,
543543
};
544544
if let Ok(mut frames) = cx.dwarf.find_frames(addr.0 as u64) {
545-
while let Ok(Some(mut frame)) = frames.next() {
546-
let function = frame.function.take();
547-
let name = function.as_ref().and_then(|f| f.raw_name().ok());
548-
let name = name.as_ref().map(|n| n.as_bytes());
545+
while let Ok(Some(frame)) = frames.next() {
549546
cb.call(Symbol::Frame {
550547
addr: addr.0 as *mut c_void,
551-
frame,
552-
name,
548+
location: frame.location,
549+
name: frame.function.map(|f| f.name.slice()),
553550
});
554551
}
555552
}
@@ -605,7 +602,7 @@ pub enum Symbol<'a> {
605602
/// `addr2line`'s frame internally has all the nitty gritty details.
606603
Frame {
607604
addr: *mut c_void,
608-
frame: addr2line::Frame<EndianSlice<'a, Endian>>,
605+
location: Option<addr2line::Location<'a>>,
609606
name: Option<&'a [u8]>,
610607
},
611608
/// Couldn't find debug information, but we found it in the symbol table of
@@ -639,9 +636,8 @@ impl Symbol<'_> {
639636
pub fn filename_raw(&self) -> Option<BytesOrWideString> {
640637
match self {
641638
Symbol::Dladdr(s) => return s.filename_raw(),
642-
Symbol::Frame { frame, .. } => {
643-
let location = frame.location.as_ref()?;
644-
let file = location.file.as_ref()?;
639+
Symbol::Frame { location, .. } => {
640+
let file = location.as_ref()?.file?;
645641
Some(BytesOrWideString::Bytes(file.as_bytes()))
646642
}
647643
Symbol::Symtab { .. } => None,
@@ -651,9 +647,8 @@ impl Symbol<'_> {
651647
pub fn filename(&self) -> Option<&Path> {
652648
match self {
653649
Symbol::Dladdr(s) => return s.filename(),
654-
Symbol::Frame { frame, .. } => {
655-
let location = frame.location.as_ref()?;
656-
let file = location.file.as_ref()?;
650+
Symbol::Frame { location, .. } => {
651+
let file = location.as_ref()?.file?;
657652
Some(Path::new(file))
658653
}
659654
Symbol::Symtab { .. } => None,
@@ -663,10 +658,7 @@ impl Symbol<'_> {
663658
pub fn lineno(&self) -> Option<u32> {
664659
match self {
665660
Symbol::Dladdr(s) => return s.lineno(),
666-
Symbol::Frame { frame, .. } => {
667-
let location = frame.location.as_ref()?;
668-
location.line.and_then(|l| u32::try_from(l).ok())
669-
}
661+
Symbol::Frame { location, .. } => location.as_ref()?.line,
670662
Symbol::Symtab { .. } => None,
671663
}
672664
}

0 commit comments

Comments
 (0)