diff options
Diffstat (limited to 'vendor/gimli/src/read/dwarf.rs')
-rw-r--r-- | vendor/gimli/src/read/dwarf.rs | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/vendor/gimli/src/read/dwarf.rs b/vendor/gimli/src/read/dwarf.rs index cce364c2b..bba0af3ef 100644 --- a/vendor/gimli/src/read/dwarf.rs +++ b/vendor/gimli/src/read/dwarf.rs @@ -571,6 +571,22 @@ impl<R: Reader> Dwarf<R> { } } +impl<R: Clone> Dwarf<R> { + /// Assuming `self` was loaded from a .dwo, take the appropriate + /// sections from `parent` (which contains the skeleton unit for this + /// dwo) such as `.debug_addr` and merge them into this `Dwarf`. + pub fn make_dwo(&mut self, parent: &Dwarf<R>) { + self.file_type = DwarfFileType::Dwo; + // These sections are always taken from the parent file and not the dwo. + self.debug_addr = parent.debug_addr.clone(); + // .debug_rnglists comes from the DWO, .debug_ranges comes from the + // parent file. + self.ranges + .set_debug_ranges(parent.ranges.debug_ranges().clone()); + self.sup = parent.sup.clone(); + } +} + /// The sections from a `.dwp` file. #[derive(Debug)] pub struct DwarfPackage<R: Reader> { @@ -787,7 +803,7 @@ impl<R: Reader> DwarfPackage<R> { locations: LocationLists::new(debug_loc, debug_loclists), ranges: RangeLists::new(debug_ranges, debug_rnglists), file_type: DwarfFileType::Dwo, - sup: None, + sup: parent.sup.clone(), abbreviations_cache: AbbreviationsCache::new(), }) } @@ -996,6 +1012,25 @@ impl<R: Reader> Unit<R> { self.rnglists_base = other.rnglists_base; } } + + /// Find the dwo name (if any) for this unit, automatically handling the differences + /// between the standardized DWARF 5 split DWARF format and the pre-DWARF 5 GNU + /// extension. + /// + /// The returned value is relative to this unit's `comp_dir`. + pub fn dwo_name(&self) -> Result<Option<AttributeValue<R>>> { + let mut entries = self.entries(); + if let None = entries.next_entry()? { + return Ok(None); + } + + let entry = entries.current().unwrap(); + if self.header.version() < 5 { + entry.attr_value(constants::DW_AT_GNU_dwo_name) + } else { + entry.attr_value(constants::DW_AT_dwo_name) + } + } } impl<T: ReaderOffset> UnitSectionOffset<T> { |