pub struct UnitRef<'a, R: Reader> {
pub dwarf: &'a Dwarf<R>,
pub unit: &'a Unit<R>,
}Expand description
A reference to a Unit and its associated Dwarf.
These often need to be passed around together, so this struct makes that easier.
It implements Deref to &'a Unit, so you can use it as if it were a Unit.
It also implements methods that correspond to methods on Dwarf that take a Unit.
Fields§
§dwarf: &'a Dwarf<R>The Dwarf that contains the unit.
unit: &'a Unit<R>The Unit being referenced.
Implementations§
Source§impl<'a, R: Reader> UnitRef<'a, R>
impl<'a, R: Reader> UnitRef<'a, R>
Sourcepub fn new(dwarf: &'a Dwarf<R>, unit: &'a Unit<R>) -> Self
pub fn new(dwarf: &'a Dwarf<R>, unit: &'a Unit<R>) -> Self
Construct a new UnitRef from a Dwarf and a Unit.
Sourcepub fn string_offset(
&self,
index: DebugStrOffsetsIndex<R::Offset>,
) -> Result<DebugStrOffset<R::Offset>>
pub fn string_offset( &self, index: DebugStrOffsetsIndex<R::Offset>, ) -> Result<DebugStrOffset<R::Offset>>
Return the string offset at the given index.
Sourcepub fn string(&self, offset: DebugStrOffset<R::Offset>) -> Result<R>
pub fn string(&self, offset: DebugStrOffset<R::Offset>) -> Result<R>
Return the string at the given offset in .debug_str.
Sourcepub fn line_string(&self, offset: DebugLineStrOffset<R::Offset>) -> Result<R>
pub fn line_string(&self, offset: DebugLineStrOffset<R::Offset>) -> Result<R>
Return the string at the given offset in .debug_line_str.
Sourcepub fn sup_string(&self, offset: DebugStrOffset<R::Offset>) -> Result<R>
pub fn sup_string(&self, offset: DebugStrOffset<R::Offset>) -> Result<R>
Return the string at the given offset in the .debug_str
in the supplementary object file.
Sourcepub fn attr_string(&self, attr: AttributeValue<R>) -> Result<R>
pub fn attr_string(&self, attr: AttributeValue<R>) -> Result<R>
Return an attribute value as a string slice.
See Dwarf::attr_string for more information.
Sourcepub fn address(&self, index: DebugAddrIndex<R::Offset>) -> Result<u64>
pub fn address(&self, index: DebugAddrIndex<R::Offset>) -> Result<u64>
Return the address at the given index.
Sourcepub fn attr_address(&self, attr: AttributeValue<R>) -> Result<Option<u64>>
pub fn attr_address(&self, attr: AttributeValue<R>) -> Result<Option<u64>>
Try to return an attribute value as an address.
See Dwarf::attr_address for more information.
Sourcepub fn ranges_offset_from_raw(
&self,
offset: RawRangeListsOffset<R::Offset>,
) -> RangeListsOffset<R::Offset>
pub fn ranges_offset_from_raw( &self, offset: RawRangeListsOffset<R::Offset>, ) -> RangeListsOffset<R::Offset>
Return the range list offset for the given raw offset.
This handles adding DW_AT_GNU_ranges_base if required.
Sourcepub fn ranges_offset(
&self,
index: DebugRngListsIndex<R::Offset>,
) -> Result<RangeListsOffset<R::Offset>>
pub fn ranges_offset( &self, index: DebugRngListsIndex<R::Offset>, ) -> Result<RangeListsOffset<R::Offset>>
Return the range list offset at the given index.
Sourcepub fn ranges(
&self,
offset: RangeListsOffset<R::Offset>,
) -> Result<RngListIter<R>>
pub fn ranges( &self, offset: RangeListsOffset<R::Offset>, ) -> Result<RngListIter<R>>
Iterate over the RangeListEntrys starting at the given offset.
Sourcepub fn raw_ranges(
&self,
offset: RangeListsOffset<R::Offset>,
) -> Result<RawRngListIter<R>>
pub fn raw_ranges( &self, offset: RangeListsOffset<R::Offset>, ) -> Result<RawRngListIter<R>>
Iterate over the RawRngListEntryies starting at the given offset.
Sourcepub fn attr_ranges_offset(
&self,
attr: AttributeValue<R>,
) -> Result<Option<RangeListsOffset<R::Offset>>>
pub fn attr_ranges_offset( &self, attr: AttributeValue<R>, ) -> Result<Option<RangeListsOffset<R::Offset>>>
Try to return an attribute value as a range list offset.
See Dwarf::attr_ranges_offset for more information.
Sourcepub fn attr_ranges(
&self,
attr: AttributeValue<R>,
) -> Result<Option<RngListIter<R>>>
pub fn attr_ranges( &self, attr: AttributeValue<R>, ) -> Result<Option<RngListIter<R>>>
Try to return an attribute value as a range list entry iterator.
See Dwarf::attr_ranges for more information.
Sourcepub fn die_ranges(
&self,
entry: &DebuggingInformationEntry<R>,
) -> Result<RangeIter<R>>
pub fn die_ranges( &self, entry: &DebuggingInformationEntry<R>, ) -> Result<RangeIter<R>>
Return an iterator for the address ranges of a DebuggingInformationEntry.
This uses DW_AT_low_pc, DW_AT_high_pc and DW_AT_ranges.
Sourcepub fn unit_ranges(&self) -> Result<RangeIter<R>>
pub fn unit_ranges(&self) -> Result<RangeIter<R>>
Return an iterator for the address ranges of the Unit.
This uses DW_AT_low_pc, DW_AT_high_pc and DW_AT_ranges of the
root DebuggingInformationEntry.
Sourcepub fn locations_offset(
&self,
index: DebugLocListsIndex<R::Offset>,
) -> Result<LocationListsOffset<R::Offset>>
pub fn locations_offset( &self, index: DebugLocListsIndex<R::Offset>, ) -> Result<LocationListsOffset<R::Offset>>
Return the location list offset at the given index.
Sourcepub fn locations(
&self,
offset: LocationListsOffset<R::Offset>,
) -> Result<LocListIter<R>>
pub fn locations( &self, offset: LocationListsOffset<R::Offset>, ) -> Result<LocListIter<R>>
Iterate over the LocationListEntrys starting at the given offset.
Sourcepub fn raw_locations(
&self,
offset: LocationListsOffset<R::Offset>,
) -> Result<RawLocListIter<R>>
pub fn raw_locations( &self, offset: LocationListsOffset<R::Offset>, ) -> Result<RawLocListIter<R>>
Iterate over the raw LocationListEntrys starting at the given offset.
Sourcepub fn attr_locations_offset(
&self,
attr: AttributeValue<R>,
) -> Result<Option<LocationListsOffset<R::Offset>>>
pub fn attr_locations_offset( &self, attr: AttributeValue<R>, ) -> Result<Option<LocationListsOffset<R::Offset>>>
Try to return an attribute value as a location list offset.
See Dwarf::attr_locations_offset for more information.
Sourcepub fn attr_locations(
&self,
attr: AttributeValue<R>,
) -> Result<Option<LocListIter<R>>>
pub fn attr_locations( &self, attr: AttributeValue<R>, ) -> Result<Option<LocListIter<R>>>
Try to return an attribute value as a location list entry iterator.
See Dwarf::attr_locations for more information.
Methods from Deref<Target = &'a Unit<R>>§
Sourcepub fn unit_ref<'a>(&'a self, dwarf: &'a Dwarf<R>) -> UnitRef<'a, R>
pub fn unit_ref<'a>(&'a self, dwarf: &'a Dwarf<R>) -> UnitRef<'a, R>
Return a reference to this unit and its associated Dwarf.
Sourcepub fn entry(
&self,
offset: UnitOffset<R::Offset>,
) -> Result<DebuggingInformationEntry<R>>
pub fn entry( &self, offset: UnitOffset<R::Offset>, ) -> Result<DebuggingInformationEntry<R>>
Read the DebuggingInformationEntry at the given offset.
Sourcepub fn entries(&self) -> EntriesCursor<'_, R>
pub fn entries(&self) -> EntriesCursor<'_, R>
Navigate this unit’s DebuggingInformationEntrys.
Sourcepub fn entries_at_offset(
&self,
offset: UnitOffset<R::Offset>,
) -> Result<EntriesCursor<'_, R>>
pub fn entries_at_offset( &self, offset: UnitOffset<R::Offset>, ) -> Result<EntriesCursor<'_, R>>
Navigate this unit’s DebuggingInformationEntrys
starting at the given offset.
Sourcepub fn entries_tree(
&self,
offset: Option<UnitOffset<R::Offset>>,
) -> Result<EntriesTree<'_, R>>
pub fn entries_tree( &self, offset: Option<UnitOffset<R::Offset>>, ) -> Result<EntriesTree<'_, R>>
Navigate this unit’s DebuggingInformationEntrys as a tree
starting at the given offset.
Sourcepub fn entries_raw(
&self,
offset: Option<UnitOffset<R::Offset>>,
) -> Result<EntriesRaw<'_, R>>
pub fn entries_raw( &self, offset: Option<UnitOffset<R::Offset>>, ) -> Result<EntriesRaw<'_, R>>
Read the raw data that defines the Debugging Information Entries.
Sourcepub fn dwo_name(&self) -> Result<Option<AttributeValue<R>>>
pub fn dwo_name(&self) -> Result<Option<AttributeValue<R>>>
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.
Methods from Deref<Target = UnitHeader<R>>§
Sourcepub fn offset(&self) -> UnitSectionOffset<Offset>
pub fn offset(&self) -> UnitSectionOffset<Offset>
Get the offset of this unit within its section.
Sourcepub fn debug_info_offset(&self) -> Option<DebugInfoOffset<Offset>>
pub fn debug_info_offset(&self) -> Option<DebugInfoOffset<Offset>>
Get the offset of this unit as an offset within the .debug_info section.
Returns None if this unit is not in the .debug_info section.
Sourcepub fn debug_types_offset(&self) -> Option<DebugTypesOffset<Offset>>
pub fn debug_types_offset(&self) -> Option<DebugTypesOffset<Offset>>
Get the offset of this unit as an offset within the .debug_types section.
Returns None if this unit is not in the .debug_types section.
Sourcepub fn size_of_header(&self) -> usize
pub fn size_of_header(&self) -> usize
Return the serialized size of the common unit header for the given DWARF format.
Sourcepub fn unit_length(&self) -> Offset
pub fn unit_length(&self) -> Offset
Get the length of the debugging info for this compilation unit, not including the byte length of the encoded length itself.
Sourcepub fn length_including_self(&self) -> Offset
pub fn length_including_self(&self) -> Offset
Get the length of the debugging info for this compilation unit, including the byte length of the encoded length itself.
Sourcepub fn version(&self) -> u16
pub fn version(&self) -> u16
Get the DWARF version of the debugging info for this compilation unit.
Sourcepub fn debug_abbrev_offset(&self) -> DebugAbbrevOffset<Offset>
pub fn debug_abbrev_offset(&self) -> DebugAbbrevOffset<Offset>
The offset into the .debug_abbrev section for this compilation unit’s
debugging information entries’ abbreviations.
Sourcepub fn address_size(&self) -> u8
pub fn address_size(&self) -> u8
The size of addresses (in bytes) in this compilation unit.
Sourcepub fn format(&self) -> Format
pub fn format(&self) -> Format
Whether this compilation unit is encoded in 64- or 32-bit DWARF.
Sourcepub fn header_size(&self) -> Offset
pub fn header_size(&self) -> Offset
The serialized size of the header for this compilation unit.
Sourcepub fn root_offset(&self) -> UnitOffset<Offset>
pub fn root_offset(&self) -> UnitOffset<Offset>
The unit offset of the root entry.
Sourcepub fn range(&self, idx: Range<UnitOffset<Offset>>) -> Result<R>
pub fn range(&self, idx: Range<UnitOffset<Offset>>) -> Result<R>
Get the underlying bytes for the supplied range.
Sourcepub fn range_from(&self, idx: RangeFrom<UnitOffset<Offset>>) -> Result<R>
pub fn range_from(&self, idx: RangeFrom<UnitOffset<Offset>>) -> Result<R>
Get the underlying bytes for the supplied range.
Sourcepub fn range_to(&self, idx: RangeTo<UnitOffset<Offset>>) -> Result<R>
pub fn range_to(&self, idx: RangeTo<UnitOffset<Offset>>) -> Result<R>
Get the underlying bytes for the supplied range.
Sourcepub fn entry<'abbrev>(
&self,
abbreviations: &'abbrev Abbreviations,
offset: UnitOffset<Offset>,
) -> Result<DebuggingInformationEntry<R>>
pub fn entry<'abbrev>( &self, abbreviations: &'abbrev Abbreviations, offset: UnitOffset<Offset>, ) -> Result<DebuggingInformationEntry<R>>
Read the DebuggingInformationEntry at the given offset.
Creating a DebuggingInformationEntry requires an allocation, so frequent use of
this method may be slow. Use methods such as Self::entries_at_offset to read
multiple entries where possible, or Self::entries_raw which does not allocate.
Sourcepub fn entries<'abbrev>(
&self,
abbreviations: &'abbrev Abbreviations,
) -> EntriesCursor<'abbrev, R>
pub fn entries<'abbrev>( &self, abbreviations: &'abbrev Abbreviations, ) -> EntriesCursor<'abbrev, R>
Navigate this unit’s DebuggingInformationEntrys.
Sourcepub fn entries_at_offset<'abbrev>(
&self,
abbreviations: &'abbrev Abbreviations,
offset: UnitOffset<Offset>,
) -> Result<EntriesCursor<'abbrev, R>>
pub fn entries_at_offset<'abbrev>( &self, abbreviations: &'abbrev Abbreviations, offset: UnitOffset<Offset>, ) -> Result<EntriesCursor<'abbrev, R>>
Navigate this compilation unit’s DebuggingInformationEntrys
starting at the given offset.
Sourcepub fn entries_tree<'abbrev>(
&self,
abbreviations: &'abbrev Abbreviations,
offset: Option<UnitOffset<Offset>>,
) -> Result<EntriesTree<'abbrev, R>>
pub fn entries_tree<'abbrev>( &self, abbreviations: &'abbrev Abbreviations, offset: Option<UnitOffset<Offset>>, ) -> Result<EntriesTree<'abbrev, R>>
Navigate this unit’s DebuggingInformationEntrys as a tree
starting at the given offset.
Sourcepub fn entries_raw<'abbrev>(
&self,
abbreviations: &'abbrev Abbreviations,
offset: Option<UnitOffset<Offset>>,
) -> Result<EntriesRaw<'abbrev, R>>
pub fn entries_raw<'abbrev>( &self, abbreviations: &'abbrev Abbreviations, offset: Option<UnitOffset<Offset>>, ) -> Result<EntriesRaw<'abbrev, R>>
Read the raw data that defines the Debugging Information Entries.
Sourcepub fn abbreviations(
&self,
debug_abbrev: &DebugAbbrev<R>,
) -> Result<Abbreviations>
pub fn abbreviations( &self, debug_abbrev: &DebugAbbrev<R>, ) -> Result<Abbreviations>
Parse this unit’s abbreviations.
Sourcepub fn is_tombstone_address(&self, address: u64) -> bool
pub fn is_tombstone_address(&self, address: u64) -> bool
Return true if the given address is a tombstone.
This currently checks if the address is -1 or -2 for the address size of the unit.
Note that this cannot detect the use of 0 as a tombstone since that is ambiguous. The caller must use their own knowledge of valid address ranges to determine that if required.