Skip to content

Commit

Permalink
Add Unit::new_with_abbreviations() to allow the user to use custom ab…
Browse files Browse the repository at this point in the history
…breviations cache (#677)
  • Loading branch information
al13n321 authored Sep 11, 2023
1 parent d9febe3 commit 2d3ad32
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/read/dwarf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -856,6 +856,19 @@ impl<R: Reader> Unit<R> {
#[inline]
pub fn new(dwarf: &Dwarf<R>, header: UnitHeader<R>) -> Result<Self> {
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<R>,
header: UnitHeader<R>,
abbreviations: Arc<Abbreviations>,
) -> Result<Self> {
let mut unit = Unit {
abbreviations,
name: None,
Expand Down

0 comments on commit 2d3ad32

Please sign in to comment.