#backtrace #run-time #stack-trace #no-std #resolve #acquire #backtracer

backtracer_core

A library to acquire a stack trace (backtrace) at runtime in a no-std Rust program

6 releases

Uses old Rust 2015

0.0.7 Oct 21, 2022
0.0.6 Oct 21, 2022
0.0.5 Apr 15, 2022
0.0.4 Aug 3, 2021
0.0.2 Apr 6, 2021

#3 in #acquire

Download history 28/week @ 2023-11-29 30/week @ 2023-12-06 3/week @ 2024-02-14 16/week @ 2024-02-21 6/week @ 2024-02-28 17/week @ 2024-03-06 10/week @ 2024-03-13

51 downloads per month

MIT/Apache

23KB
434 lines

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.


lib.rs:

A library for acquiring a backtrace at runtime

Dependencies

~4.5MB
~60K SLoC