Crate stacktrace [−] [src]
A library for pretty-printing stack traces.
Programmers typically find stack traces useful for debugging executables.
One way to get a trace for a thread is by panicking with the environment variable
RUST_BACKTRACE=1.
This is unfortunately hard to use.
Alex Crichton's backtrace crate implements the work required for actually getting information about the call stack on a variety of platforms. Stacktrace tries to make that information more ergonomic to acquire and use.
Quick Start
- For getting a stack trace with a pretty-printing instance of
std::fmt::Debug, seeStackInfo. - For utilities for working with
std::result::Result, seeTrace.
Build profiles
For release builds, consider enabling debugging symbols if you want to keep useful
stack trace information available. To do so, add the following to your Cargo.toml:
[profile.release]
debug = true
For more information, see here.
Notes
- All traces will have various calls into
backtraceandstacktraceas their first few entries. The particular entries will depend on platform as well. - The structs storing call stack information use heap-allocated
Strings. This may be relevant in environments where allocation might fail, such as some low-level projects.
Structs
| FrameInfo |
Information on a function call frame, for use in a stack trace. |
| StackInfo |
A stack trace. Contains a vector of function call frames, in call stack order. |
| Trace |
An error 'annotated' with a stack trace. |