From 4f9fe856a25ab29345b90e7725509e9ee38a37be Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:41 +0200 Subject: Adding upstream version 1.69.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/gimli/src/read/dwarf.rs | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) (limited to 'vendor/gimli/src/read/dwarf.rs') diff --git a/vendor/gimli/src/read/dwarf.rs b/vendor/gimli/src/read/dwarf.rs index b63526941..cce364c2b 100644 --- a/vendor/gimli/src/read/dwarf.rs +++ b/vendor/gimli/src/read/dwarf.rs @@ -9,11 +9,11 @@ use crate::common::{ }; use crate::constants; use crate::read::{ - Abbreviations, AttributeValue, DebugAbbrev, DebugAddr, DebugAranges, DebugCuIndex, DebugInfo, - DebugInfoUnitHeadersIter, DebugLine, DebugLineStr, DebugLoc, DebugLocLists, DebugRngLists, - DebugStr, DebugStrOffsets, DebugTuIndex, DebugTypes, DebugTypesUnitHeadersIter, - DebuggingInformationEntry, EntriesCursor, EntriesRaw, EntriesTree, Error, - IncompleteLineProgram, LocListIter, LocationLists, Range, RangeLists, RawLocListIter, + Abbreviations, AbbreviationsCache, AttributeValue, DebugAbbrev, DebugAddr, DebugAranges, + DebugCuIndex, DebugInfo, DebugInfoUnitHeadersIter, DebugLine, DebugLineStr, DebugLoc, + DebugLocLists, DebugRngLists, DebugStr, DebugStrOffsets, DebugTuIndex, DebugTypes, + DebugTypesUnitHeadersIter, DebuggingInformationEntry, EntriesCursor, EntriesRaw, EntriesTree, + Error, IncompleteLineProgram, LocListIter, LocationLists, Range, RangeLists, RawLocListIter, RawRngListIter, Reader, ReaderOffset, ReaderOffsetId, Result, RngListIter, Section, UnitHeader, UnitIndex, UnitIndexSectionIterator, UnitOffset, UnitType, }; @@ -59,6 +59,9 @@ pub struct Dwarf { /// The DWARF sections for a supplementary object file. pub sup: Option>>, + + /// A cache of previously parsed abbreviations for units in this file. + pub abbreviations_cache: AbbreviationsCache, } impl Dwarf { @@ -96,6 +99,7 @@ impl Dwarf { ranges: RangeLists::new(debug_ranges, debug_rnglists), file_type: DwarfFileType::Main, sup: None, + abbreviations_cache: AbbreviationsCache::new(), }) } @@ -157,6 +161,7 @@ impl Dwarf { ranges: self.ranges.borrow(&mut borrow), file_type: self.file_type, sup: self.sup().map(|sup| Arc::new(sup.borrow(borrow))), + abbreviations_cache: AbbreviationsCache::new(), } } @@ -192,10 +197,10 @@ impl Dwarf { } /// Parse the abbreviations for a compilation unit. - // TODO: provide caching of abbreviations #[inline] - pub fn abbreviations(&self, unit: &UnitHeader) -> Result { - unit.abbreviations(&self.debug_abbrev) + pub fn abbreviations(&self, unit: &UnitHeader) -> Result> { + self.abbreviations_cache + .get(&self.debug_abbrev, unit.debug_abbrev_offset()) } /// Return the string offset at the given index. @@ -783,6 +788,7 @@ impl DwarfPackage { ranges: RangeLists::new(debug_ranges, debug_rnglists), file_type: DwarfFileType::Dwo, sup: None, + abbreviations_cache: AbbreviationsCache::new(), }) } } @@ -799,7 +805,7 @@ where pub header: UnitHeader, /// The parsed abbreviations for the unit. - pub abbreviations: Abbreviations, + pub abbreviations: Arc, /// The `DW_AT_name` attribute of the unit. pub name: Option, @@ -833,7 +839,7 @@ impl Unit { /// Construct a new `Unit` from the given unit header. #[inline] pub fn new(dwarf: &Dwarf, header: UnitHeader) -> Result { - let abbreviations = header.abbreviations(&dwarf.debug_abbrev)?; + let abbreviations = dwarf.abbreviations(&header)?; let mut unit = Unit { abbreviations, name: None, -- cgit v1.2.3