pub struct DebugInfo<R> { /* private fields */ }
Expand description
The DebugInfo
struct represents the DWARF debugging information found in
the .debug_info
section.
Implementations§
source§impl<'input, Endian> DebugInfo<EndianSlice<'input, Endian>>where
Endian: Endianity,
impl<'input, Endian> DebugInfo<EndianSlice<'input, Endian>>where
Endian: Endianity,
sourcepub fn new(debug_info_section: &'input [u8], endian: Endian) -> Self
pub fn new(debug_info_section: &'input [u8], endian: Endian) -> Self
Construct a new DebugInfo
instance from the data in the .debug_info
section.
It is the caller’s responsibility to read the .debug_info
section and
present it as a &[u8]
slice. That means using some ELF loader on
Linux, a Mach-O loader on macOS, etc.
use gimli::{DebugInfo, LittleEndian};
let debug_info = DebugInfo::new(read_debug_info_section_somehow(), LittleEndian);
source§impl<R: Reader> DebugInfo<R>
impl<R: Reader> DebugInfo<R>
sourcepub fn units(&self) -> DebugInfoUnitHeadersIter<R>
pub fn units(&self) -> DebugInfoUnitHeadersIter<R>
Iterate the units in this .debug_info
section.
use gimli::{DebugInfo, LittleEndian};
let debug_info = DebugInfo::new(read_debug_info_section_somehow(), LittleEndian);
let mut iter = debug_info.units();
while let Some(unit) = iter.next().unwrap() {
println!("unit's length is {}", unit.unit_length());
}
Can be used with
FallibleIterator
.
sourcepub fn header_from_offset(
&self,
offset: DebugInfoOffset<R::Offset>,
) -> Result<UnitHeader<R>>
pub fn header_from_offset( &self, offset: DebugInfoOffset<R::Offset>, ) -> Result<UnitHeader<R>>
Get the UnitHeader located at offset from this .debug_info section.
source§impl<T> DebugInfo<T>
impl<T> DebugInfo<T>
sourcepub fn borrow<'a, F, R>(&'a self, borrow: F) -> DebugInfo<R>
pub fn borrow<'a, F, R>(&'a self, borrow: F) -> DebugInfo<R>
Create a DebugInfo
section that references the data in self
.
This is useful when R
implements Reader
but T
does not.
§Example Usage
// Read the DWARF section into a `Vec` with whatever object loader you're using.
let owned_section: gimli::DebugInfo<Vec<u8>> = load_section();
// Create a reference to the DWARF section.
let section = owned_section.borrow(|section| {
gimli::EndianSlice::new(§ion, gimli::LittleEndian)
});
Trait Implementations§
source§impl<R> Section<R> for DebugInfo<R>
impl<R> Section<R> for DebugInfo<R>
source§fn section_name() -> &'static str
fn section_name() -> &'static str
Returns the ELF section name for this type.
source§fn dwo_section_name() -> Option<&'static str>
fn dwo_section_name() -> Option<&'static str>
Returns the ELF section name (if any) for this type when used in a dwo
file.
source§fn xcoff_section_name() -> Option<&'static str>
fn xcoff_section_name() -> Option<&'static str>
Returns the XCOFF section name (if any) for this type when used in a XCOFF
file.
impl<R: Copy> Copy for DebugInfo<R>
Auto Trait Implementations§
impl<R> Freeze for DebugInfo<R>where
R: Freeze,
impl<R> RefUnwindSafe for DebugInfo<R>where
R: RefUnwindSafe,
impl<R> Send for DebugInfo<R>where
R: Send,
impl<R> Sync for DebugInfo<R>where
R: Sync,
impl<R> Unpin for DebugInfo<R>where
R: Unpin,
impl<R> UnwindSafe for DebugInfo<R>where
R: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more