Struct backtrace::Symbol

source ·
pub struct Symbol { /* private fields */ }
Expand description

A trait representing the resolution of a symbol in a file.

This trait is yielded as a trait object to the closure given to the backtrace::resolve function, and it is virtually dispatched as it’s unknown which implementation is behind it.

A symbol can give contextual information about a function, for example the name, filename, line number, precise address, etc. Not all information is always available in a symbol, however, so all methods return an Option.

Implementations§

source§

impl Symbol

source

pub fn name(&self) -> Option<SymbolName<'_>>

Returns the name of this function.

The returned structure can be used to query various properties about the symbol name:

  • The Display implementation will print out the demangled symbol.
  • The raw str value of the symbol can be accessed (if it’s valid utf-8).
  • The raw bytes for the symbol name can be accessed.
source

pub fn addr(&self) -> Option<*mut c_void>

Returns the starting address of this function.

source

pub fn filename_raw(&self) -> Option<BytesOrWideString<'_>>

Returns the raw filename as a slice. This is mainly useful for no_std environments.

source

pub fn colno(&self) -> Option<u32>

Returns the column number for where this symbol is currently executing.

Only gimli currently provides a value here and even then only if filename returns Some, and so it is then consequently subject to similar caveats.

source

pub fn lineno(&self) -> Option<u32>

Returns the line number for where this symbol is currently executing.

This return value is typically Some if filename returns Some, and is consequently subject to similar caveats.

source

pub fn filename(&self) -> Option<&Path>

Returns the file name where this function was defined.

This is currently only available when libbacktrace or gimli is being used (e.g. unix platforms other) and when a binary is compiled with debuginfo. If neither of these conditions is met then this will likely return None.

Required features

This function requires the std feature of the backtrace crate to be enabled, and the std feature is enabled by default.

Trait Implementations§

source§

impl Debug for Symbol

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Symbol

§

impl !Send for Symbol

§

impl !Sync for Symbol

§

impl Unpin for Symbol

§

impl UnwindSafe for Symbol

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.