Struct gimli::read::DwarfSections

source ·
pub struct DwarfSections<T> {
Show 13 fields pub debug_abbrev: DebugAbbrev<T>, pub debug_addr: DebugAddr<T>, pub debug_aranges: DebugAranges<T>, pub debug_info: DebugInfo<T>, pub debug_line: DebugLine<T>, pub debug_line_str: DebugLineStr<T>, pub debug_str: DebugStr<T>, pub debug_str_offsets: DebugStrOffsets<T>, pub debug_types: DebugTypes<T>, pub debug_loc: DebugLoc<T>, pub debug_loclists: DebugLocLists<T>, pub debug_ranges: DebugRanges<T>, pub debug_rnglists: DebugRngLists<T>,
}
Expand description

All of the commonly used DWARF sections.

This is useful for storing sections when T does not implement Reader. It can be used to create a Dwarf that references the data in self. If T does implement Reader, then use Dwarf directly.

§Example Usage

It can be useful to load DWARF sections into owned data structures, such as Vec. However, we do not implement the Reader trait for Vec, because it would be very inefficient, but this trait is required for all of the methods that parse the DWARF data. So we first load the DWARF sections into Vecs, and then use borrow to create Readers that reference the data.

// Read the DWARF sections into `Vec`s with whatever object loader you're using.
let dwarf_sections: gimli::DwarfSections<Vec<u8>> = gimli::DwarfSections::load(loader)?;
// Create references to the DWARF sections.
let dwarf: gimli::Dwarf<_> = dwarf_sections.borrow(|section| {
    gimli::EndianSlice::new(&section, gimli::LittleEndian)
});

Fields§

§debug_abbrev: DebugAbbrev<T>

The .debug_abbrev section.

§debug_addr: DebugAddr<T>

The .debug_addr section.

§debug_aranges: DebugAranges<T>

The .debug_aranges section.

§debug_info: DebugInfo<T>

The .debug_info section.

§debug_line: DebugLine<T>

The .debug_line section.

§debug_line_str: DebugLineStr<T>

The .debug_line_str section.

§debug_str: DebugStr<T>

The .debug_str section.

§debug_str_offsets: DebugStrOffsets<T>

The .debug_str_offsets section.

§debug_types: DebugTypes<T>

The .debug_types section.

§debug_loc: DebugLoc<T>

The .debug_loc section.

§debug_loclists: DebugLocLists<T>

The .debug_loclists section.

§debug_ranges: DebugRanges<T>

The .debug_ranges section.

§debug_rnglists: DebugRngLists<T>

The .debug_rnglists section.

Implementations§

source§

impl<T> DwarfSections<T>

source

pub fn load<F, E>(section: F) -> Result<Self, E>
where F: FnMut(SectionId) -> Result<T, E>,

Try to load the DWARF sections using the given loader function.

section loads a DWARF section from the object file. It should return an empty section if the section does not exist.

source

pub fn borrow<'a, F, R>(&'a self, borrow: F) -> Dwarf<R>
where F: FnMut(&'a T) -> R,

Create a Dwarf structure that references the data in self.

source

pub fn borrow_with_sup<'a, F, R>(&'a self, sup: &'a Self, borrow: F) -> Dwarf<R>
where F: FnMut(&'a T) -> R,

Create a Dwarf structure that references the data in self and sup.

This is like borrow, but also includes the supplementary object file. This is useful when R implements Reader but T does not.

§Example Usage
// Read the DWARF sections into `Vec`s with whatever object loader you're using.
let dwarf_sections: gimli::DwarfSections<Vec<u8>> = gimli::DwarfSections::load(loader)?;
let dwarf_sup_sections: gimli::DwarfSections<Vec<u8>> = gimli::DwarfSections::load(sup_loader)?;
// Create references to the DWARF sections.
let dwarf = dwarf_sections.borrow_with_sup(&dwarf_sup_sections, |section| {
    gimli::EndianSlice::new(&section, gimli::LittleEndian)
});

Trait Implementations§

source§

impl<T: Debug> Debug for DwarfSections<T>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> Freeze for DwarfSections<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for DwarfSections<T>
where T: RefUnwindSafe,

§

impl<T> Send for DwarfSections<T>
where T: Send,

§

impl<T> Sync for DwarfSections<T>
where T: Sync,

§

impl<T> Unpin for DwarfSections<T>
where T: Unpin,

§

impl<T> UnwindSafe for DwarfSections<T>
where T: 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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.