Improve documentation
This commit is contained in:
parent
88d34ea7ad
commit
2bba02748c
@ -37,9 +37,12 @@ system-alloc = []
|
||||
default = ["unwinder", "dwarf-expr", "hide-trace", "fde-phdr-dl", "fde-registry"]
|
||||
|
||||
[profile.dev]
|
||||
# Must be turned on due to Rust bug https://github.com/rust-lang/rust/issues/50007
|
||||
# Must be turned on for cdylib due to Rust bug https://github.com/rust-lang/rust/issues/50007
|
||||
lto = true
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
debug = true
|
||||
|
||||
[package.metadata.docs.rs]
|
||||
features = ["panic-handler"]
|
||||
|
@ -9,8 +9,8 @@ Currently supports x86_64 and RV64.
|
||||
|
||||
## Unwinder
|
||||
|
||||
The unwinder can be enabled with `unwinder` feature. Here are the feature gates related to
|
||||
the unwinder:
|
||||
The unwinder can be enabled with `unwinder` feature. Here are the feature gates related to the unwinder:
|
||||
|
||||
| Feature | Default | Description |
|
||||
|--------------------- |---------|-|
|
||||
| unwinder | Yes | The primary feature gate to enable the unwinder |
|
||||
@ -40,6 +40,7 @@ extern crate unwind;
|
||||
The library also provides Rust personality function. This can work with the unwinder described above or with a different unwinder. This can be handy if you are working on a `#![no_std]` binary/staticlib/cdylib and you still want unwinding support.
|
||||
|
||||
Here are the feature gates related:
|
||||
|
||||
| Feature | Default | Description |
|
||||
|---------------|---------|-|
|
||||
| personality | No | Provides `#[lang = eh_personality]` |
|
||||
@ -49,7 +50,7 @@ Here are the feature gates related:
|
||||
| panic-handler | No | Provides `#[panic_handler]`. Provides similar behaviour on panic to std, with `RUST_BACKTRACE` support as well. Stack trace won't have symbols though. Depends on libc. |
|
||||
| system-alloc | No | Provides a global allocator which calls `malloc` and friends. Provided for convience. |
|
||||
|
||||
If you are writing a `#![no_std]` program, simply enable `personality`, `panic-handler` and `system-alloc` in addition to the defaults, you instantly obtains the ability to do unwinding! An example is given in [`example/`](example).
|
||||
If you are writing a `#![no_std]` program, simply enable `personality`, `panic-handler` and `system-alloc` in addition to the defaults, you instantly obtains the ability to do unwinding! An example is given in the [`example/` folder](example).
|
||||
|
||||
## Baremetal
|
||||
|
||||
@ -64,6 +65,8 @@ PROVIDE(__eh_frame = .);
|
||||
|
||||
And that's it! After you ensured that the global allocator is functional, you can use `unwind::panic::begin_panic` to initiate an unwing and catch using `unwind::panic::catch_unwind`, as if you have a `std`.
|
||||
|
||||
If your linker supports `--eh-frame-hdr` you can also try to use `fde-gnu-eh-frame-hdr` instead of `fde-static`. GNU LD will provides a `__GNU_EH_FRAME_HDR` magic symbol so you don't have to provide `__eh_frame` through linker script.
|
||||
|
||||
If you have your own version of `thread_local` and `println!` working, you can port [`panic_handler.rs`](src/panic_handler.rs) for double-panic protection and stack traces!
|
||||
|
||||
## TODO
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![doc = include_str!("../README.md")]
|
||||
#![feature(c_unwind)]
|
||||
#![feature(naked_functions)]
|
||||
#![feature(asm)]
|
||||
@ -39,9 +40,9 @@ pub mod panic;
|
||||
pub mod panicking;
|
||||
|
||||
#[cfg(feature = "panic-handler")]
|
||||
pub mod panic_handler;
|
||||
mod panic_handler;
|
||||
#[cfg(feature = "panic-handler-dummy")]
|
||||
pub mod panic_handler_dummy;
|
||||
mod panic_handler_dummy;
|
||||
|
||||
#[cfg(feature = "system-alloc")]
|
||||
mod system_alloc;
|
||||
|
@ -4,7 +4,7 @@ use core::mem::MaybeUninit;
|
||||
|
||||
use crate::abi::*;
|
||||
#[cfg(feature = "panic-handler")]
|
||||
use crate::panic_handler::*;
|
||||
pub use crate::panic_handler::*;
|
||||
use crate::panicking::Exception;
|
||||
|
||||
#[repr(transparent)]
|
||||
|
Loading…
Reference in New Issue
Block a user