Function get_current_unit

Source
pub fn get_current_unit<R>(dwarf: &Dwarf<R>, pc: u32) -> Result<Unit<R>, Error>
where R: Reader<Offset = usize>,
Expand description

Find a compilation unit(gimli-rs Unit) using a address.

Description:

  • dwarf - A reference to gimli-rs Dwarf struct.
  • pc - A 32 bit machine code address, which is most commonly the current program counter value.

This function will check if the given address is within range of all the compilation units in the .debug_info DWARF section. If there is only one unit in range it will return it, otherwise it will return a error.