diff --git a/Cargo.toml b/Cargo.toml index b65914a..b31dbc0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,7 @@ fallible-iterator = "0.1" object = "0.7" intervaltree = "0.2" smallvec = "0.6" -lazy-init = "0.3" +lazycell = "1.0" rustc-demangle = { version = "0.1", optional = true } cpp_demangle = { version = "0.2", optional = true } diff --git a/src/lib.rs b/src/lib.rs index 6fcbeaa..f5fe734 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -28,7 +28,7 @@ extern crate cpp_demangle; extern crate fallible_iterator; extern crate gimli; extern crate intervaltree; -extern crate lazy_init; +extern crate lazycell; extern crate object; #[cfg(feature = "rustc-demangle")] extern crate rustc_demangle; @@ -41,7 +41,7 @@ use std::u64; use fallible_iterator::FallibleIterator; use intervaltree::{Element, IntervalTree}; -use lazy_init::Lazy; +use lazycell::LazyCell; use object::Object; use smallvec::SmallVec; @@ -57,8 +57,7 @@ struct Lines { struct ResUnit where - R: gimli::Reader + Sync, - R::Offset: Sync, + R: gimli::Reader, { dw_unit: gimli::CompilationUnitHeader, abbrevs: gimli::Abbreviations, @@ -67,8 +66,8 @@ where comp_name: Option, lang: Option, base_addr: u64, - lines: Lazy, Error>>, - funcs: Lazy>, Error>>, + lines: LazyCell, Error>>, + funcs: LazyCell>, Error>>, } /// The state necessary to perform address to line translation. @@ -77,8 +76,7 @@ where /// when performing lookups for many addresses in the same executable. pub struct Context where - R: gimli::Reader + Sync, - R::Offset: Sync, + R: gimli::Reader, { unit_ranges: Vec<(gimli::Range, usize)>, units: Vec>, @@ -205,8 +203,8 @@ impl<'a> Context> { comp_name: dcn, lang, base_addr, - lines: Lazy::new(), - funcs: Lazy::new(), + lines: LazyCell::new(), + funcs: LazyCell::new(), }); } @@ -242,12 +240,11 @@ impl<'a> Context> { impl ResUnit where - R: gimli::Reader + Sync, - R::Offset: Sync, + R: gimli::Reader, { fn parse_lines(&self, sections: &DebugSections) -> Result<&Lines, Error> { self.lines - .get_or_create(|| { + .borrow_with(|| { let ilnp = sections.debug_line.program( self.line_offset, self.dw_unit.address_size(), @@ -269,7 +266,7 @@ where sections: &DebugSections, ) -> Result<&IntervalTree>, Error> { self.funcs - .get_or_create(|| { + .borrow_with(|| { let mut results = Vec::new(); let mut depth = 0; let mut cursor = self.dw_unit.entries(&self.abbrevs); @@ -322,8 +319,7 @@ struct DebugSections { /// An iterator over function frames. pub struct FrameIter<'ctx, R> where - R: gimli::Reader + Sync + 'ctx, - R::Offset: Sync, + R: gimli::Reader + 'ctx, { unit_id: usize, units: &'ctx Vec>, @@ -426,8 +422,7 @@ pub struct Location { impl Context where - R: gimli::Reader + Sync, - R::Offset: Sync, + R: gimli::Reader, { fn find_unit(&self, probe: u64) -> Option { let idx = self.unit_ranges.binary_search_by(|r| { @@ -491,8 +486,7 @@ where impl ResUnit where - R: gimli::Reader + Sync, - R::Offset: Sync, + R: gimli::Reader, { fn find_location( &self, @@ -570,8 +564,7 @@ fn name_attr<'abbrev, 'unit, R>( recursion_limit: usize, ) -> Result, Error> where - R: gimli::Reader + Sync, - R::Offset: Sync, + R: gimli::Reader, { if recursion_limit == 0 { return Ok(None); @@ -625,8 +618,7 @@ where impl<'ctx, R> FrameIter<'ctx, R> where - R: gimli::Reader + Sync + 'ctx, - R::Offset: Sync, + R: gimli::Reader + 'ctx, { /// Advances the iterator and returns the next frame. pub fn next(&mut self) -> Result>, Error> { @@ -690,8 +682,7 @@ where impl<'ctx, R> FallibleIterator for FrameIter<'ctx, R> where - R: gimli::Reader + Sync + 'ctx, - R::Offset: Sync, + R: gimli::Reader + 'ctx, { type Item = Frame; type Error = Error;