diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:19:50 +0000 |
commit | 2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35 (patch) | |
tree | d325add32978dbdc1db975a438b3a77d571b1ab8 /vendor/gimli/src/read/dwarf.rs | |
parent | Releasing progress-linux version 1.68.2+dfsg1-1~progress7.99u1. (diff) | |
download | rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.tar.xz rustc-2e00214b3efbdfeefaa0fe9e8b8fd519de7adc35.zip |
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gimli/src/read/dwarf.rs')
-rw-r--r-- | vendor/gimli/src/read/dwarf.rs | 26 |
1 files changed, 16 insertions, 10 deletions
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<R> { /// The DWARF sections for a supplementary object file. pub sup: Option<Arc<Dwarf<R>>>, + + /// A cache of previously parsed abbreviations for units in this file. + pub abbreviations_cache: AbbreviationsCache, } impl<T> Dwarf<T> { @@ -96,6 +99,7 @@ impl<T> Dwarf<T> { ranges: RangeLists::new(debug_ranges, debug_rnglists), file_type: DwarfFileType::Main, sup: None, + abbreviations_cache: AbbreviationsCache::new(), }) } @@ -157,6 +161,7 @@ impl<T> Dwarf<T> { 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<R: Reader> Dwarf<R> { } /// Parse the abbreviations for a compilation unit. - // TODO: provide caching of abbreviations #[inline] - pub fn abbreviations(&self, unit: &UnitHeader<R>) -> Result<Abbreviations> { - unit.abbreviations(&self.debug_abbrev) + pub fn abbreviations(&self, unit: &UnitHeader<R>) -> Result<Arc<Abbreviations>> { + self.abbreviations_cache + .get(&self.debug_abbrev, unit.debug_abbrev_offset()) } /// Return the string offset at the given index. @@ -783,6 +788,7 @@ impl<R: Reader> DwarfPackage<R> { 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<R, Offset>, /// The parsed abbreviations for the unit. - pub abbreviations: Abbreviations, + pub abbreviations: Arc<Abbreviations>, /// The `DW_AT_name` attribute of the unit. pub name: Option<R>, @@ -833,7 +839,7 @@ impl<R: Reader> Unit<R> { /// Construct a new `Unit` from the given unit header. #[inline] pub fn new(dwarf: &Dwarf<R>, header: UnitHeader<R>) -> Result<Self> { - let abbreviations = header.abbreviations(&dwarf.debug_abbrev)?; + let abbreviations = dwarf.abbreviations(&header)?; let mut unit = Unit { abbreviations, name: None, |