Skip to main content

Unit

Struct Unit 

Source
pub struct Unit<R, Offset = <R as Reader>::Offset>
where R: Reader<Offset = Offset>, Offset: ReaderOffset,
{ pub header: UnitHeader<R, Offset>, pub abbreviations: Arc<Abbreviations>, pub name: Option<R>, pub comp_dir: Option<R>, pub low_pc: u64, pub str_offsets_base: DebugStrOffsetsBase<Offset>, pub addr_base: DebugAddrBase<Offset>, pub loclists_base: DebugLocListsBase<Offset>, pub rnglists_base: DebugRngListsBase<Offset>, pub line_program: Option<IncompleteLineProgram<R, Offset>>, pub dwo_id: Option<DwoId>, }
Expand description

All of the commonly used information for a unit in the .debug_info or .debug_types sections.

Fields§

§header: UnitHeader<R, Offset>

The header of the unit.

§abbreviations: Arc<Abbreviations>

The parsed abbreviations for the unit.

§name: Option<R>

The DW_AT_name attribute of the unit.

§comp_dir: Option<R>

The DW_AT_comp_dir attribute of the unit.

§low_pc: u64

The DW_AT_low_pc attribute of the unit. Defaults to 0.

§str_offsets_base: DebugStrOffsetsBase<Offset>

The DW_AT_str_offsets_base attribute of the unit. Defaults to 0.

§addr_base: DebugAddrBase<Offset>

The DW_AT_addr_base attribute of the unit. Defaults to 0.

§loclists_base: DebugLocListsBase<Offset>

The DW_AT_loclists_base attribute of the unit. Defaults to 0.

§rnglists_base: DebugRngListsBase<Offset>

The DW_AT_rnglists_base attribute of the unit. Defaults to 0.

§line_program: Option<IncompleteLineProgram<R, Offset>>

The line number program of the unit.

§dwo_id: Option<DwoId>

The DWO ID of a skeleton unit or split compilation unit.

Implementations§

Source§

impl<R: Reader> Unit<R>

Source

pub fn new(dwarf: &Dwarf<R>, header: UnitHeader<R>) -> Result<Self>

Construct a new Unit from the given unit header.

Source

pub fn new_with_abbreviations( dwarf: &Dwarf<R>, header: UnitHeader<R>, abbreviations: Arc<Abbreviations>, ) -> Result<Self>

Construct a new Unit from the given unit header and abbreviations.

The abbreviations for this call can be obtained using dwarf.abbreviations(&header). The caller may implement caching to reuse the Abbreviations across units with the same header.debug_abbrev_offset() value.

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 copy_relocated_attributes(&mut self, other: &Unit<R>)

Copy attributes that are subject to relocation from another unit. This is intended to be used to copy attributes from a skeleton compilation unit to the corresponding split compilation unit.

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<R, Offset> Debug for Unit<R, Offset>
where R: Reader<Offset = Offset> + Debug, Offset: ReaderOffset + Debug,

Source§

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

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

impl<R: Reader> Deref for Unit<R>

Source§

type Target = UnitHeader<R>

The resulting type after dereferencing.
Source§

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

Dereferences the value.

Auto Trait Implementations§

§

impl<R, Offset> Freeze for Unit<R, Offset>
where Offset: Freeze, R: Freeze,

§

impl<R, Offset> RefUnwindSafe for Unit<R, Offset>
where Offset: RefUnwindSafe, R: RefUnwindSafe,

§

impl<R, Offset> Send for Unit<R, Offset>
where Offset: Send, R: Send,

§

impl<R, Offset> Sync for Unit<R, Offset>
where Offset: Sync, R: Sync,

§

impl<R, Offset> Unpin for Unit<R, Offset>
where Offset: Unpin, R: Unpin,

§

impl<R, Offset> UnsafeUnpin for Unit<R, Offset>
where Offset: UnsafeUnpin, R: UnsafeUnpin,

§

impl<R, Offset> UnwindSafe for Unit<R, Offset>
where Offset: UnwindSafe, R: UnwindSafe,

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> 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, 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.