Struct addr2line::Context

source ·
pub struct Context<R: Reader> { /* private fields */ }
Expand description

The state necessary to perform address to line translation.

Constructing a Context is somewhat costly, so users should aim to reuse Contexts when performing lookups for many addresses in the same executable.

Implementations§

Construct a new Context from DWARF sections.

This method does not support using a supplementary object file.

Construct a new Context from an existing gimli::Dwarf object.

Find the DWARF unit corresponding to the given virtual memory address.

Find the source file and line corresponding to the given virtual memory address.

Return source file and lines for a range of addresses. For each location it also returns the address and size of the range of the underlying instructions.

Return an iterator for the function frames corresponding to the given virtual memory address.

If the probe address is not for an inline function then only one frame is returned.

If the probe address is for an inline function then the first frame corresponds to the innermost inline function. Subsequent frames contain the caller and call location, until an non-inline caller is reached.

Preload units for probe.

The iterator returns pairs of SplitDwarfLoads containing the information needed to locate and load split DWARF for probe and a matching callback to invoke once that data is available.

If this method is called, and all of the returned closures are invoked, addr2line guarantees that any future API call for the address probe will not require the loading of any split DWARF.

  const ADDRESS: u64 = 0xdeadbeef;
  ctx.preload_units(ADDRESS).for_each(|(load, callback)| {
    let dwo = do_split_dwarf_load(load);
    callback(dwo);
  });

  let frames_iter = match ctx.find_frames(ADDRESS) {
    LookupResult::Output(result) => result,
    LookupResult::Load { .. } => unreachable!("addr2line promised we wouldn't get here"),
  };

  // ...

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.