Commit work
This commit is contained in:
parent
978cc419f9
commit
3401b8e3a6
@ -7,9 +7,6 @@ license = "MIT OR Apache-2.0"
|
|||||||
description = "Unwinding library in Rust and for Rust"
|
description = "Unwinding library in Rust and for Rust"
|
||||||
repository = "https://github.com/nbdd0121/unwinding/"
|
repository = "https://github.com/nbdd0121/unwinding/"
|
||||||
|
|
||||||
[workspace]
|
|
||||||
members = ["cdylib", "example"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gimli = { version = "0.26.1", default-features = false, features = ["read-core"] }
|
gimli = { version = "0.26.1", default-features = false, features = ["read-core"] }
|
||||||
libc = { version = "0.2", optional = true }
|
libc = { version = "0.2", optional = true }
|
||||||
@ -36,8 +33,5 @@ panic-handler-dummy = []
|
|||||||
system-alloc = []
|
system-alloc = []
|
||||||
default = ["unwinder", "dwarf-expr", "hide-trace", "fde-phdr-dl", "fde-registry"]
|
default = ["unwinder", "dwarf-expr", "hide-trace", "fde-phdr-dl", "fde-registry"]
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
debug = true
|
|
||||||
|
|
||||||
[package.metadata.docs.rs]
|
[package.metadata.docs.rs]
|
||||||
features = ["panic-handler"]
|
features = ["panic-handler"]
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "unwinding_dyn"
|
|
||||||
version = "0.1.0"
|
|
||||||
authors = ["Gary Guo <gary@garyguo.net>"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
unwinding = { path = "../", features = ["system-alloc", "personality-dummy", "panic-handler-dummy"] }
|
|
||||||
libc = "0.2"
|
|
@ -1,8 +0,0 @@
|
|||||||
#![no_std]
|
|
||||||
#![feature(default_alloc_error_handler)]
|
|
||||||
#![warn(rust_2018_idioms)]
|
|
||||||
#![warn(unsafe_op_in_unsafe_fn)]
|
|
||||||
|
|
||||||
// Keep this explicit
|
|
||||||
#[allow(unused_extern_crates)]
|
|
||||||
extern crate unwinding;
|
|
@ -1,8 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "example"
|
|
||||||
version = "0.1.0"
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
unwinding = { path = "../", features = ["system-alloc", "personality", "panic-handler"] }
|
|
||||||
libc = "0.2"
|
|
@ -1,56 +0,0 @@
|
|||||||
#![no_std]
|
|
||||||
#![feature(start)]
|
|
||||||
#![feature(default_alloc_error_handler)]
|
|
||||||
|
|
||||||
extern crate alloc;
|
|
||||||
extern crate unwinding;
|
|
||||||
|
|
||||||
use alloc::{borrow::ToOwned, string::String};
|
|
||||||
use unwinding::print::*;
|
|
||||||
|
|
||||||
#[link(name = "c")]
|
|
||||||
extern "C" {}
|
|
||||||
|
|
||||||
struct PrintOnDrop(String);
|
|
||||||
|
|
||||||
impl Drop for PrintOnDrop {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
println!("dropped: {:?}", self.0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct PanicOnDrop;
|
|
||||||
|
|
||||||
impl Drop for PanicOnDrop {
|
|
||||||
fn drop(&mut self) {
|
|
||||||
panic!("panic on drop");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn foo() {
|
|
||||||
panic!("panic");
|
|
||||||
}
|
|
||||||
|
|
||||||
fn bar() {
|
|
||||||
let _p = PrintOnDrop("string".to_owned());
|
|
||||||
foo()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
let _ = unwinding::panic::catch_unwind(|| {
|
|
||||||
bar();
|
|
||||||
println!("done");
|
|
||||||
});
|
|
||||||
println!("caught");
|
|
||||||
let _p = PanicOnDrop;
|
|
||||||
foo();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[start]
|
|
||||||
fn start(_argc: isize, _argv: *const *const u8) -> isize {
|
|
||||||
unwinding::panic::catch_unwind(|| {
|
|
||||||
main();
|
|
||||||
0
|
|
||||||
})
|
|
||||||
.unwrap_or(101)
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user