Crates.io | backtrace-rust |
lib.rs | backtrace-rust |
version | 0.1.0 |
source | src |
created_at | 2020-05-30 08:35:45.838032 |
updated_at | 2020-05-30 08:35:45.838032 |
description | A library written in Rust with no C dependency to acquire stack trace (backtrace) at runtime in a Rust program. |
homepage | https://github.com/laurentiustefan97/backtrace-rust |
repository | https://github.com/laurentiustefan97/backtrace-rust |
max_upload_size | |
id | 247637 |
size | 37,648 |
A backtrace implementation written in Rust for Linux OS (ELF binaries). This is implemented using other Rust crates such as:
Currently working only on x86-64, x86 architectures and on libc and musl-libc platforms.
Add the crate dependency in the Cargo.toml
file.
[dependencies]
backtrace-rust = "0.1"
Instantiate an object of type backtrace::Backtrace
and print it with the {:?}
format. Example:
use backtrace_rust::backtrace::Backtrace;
fn main() {
let bt = Backtrace::new();
// other code
println!("{:?}", bt);
}
There are 3 examples in the examples/
directory. Example of running:
$ cargo +nightly run --example complex_inline
0: complex_inline::tazz
at /backtrace-rust/examples/complex_inline.rs:22
1: complex_inline::taz
at /backtrace-rust/examples/complex_inline.rs:28
<complex_inline::MyStruct as complex_inline::MyTrait>::test
at /backtrace-rust/examples/complex_inline.rs:17
2: complex_inline::tar
at /backtrace-rust/examples/complex_inline.rs:34
complex_inline::bar
at /backtrace-rust/examples/complex_inline.rs:39
complex_inline::foo
at /backtrace-rust/examples/complex_inline.rs:44
complex_inline::main
at /backtrace-rust/examples/complex_inline.rs:48
3: std::rt::lang_start::{{closure}}
at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/libstd/rt.rs:67
4: std::rt::lang_start_internal::{{closure}}
at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/libstd/rt.rs:52
std::panicking::try::do_call
at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/libstd/panicking.rs:303
5: __rust_maybe_catch_panic
at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/libpanic_unwind/lib.rs:86
6: std::panicking::try
at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/libstd/panicking.rs:281
std::panic::catch_unwind
at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/libstd/panic.rs:394
std::rt::lang_start_internal
at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/libstd/rt.rs:51
7: std::rt::lang_start
at /rustc/c20d7eecbc0928b57da8fe30b2ef8528e2bdd5be/src/libstd/rt.rs:67
8: main
Rust nightly
channel for running at this moment (uses inline assembly which is not a stable feature).debug_frame
debug section when .eh_frame
is not present.eh_frame
register restoring rule (in testing seems that such a functionality is not needed)