Skip to main content

FilterUnitSection

Struct FilterUnitSection 

Source
pub struct FilterUnitSection<'a, R: Reader<Offset = usize>> { /* private fields */ }
Expand description

The state for identifying which DIEs in a .debug_info section need to be converted.

This is used to prune unneeded DIEs, and reserve IDs so that DIE references can be converted.

The user should call FilterUnitSection::read_unit and FilterUnit::read_entry to traverse all DIEs in the section. Once there are no more units, this state can be passed to Dwarf::convert_with_filter or ConvertUnit::convert_split_with_filter.

§Example

Create a filter for the DIEs in a DWARF section.

let read_dwarf = gimli::read::Dwarf::load(loader)?;
let mut filter = gimli::write::FilterUnitSection::new(&read_dwarf)?;
while let Some(mut unit) = filter.read_unit()? {
    let mut entry = unit.null_entry();
    while unit.read_entry(&mut entry)? {
        if need_entry(&entry)? {
            unit.require_entry(entry.offset);
        }
    }
}
// `filter` can now be used to filter the DIEs during a conversion.

Implementations§

Source§

impl<'a, R: Reader<Offset = usize>> FilterUnitSection<'a, R>

Source

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

Start parsing a .debug_info section.

§Example
let read_dwarf = gimli::read::Dwarf::load(loader)?;
let mut filter = gimli::write::FilterUnitSection::new(&read_dwarf)?;
Source

pub fn new_split( dwarf: &'a Dwarf<R>, skeleton_unit: UnitRef<'a, R>, ) -> ConvertResult<Self>

Start parsing the .debug_info section for a split DWARF unit.

§Example
let dwp = gimli::read::DwarfPackage::load(loader, Default::default())?;
let dwo_id = skeleton_unit.dwo_id.unwrap();
let split_dwarf = dwp.find_cu(dwo_id, skeleton_unit.dwarf)?.unwrap();
let mut filter = gimli::write::FilterUnitSection::new_split(&split_dwarf, skeleton_unit)?;
Source

pub fn read_unit(&mut self) -> ConvertResult<Option<FilterUnit<'_, R>>>

Read the next unit header and prepare to parse its DIEs.

Trait Implementations§

Source§

impl<'a, R: Debug + Reader<Offset = usize>> Debug for FilterUnitSection<'a, R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, R> Freeze for FilterUnitSection<'a, R>
where R: Freeze,

§

impl<'a, R> RefUnwindSafe for FilterUnitSection<'a, R>
where R: RefUnwindSafe,

§

impl<'a, R> Send for FilterUnitSection<'a, R>
where R: Send + Sync,

§

impl<'a, R> Sync for FilterUnitSection<'a, R>
where R: Sync + Send,

§

impl<'a, R> Unpin for FilterUnitSection<'a, R>
where R: Unpin,

§

impl<'a, R> UnsafeUnpin for FilterUnitSection<'a, R>
where R: UnsafeUnpin,

§

impl<'a, R> UnwindSafe for FilterUnitSection<'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> 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, 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.