Giter Site home page Giter Site logo

nemo157 / 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.03 MB

Backtraces in Rust

License: Apache License 2.0

Rust 11.91% Makefile 4.19% C 41.67% M4 1.89% Awk 0.04% Shell 40.26% C++ 0.04%

backtrace-rs's Introduction

backtrace-rs

Build Status Build status

Documentation

A library for acquiring backtraces at runtime for Rust. This library aims to enhance the support given by the standard library at std::rt by providing a more stable and programmatic interface.

Install

[dependencies]
backtrace = "0.3"
extern crate backtrace;

Note that this crate requires make, objcopy, and ar to be present on Linux systems.

Usage

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

extern crate backtrace;

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.

extern crate backtrace;

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(ip, |symbol| {
            if let Some(name) = symbol.name() {
                // ...
            }
            if let Some(filename) = symbol.filename() {
                // ...
            }
        });

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

Platform Support

This library currently supports OSX, Linux, and Windows. Support for other platforms is always welcome!

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

alexcrichton avatar alusch avatar birkenfeld avatar d12i avatar eijebong avatar fitzgen avatar jarod avatar jchlapinski avatar keruspe avatar king6cong avatar kirillrdy avatar malbarbo avatar mark-simulacrum avatar mbrubeck avatar mitsuhiko avatar retep998 avatar sdemos avatar semarie avatar sfackler avatar steffengy avatar tkilbourn avatar vi avatar walfie avatar zzeroo 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.