diff --git a/src/read/dwarf.rs b/src/read/dwarf.rs index bba0af3e..afc154e7 100644 --- a/src/read/dwarf.rs +++ b/src/read/dwarf.rs @@ -856,6 +856,19 @@ impl Unit { #[inline] pub fn new(dwarf: &Dwarf, header: UnitHeader) -> Result { let abbreviations = dwarf.abbreviations(&header)?; + Self::new_with_abbreviations(dwarf, header, abbreviations) + } + + /// Construct a new `Unit` from the given unit header and abbreviations. + /// + /// The abbreviations for this call can be obtained using `dwarf.abbreviations(&header)`. + /// The caller may implement caching to reuse the Abbreviations across units with the same header.debug_abbrev_offset() value. + #[inline] + pub fn new_with_abbreviations( + dwarf: &Dwarf, + header: UnitHeader, + abbreviations: Arc, + ) -> Result { let mut unit = Unit { abbreviations, name: None,