Struct gimli::read::unit::DebuggingInformationEntry

source ·
pub struct DebuggingInformationEntry<'abbrev, 'unit, R, Offset = <R as Reader>::Offset>
where R: Reader<Offset = Offset>, Offset: ReaderOffset,
{ offset: UnitOffset<Offset>, attrs_slice: R, attrs_len: Cell<Option<Offset>>, abbrev: &'abbrev Abbreviation, unit: &'unit UnitHeader<R, Offset>, }
Expand description

A Debugging Information Entry (DIE).

DIEs have a set of attributes and optionally have children DIEs as well.

Fields§

§offset: UnitOffset<Offset>§attrs_slice: R§attrs_len: Cell<Option<Offset>>§abbrev: &'abbrev Abbreviation§unit: &'unit UnitHeader<R, Offset>

Implementations§

source§

impl<'abbrev, 'unit, R, Offset> DebuggingInformationEntry<'abbrev, 'unit, R, Offset>
where R: Reader<Offset = Offset>, Offset: ReaderOffset,

source

pub fn new( offset: UnitOffset<Offset>, attrs_slice: R, abbrev: &'abbrev Abbreviation, unit: &'unit UnitHeader<R, Offset>, ) -> Self

Construct a new DebuggingInformationEntry.

source

pub fn code(&self) -> u64

Get this entry’s code.

source

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

Get this entry’s offset.

source

pub fn tag(&self) -> DwTag

Get this entry’s DW_TAG_whatever tag.

let entry = get_some_entry();

match entry.tag() {
    gimli::DW_TAG_subprogram =>
        println!("this entry contains debug info about a function"),
    gimli::DW_TAG_inlined_subroutine =>
        println!("this entry contains debug info about a particular instance of inlining"),
    gimli::DW_TAG_variable =>
        println!("this entry contains debug info about a local variable"),
    gimli::DW_TAG_formal_parameter =>
        println!("this entry contains debug info about a function parameter"),
    otherwise =>
        println!("this entry is some other kind of data: {:?}", otherwise),
};
source

pub fn has_children(&self) -> bool

Return true if this entry’s type can have children, false otherwise.

source

pub fn attrs<'me>(&'me self) -> AttrsIter<'abbrev, 'me, 'unit, R>

Iterate over this entry’s set of attributes.

use gimli::{DebugAbbrev, DebugInfo, LittleEndian};

// Read the `.debug_info` section.

let debug_info = DebugInfo::new(read_debug_info_section_somehow(), LittleEndian);

// Get the data about the first compilation unit out of the `.debug_info`.

let unit = debug_info.units().next()
    .expect("Should have at least one compilation unit")
    .expect("and it should parse ok");

// Read the `.debug_abbrev` section and parse the
// abbreviations for our compilation unit.

let debug_abbrev = DebugAbbrev::new(read_debug_abbrev_section_somehow(), LittleEndian);
let abbrevs = unit.abbreviations(&debug_abbrev).unwrap();

// Get the first entry from that compilation unit.

let mut cursor = unit.entries(&abbrevs);
let (_, entry) = cursor.next_dfs()
    .expect("Should parse next entry")
    .expect("Should have at least one entry");

// Finally, print the first entry's attributes.

let mut attrs = entry.attrs();
while let Some(attr) = attrs.next().unwrap() {
    println!("Attribute name = {:?}", attr.name());
    println!("Attribute value = {:?}", attr.value());
}

Can be used with FallibleIterator.

source

pub fn attr(&self, name: DwAt) -> Result<Option<Attribute<R>>>

Find the first attribute in this entry which has the given name, and return it. Returns Ok(None) if no attribute is found.

source

pub fn attr_value_raw(&self, name: DwAt) -> Result<Option<AttributeValue<R>>>

Find the first attribute in this entry which has the given name, and return its raw value. Returns Ok(None) if no attribute is found.

source

pub fn attr_value(&self, name: DwAt) -> Result<Option<AttributeValue<R>>>

Find the first attribute in this entry which has the given name, and return its normalized value. Returns Ok(None) if no attribute is found.

source

fn after_attrs(&self) -> Result<R>

Return the input buffer after the last attribute.

source

fn sibling(&self) -> Option<R>

Use the DW_AT_sibling attribute to find the input buffer for the next sibling. Returns None if the attribute is missing or invalid.

source

fn parse( input: &mut R, unit: &'unit UnitHeader<R>, abbreviations: &'abbrev Abbreviations, ) -> Result<Option<Self>>

Parse an entry. Returns Ok(None) for null entries.

Trait Implementations§

source§

impl<'abbrev, 'unit, R, Offset> Clone for DebuggingInformationEntry<'abbrev, 'unit, R, Offset>
where R: Reader<Offset = Offset> + Clone, Offset: ReaderOffset + Clone,

source§

fn clone(&self) -> DebuggingInformationEntry<'abbrev, 'unit, R, Offset>

Returns a copy 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<'abbrev, 'unit, R, Offset> Debug for DebuggingInformationEntry<'abbrev, '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

Auto Trait Implementations§

§

impl<'abbrev, 'unit, R, Offset = <R as Reader>::Offset> !Freeze for DebuggingInformationEntry<'abbrev, 'unit, R, Offset>

§

impl<'abbrev, 'unit, R, Offset = <R as Reader>::Offset> !RefUnwindSafe for DebuggingInformationEntry<'abbrev, 'unit, R, Offset>

§

impl<'abbrev, 'unit, R, Offset> Send for DebuggingInformationEntry<'abbrev, 'unit, R, Offset>
where R: Send + Sync, Offset: Send + Sync,

§

impl<'abbrev, 'unit, R, Offset = <R as Reader>::Offset> !Sync for DebuggingInformationEntry<'abbrev, 'unit, R, Offset>

§

impl<'abbrev, 'unit, R, Offset> Unpin for DebuggingInformationEntry<'abbrev, 'unit, R, Offset>
where R: Unpin, Offset: Unpin,

§

impl<'abbrev, 'unit, R, Offset> UnwindSafe for DebuggingInformationEntry<'abbrev, 'unit, R, Offset>

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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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<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.