backtracer_core

Crates.iobacktracer_core
lib.rsbacktracer_core
version0.0.7
sourcesrc
created_at2021-04-06 21:57:16.837613
updated_at2022-10-21 17:13:43.988306
descriptionA library to acquire a stack trace (backtrace) at runtime in a no-std Rust program.
homepagehttps://github.com/gz/backtracer
repositoryhttps://github.com/gz/backtracer
max_upload_size
id380033
size34,879
Gerd Zellweger (gz)

documentation

https://docs.rs/backtracer

README

backtracer

A library for acquiring backtraces at runtime for Rust no-std environments. If you are not in a no-std environment, you probably want to use https://github.com/alexcrichton/backtrace-rs instead.

Install

[dependencies]
backtracer = "0.0.1"
extern crate backtracer;

Usage

Use the trace and resolve functions directly.

extern crate backtracer;

fn main() {
    backtracer::trace(|frame| {
        let ip = frame.ip();
        let symbol_address = frame.symbol_address();

        // Resolve this instruction pointer to a symbol name
        backtracer::resolve(ip, |symbol| {
            if let Some(name) = symbol.name() {
                // ...
            }
            if let Some(filename) = symbol.filename() {
                // ...
            }
        });

        true // keep going to the next frame
    });
}

Platform Support

This should work on any platform with minimal implementation effort.

Commit count: 325

cargo fmt