forked from rust-lang/backtrace-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
15a28b9
commit f897487
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# backtrace-rs | ||
|
||
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 | ||
|
||
```toml | ||
[dependencies] | ||
backtrace = "0.1" | ||
``` | ||
|
||
```rust | ||
extern crate backtrace; | ||
``` | ||
|
||
## Usage | ||
|
||
```rust | ||
extern crate backtrace; | ||
|
||
fn main() { | ||
backtrace::trace(&mut |frame| { | ||
let ip = frame.ip(); | ||
let symbol_address = frame.symbol_address(); | ||
|
||
// Resolve this instruction pointer to a symbol name | ||
backtrace::resolve(ip, &mut |symbol| { | ||
if let Some(name) = symbol.name() { | ||
// ... | ||
} | ||
if let Some(filename) = symbol.filename() { | ||
// ... | ||
} | ||
}); | ||
|
||
true // keep going to the next frame | ||
}); | ||
} | ||
``` |