pub struct EntriesRaw<'abbrev, R>where
R: Reader,{ /* private fields */ }Expand description
A raw reader of the data that defines the Debugging Information Entries.
EntriesRaw provides primitives to read the components of Debugging Information
Entries (DIEs). A DIE consists of an abbreviation code (read with read_abbreviation)
followed by a number of attributes (read with read_attribute).
The user must provide the control flow to read these correctly.
In particular, all attributes must always be read before reading another
abbreviation code.
Alternatively, you may call Self::read_entry to read the abbreviations and all
attributes. The attributes are stored in a Vec in the DIE, so you should try to
reuse this allocation for future calls.
EntriesRaw lacks some features of EntriesCursor, such as the ability to skip
to the next sibling DIE. However, this also allows it to optimize better, since it
does not need to perform the extra bookkeeping required to support these features,
and thus it is suitable for cases where performance is important.
§Example Usage
let unit = get_some_unit();
let abbrevs = get_abbrevs_for_unit(&unit);
let mut entries = unit.entries_raw(&abbrevs, None)?;
while !entries.is_empty() {
let abbrev = if let Some(abbrev) = entries.read_abbreviation()? {
abbrev
} else {
// Null entry with no attributes.
continue
};
match abbrev.tag() {
gimli::DW_TAG_subprogram => {
// Loop over attributes for DIEs we care about.
for spec in abbrev.attributes() {
let attr = entries.read_attribute(*spec)?;
match attr.name() {
// Handle attributes.
_ => {}
}
}
}
_ => {
// Skip attributes for DIEs we don't care about.
entries.skip_attributes(abbrev.attributes());
}
}
}Implementations§
Source§impl<'abbrev, R: Reader> EntriesRaw<'abbrev, R>
impl<'abbrev, R: Reader> EntriesRaw<'abbrev, R>
Sourcepub fn new(
input: R,
encoding: Encoding,
abbreviations: &'abbrev Abbreviations,
offset: UnitOffset<R::Offset>,
) -> Self
pub fn new( input: R, encoding: Encoding, abbreviations: &'abbrev Abbreviations, offset: UnitOffset<R::Offset>, ) -> Self
Construct a new EntriesRaw.
input may be anywhere within the entries for a unit, including partway
through an entry. It is up to the caller to know what needs to be parsed
next.
offset may be any value. It is used as the initial value returned by
Self::next_offset.
Sourcepub fn next_offset(&self) -> UnitOffset<R::Offset>
pub fn next_offset(&self) -> UnitOffset<R::Offset>
Return the unit offset at which the reader will read next.
If you want the offset of the next entry, then this must be called prior to reading the next entry.
Sourcepub fn next_depth(&self) -> isize
pub fn next_depth(&self) -> isize
Return the depth of the next entry.
This depth is updated when read_abbreviation is called, and is updated
based on null entries and the has_children field in the abbreviation.
Sourcepub fn read_entry(
&mut self,
entry: &mut DebuggingInformationEntry<R>,
) -> Result<bool>
pub fn read_entry( &mut self, entry: &mut DebuggingInformationEntry<R>, ) -> Result<bool>
Read an entry into a placeholder.
This reads the abbreviation code and all attributes. The attributes are stored in
a Vec in the entry, so you should try to reuse this entry for future calls.
Returns Ok(false) if a null entry is read. All fields in the entry will be
set appropriately for a null entry.
Returns Err if an error occurred. Some fields in the entry may be modified
depending on where the error occurred.
Sourcepub fn read_abbreviation(&mut self) -> Result<Option<&'abbrev Abbreviation>>
pub fn read_abbreviation(&mut self) -> Result<Option<&'abbrev Abbreviation>>
Read an abbreviation code and lookup the corresponding Abbreviation.
Returns Ok(None) for null entries.
Returns Err if end of input is reached, or the code is invalid.
Sourcepub fn read_attribute(
&mut self,
spec: AttributeSpecification,
) -> Result<Attribute<R>>
pub fn read_attribute( &mut self, spec: AttributeSpecification, ) -> Result<Attribute<R>>
Read an attribute.
This function is never inlined. Consider using read_attribute_inline instead
if you only call this from a small number of places.
Sourcepub fn read_attribute_inline(
&mut self,
spec: AttributeSpecification,
) -> Result<Attribute<R>>
pub fn read_attribute_inline( &mut self, spec: AttributeSpecification, ) -> Result<Attribute<R>>
Read an attribute.
Identical to read_attribute, but has the #[inline(always)] attribute.
This allows better optimisation at the cost of code size.
Sourcepub fn read_attributes(
&mut self,
specs: &[AttributeSpecification],
attrs: &mut Vec<Attribute<R>>,
) -> Result<()>
pub fn read_attributes( &mut self, specs: &[AttributeSpecification], attrs: &mut Vec<Attribute<R>>, ) -> Result<()>
Read all attributes into a Vec.
This will clear attrs before reading.
It is recommended to reuse the same Vec for multiple calls to avoid allocations.
Sourcepub fn skip_attributes(
&mut self,
specs: &[AttributeSpecification],
) -> Result<()>
pub fn skip_attributes( &mut self, specs: &[AttributeSpecification], ) -> Result<()>
Skip all the attributes of an abbreviation.
Trait Implementations§
Source§impl<'abbrev, R> Clone for EntriesRaw<'abbrev, R>
impl<'abbrev, R> Clone for EntriesRaw<'abbrev, R>
Source§fn clone(&self) -> EntriesRaw<'abbrev, R>
fn clone(&self) -> EntriesRaw<'abbrev, R>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more