Skip to main content

UnitRef

Struct UnitRef 

Source
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>

Source

pub fn new(dwarf: &'a Dwarf<R>, unit: &'a Unit<R>) -> Self

Construct a new UnitRef from a Dwarf and a Unit.

Source

pub fn string_offset( &self, index: DebugStrOffsetsIndex<R::Offset>, ) -> Result<DebugStrOffset<R::Offset>>

Return the string offset at the given index.

Source

pub fn string(&self, offset: DebugStrOffset<R::Offset>) -> Result<R>

Return the string at the given offset in .debug_str.

Source

pub fn line_string(&self, offset: DebugLineStrOffset<R::Offset>) -> Result<R>

Return the string at the given offset in .debug_line_str.

Source

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.

Source

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.

Source

pub fn address(&self, index: DebugAddrIndex<R::Offset>) -> Result<u64>

Return the address at the given index.

Source

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.

Source

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.

Source

pub fn ranges_offset( &self, index: DebugRngListsIndex<R::Offset>, ) -> Result<RangeListsOffset<R::Offset>>

Return the range list offset at the given index.

Source

pub fn ranges( &self, offset: RangeListsOffset<R::Offset>, ) -> Result<RngListIter<R>>

Iterate over the RangeListEntrys starting at the given offset.

Source

pub fn raw_ranges( &self, offset: RangeListsOffset<R::Offset>, ) -> Result<RawRngListIter<R>>

Iterate over the RawRngListEntryies starting at the given offset.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn locations_offset( &self, index: DebugLocListsIndex<R::Offset>, ) -> Result<LocationListsOffset<R::Offset>>

Return the location list offset at the given index.

Source

pub fn locations( &self, offset: LocationListsOffset<R::Offset>, ) -> Result<LocListIter<R>>

Iterate over the LocationListEntrys starting at the given offset.

Source

pub fn raw_locations( &self, offset: LocationListsOffset<R::Offset>, ) -> Result<RawLocListIter<R>>

Iterate over the raw LocationListEntrys starting at the given offset.

Source

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.

Source

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.

Source

pub fn macinfo( &self, offset: DebugMacinfoOffset<R::Offset>, ) -> Result<MacroIter<R>>

Try to return an iterator for the list of macros at the given .debug_macinfo offset.

Source

pub fn macros( &self, offset: DebugMacroOffset<R::Offset>, ) -> Result<MacroIter<R>>

Try to return an iterator for the list of macros at the given .debug_macro offset.

Methods from Deref<Target = &'a Unit<R>>§

Source

pub fn unit_ref<'a>(&'a self, dwarf: &'a Dwarf<R>) -> UnitRef<'a, R>

Return a reference to this unit and its associated Dwarf.

Source

pub fn encoding(&self) -> Encoding

Return the encoding parameters for this unit.

Source

pub fn entry( &self, offset: UnitOffset<R::Offset>, ) -> Result<DebuggingInformationEntry<R>>

Read the DebuggingInformationEntry at the given offset.

Source

pub fn entries(&self) -> EntriesCursor<'_, R>

Navigate this unit’s DebuggingInformationEntrys.

Source

pub fn entries_at_offset( &self, offset: UnitOffset<R::Offset>, ) -> Result<EntriesCursor<'_, R>>

Navigate this unit’s DebuggingInformationEntrys starting at the given offset.

Source

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.

Source

pub fn entries_raw( &self, offset: Option<UnitOffset<R::Offset>>, ) -> Result<EntriesRaw<'_, R>>

Read the raw data that defines the Debugging Information Entries.

Source

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>>§

Source

pub fn section(&self) -> SectionId

Get the ID of the section containing this unit.

Source

pub fn offset(&self) -> UnitSectionOffset<Offset>

Get the offset of this unit within its section.

Source

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.

Source

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.

Source

pub fn size_of_header(&self) -> usize

Return the serialized size of the common unit header for the given DWARF format.

Source

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.

Source

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.

Source

pub fn encoding(&self) -> Encoding

Return the encoding parameters for this unit.

Source

pub fn version(&self) -> u16

Get the DWARF version of the debugging info for this compilation unit.

Source

pub fn type_(&self) -> UnitType<Offset>

Get the UnitType of this unit.

Source

pub fn debug_abbrev_offset(&self) -> DebugAbbrevOffset<Offset>

The offset into the .debug_abbrev section for this compilation unit’s debugging information entries’ abbreviations.

Source

pub fn address_size(&self) -> u8

The size of addresses (in bytes) in this compilation unit.

Source

pub fn format(&self) -> Format

Whether this compilation unit is encoded in 64- or 32-bit DWARF.

Source

pub fn header_size(&self) -> Offset

The serialized size of the header for this compilation unit.

Source

pub fn root_offset(&self) -> UnitOffset<Offset>

The unit offset of the root entry.

Source

pub fn range(&self, idx: Range<UnitOffset<Offset>>) -> Result<R>

Get the underlying bytes for the supplied range.

Source

pub fn range_from(&self, idx: RangeFrom<UnitOffset<Offset>>) -> Result<R>

Get the underlying bytes for the supplied range.

Source

pub fn range_to(&self, idx: RangeTo<UnitOffset<Offset>>) -> Result<R>

Get the underlying bytes for the supplied range.

Source

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.

Source

pub fn entries<'abbrev>( &self, abbreviations: &'abbrev Abbreviations, ) -> EntriesCursor<'abbrev, R>

Navigate this unit’s DebuggingInformationEntrys.

Source

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.

Source

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.

Source

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.

Source

pub fn abbreviations( &self, debug_abbrev: &DebugAbbrev<R>, ) -> Result<Abbreviations>

Parse this unit’s abbreviations.

Source

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.

Trait Implementations§

Source§

impl<'a, R: Reader> Clone for UnitRef<'a, R>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, R: Debug + Reader> Debug for UnitRef<'a, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a, R: Reader> Deref for UnitRef<'a, R>

Source§

type Target = &'a Unit<R>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, R: Reader> Copy for UnitRef<'a, R>

Auto Trait Implementations§

§

impl<'a, R> Freeze for UnitRef<'a, R>

§

impl<'a, R> RefUnwindSafe for UnitRef<'a, R>

§

impl<'a, R> Send for UnitRef<'a, R>
where R: Sync + Send, <R as Reader>::Offset: Sync,

§

impl<'a, R> Sync for UnitRef<'a, R>
where R: Sync + Send, <R as Reader>::Offset: Sync,

§

impl<'a, R> Unpin for UnitRef<'a, R>

§

impl<'a, R> UnsafeUnpin for UnitRef<'a, R>

§

impl<'a, R> UnwindSafe for UnitRef<'a, R>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.