GithubHelp home page GithubHelp logo

syrusakbary / backtrace-rs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rust-lang/backtrace-rs

1.0 2.0 0.0 1.08 MB

Backtraces in Rust

Home Page: https://docs.rs/backtrace

License: Apache License 2.0

Rust 96.31% C++ 0.10% Shell 1.40% Dockerfile 2.06% C 0.13%

backtrace-rs's Introduction

backtrace-rs

Documentation

A library for acquiring backtraces at runtime for Rust. This library aims to enhance the support of the standard library by providing a programmatic interface to work with, but it also supports simply easily printing the current backtrace like libstd's panics.

Install

[dependencies]
backtrace = "0.3"

Usage

To simply capture a backtrace and defer dealing with it until a later time, you can use the top-level Backtrace type.

use backtrace::Backtrace;

fn main() {
    let bt = Backtrace::new();

    // do_some_work();

    println!("{:?}", bt);
}

If, however, you'd like more raw access to the actual tracing functionality, you can use the trace and resolve functions directly.

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

        // Resolve this instruction pointer to a symbol name
        backtrace::resolve_frame(frame, |symbol| {
            if let Some(name) = symbol.name() {
                // ...
            }
            if let Some(filename) = symbol.filename() {
                // ...
            }
        });

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

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in backtrace-rs by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

backtrace-rs's People

Contributors

aaron1011 avatar alexcrichton avatar aloucks avatar azriel91 avatar baoshanpang avatar bpangwr avatar bugadani avatar cramertj avatar cuviper avatar dependabot-support avatar fitzgen avatar jchlapinski avatar jdm avatar kali avatar keruspe avatar king6cong avatar leo60228 avatar malbarbo avatar mark-simulacrum avatar mitsuhiko avatar nhynes avatar nielx avatar philipc avatar plauche avatar ralfjung avatar sfackler avatar tesuji avatar tkilbourn avatar tomcc avatar uweigand avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.