Rename project to unwinding to avoid crates.io name conflict

This commit is contained in:
Gary Guo 2021-10-05 20:16:20 +01:00
parent 2bba02748c
commit 52b976dc4d
6 changed files with 14 additions and 15 deletions

View File

@ -1,5 +1,5 @@
[package] [package]
name = "unwind" name = "unwinding"
version = "0.1.0" version = "0.1.0"
authors = ["Gary Guo <gary@garyguo.net>"] authors = ["Gary Guo <gary@garyguo.net>"]
edition = "2018" edition = "2018"

View File

@ -22,17 +22,17 @@ The unwinder can be enabled with `unwinder` feature. Here are the feature gates
| dwarf-expr | Yes | Enable the dwarf expression evaluator. Usually not necessary for Rust | | dwarf-expr | Yes | Enable the dwarf expression evaluator. Usually not necessary for Rust |
| hide-trace | Yes | Hide unwinder frames in back trace | | hide-trace | Yes | Hide unwinder frames in back trace |
If you want to use the unwinder for other Rust (C++, or any programs that utilize the unwinder), you can build the [`unwind_dyn`](cdylib) crate provided, and use `LD_PRELOAD` to replace the system unwinder with it. If you want to use the unwinder for other Rust (C++, or any programs that utilize the unwinder), you can build the [`unwinding_dyn`](cdylib) crate provided, and use `LD_PRELOAD` to replace the system unwinder with it.
```sh ```sh
cd cdylib cd cdylib
cargo build --release cargo build --release
# Test the unwinder using rustc. Why not :) # Test the unwinder using rustc. Why not :)
LD_PRELOAD=`../target/release/libunwind_dyn.so` rustc +nightly -Ztreat-err-as-bug LD_PRELOAD=`../target/release/libunwinding_dyn.so` rustc +nightly -Ztreat-err-as-bug
``` ```
If you want to link to the unwinder in a Rust binary, simply add If you want to link to the unwinder in a Rust binary, simply add
```rust ```rust
extern crate unwind; extern crate unwinding;
``` ```
## Personality and other utilities ## Personality and other utilities
@ -44,7 +44,7 @@ Here are the feature gates related:
| Feature | Default | Description | | Feature | Default | Description |
|---------------|---------|-| |---------------|---------|-|
| personality | No | Provides `#[lang = eh_personality]` | | personality | No | Provides `#[lang = eh_personality]` |
| print | No | Provides `(e)?print(ln)?`. This is really only here because panic handler needs to provide things. Depends on libc. | | print | No | Provides `(e)?print(ln)?`. This is really only here because panic handler needs to print things. Depends on libc. |
| panicking | No | Provides a generic `begin_panic` and `catch_unwind`. Only stack unwinding functionality is provided, memory allocation and panic handling is left to the user. | | panicking | No | Provides a generic `begin_panic` and `catch_unwind`. Only stack unwinding functionality is provided, memory allocation and panic handling is left to the user. |
| panic | No | Provides Rust `begin_panic` and `catch_unwind`. Only stack unwinding functionality is provided and no printing is done, because this feature does not depend on libc. | | panic | No | Provides Rust `begin_panic` and `catch_unwind`. Only stack unwinding functionality is provided and no printing is done, because this feature does not depend on libc. |
| 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. | | 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. |
@ -63,7 +63,7 @@ PROVIDE(__eh_frame = .);
.eh_frame : { KEEP (*(.eh_frame)) *(.eh_frame.*) } .eh_frame : { KEEP (*(.eh_frame)) *(.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`. And that's it! After you ensured that the global allocator is functional, you can use `unwinding::panic::begin_panic` to initiate an unwing and catch using `unwinding::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 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.
@ -71,5 +71,4 @@ If you have your own version of `thread_local` and `println!` working, you can p
## TODO ## TODO
* A better project name!
* Remove dependencies on `alloc`. * Remove dependencies on `alloc`.

View File

@ -1,5 +1,5 @@
[package] [package]
name = "unwind_dyn" name = "unwinding_dyn"
version = "0.1.0" version = "0.1.0"
authors = ["Gary Guo <gary@garyguo.net>"] authors = ["Gary Guo <gary@garyguo.net>"]
edition = "2018" edition = "2018"
@ -8,5 +8,5 @@ edition = "2018"
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
unwind = { path = "../", features = ["system-alloc", "personality-dummy", "panic-handler-dummy"] } unwinding = { path = "../", features = ["system-alloc", "personality-dummy", "panic-handler-dummy"] }
libc = "0.2" libc = "0.2"

View File

@ -5,4 +5,4 @@
// Keep this explicit // Keep this explicit
#[allow(unused_extern_crates)] #[allow(unused_extern_crates)]
extern crate unwind; extern crate unwinding;

View File

@ -4,5 +4,5 @@ version = "0.1.0"
edition = "2018" edition = "2018"
[dependencies] [dependencies]
unwind = { path = "../", features = ["system-alloc", "personality", "panic-handler"] } unwinding = { path = "../", features = ["system-alloc", "personality", "panic-handler"] }
libc = "0.2" libc = "0.2"

View File

@ -3,10 +3,10 @@
#![feature(default_alloc_error_handler)] #![feature(default_alloc_error_handler)]
extern crate alloc; extern crate alloc;
extern crate unwind; extern crate unwinding;
use alloc::{borrow::ToOwned, string::String}; use alloc::{borrow::ToOwned, string::String};
use unwind::print::*; use unwinding::print::*;
#[link(name = "c")] #[link(name = "c")]
extern "C" {} extern "C" {}
@ -37,7 +37,7 @@ fn bar() {
} }
fn main() { fn main() {
let _ = unwind::panic::catch_unwind(|| { let _ = unwinding::panic::catch_unwind(|| {
bar(); bar();
println!("done"); println!("done");
}); });
@ -48,7 +48,7 @@ fn main() {
#[start] #[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize { fn start(_argc: isize, _argv: *const *const u8) -> isize {
unwind::panic::catch_unwind(|| { unwinding::panic::catch_unwind(|| {
main(); main();
0 0
}) })