make backtrace collection a Config field rather than a cargo feature (#4183)
* sorta working in runtime * wasmtime-runtime: get rid of wasm-backtrace feature * wasmtime: factor to make backtraces recording optional. not configurable yet * get rid of wasm-backtrace features * trap tests: now a Trap optionally contains backtrace * eliminate wasm-backtrace feature * code review fixes * ci: no more wasm-backtrace feature * c_api: backtraces always enabled * config: unwind required by backtraces and ref types * plumbed * test that disabling backtraces works * code review comments * fuzzing generator: wasm_backtrace is a runtime config now * doc fix
This commit is contained in:
@@ -20,7 +20,7 @@ doctest = false
|
||||
env_logger = "0.9"
|
||||
anyhow = "1.0"
|
||||
once_cell = "1.3"
|
||||
wasmtime = { path = "../wasmtime", default-features = false, features = ['cranelift', 'wasm-backtrace'] }
|
||||
wasmtime = { path = "../wasmtime", default-features = false, features = ['cranelift'] }
|
||||
wasmtime-c-api-macros = { path = "macros" }
|
||||
|
||||
# Optional dependency for the `wat2wasm` API
|
||||
|
||||
@@ -64,7 +64,13 @@ pub extern "C" fn wasm_trap_message(trap: &wasm_trap_t, out: &mut wasm_message_t
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_trap_origin(raw: &wasm_trap_t) -> Option<Box<wasm_frame_t>> {
|
||||
if raw.trap.trace().len() > 0 {
|
||||
if raw
|
||||
.trap
|
||||
.trace()
|
||||
.expect("backtraces are always enabled")
|
||||
.len()
|
||||
> 0
|
||||
{
|
||||
Some(Box::new(wasm_frame_t {
|
||||
trap: raw.trap.clone(),
|
||||
idx: 0,
|
||||
@@ -78,7 +84,11 @@ pub extern "C" fn wasm_trap_origin(raw: &wasm_trap_t) -> Option<Box<wasm_frame_t
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_trap_trace(raw: &wasm_trap_t, out: &mut wasm_frame_vec_t) {
|
||||
let vec = (0..raw.trap.trace().len())
|
||||
let vec = (0..raw
|
||||
.trap
|
||||
.trace()
|
||||
.expect("backtraces are always enabled")
|
||||
.len())
|
||||
.map(|idx| {
|
||||
Some(Box::new(wasm_frame_t {
|
||||
trap: raw.trap.clone(),
|
||||
@@ -128,7 +138,7 @@ pub extern "C" fn wasmtime_trap_exit_status(raw: &wasm_trap_t, status: &mut i32)
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_frame_func_index(frame: &wasm_frame_t) -> u32 {
|
||||
frame.trap.trace()[frame.idx].func_index()
|
||||
frame.trap.trace().expect("backtraces are always enabled")[frame.idx].func_index()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
@@ -136,7 +146,7 @@ pub extern "C" fn wasmtime_frame_func_name(frame: &wasm_frame_t) -> Option<&wasm
|
||||
frame
|
||||
.func_name
|
||||
.get_or_init(|| {
|
||||
frame.trap.trace()[frame.idx]
|
||||
frame.trap.trace().expect("backtraces are always enabled")[frame.idx]
|
||||
.func_name()
|
||||
.map(|s| wasm_name_t::from(s.to_string().into_bytes()))
|
||||
})
|
||||
@@ -148,7 +158,7 @@ pub extern "C" fn wasmtime_frame_module_name(frame: &wasm_frame_t) -> Option<&wa
|
||||
frame
|
||||
.module_name
|
||||
.get_or_init(|| {
|
||||
frame.trap.trace()[frame.idx]
|
||||
frame.trap.trace().expect("backtraces are always enabled")[frame.idx]
|
||||
.module_name()
|
||||
.map(|s| wasm_name_t::from(s.to_string().into_bytes()))
|
||||
})
|
||||
@@ -157,7 +167,7 @@ pub extern "C" fn wasmtime_frame_module_name(frame: &wasm_frame_t) -> Option<&wa
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_frame_func_offset(frame: &wasm_frame_t) -> usize {
|
||||
frame.trap.trace()[frame.idx]
|
||||
frame.trap.trace().expect("backtraces are always enabled")[frame.idx]
|
||||
.func_offset()
|
||||
.unwrap_or(usize::MAX)
|
||||
}
|
||||
@@ -169,7 +179,7 @@ pub extern "C" fn wasm_frame_instance(_arg1: *const wasm_frame_t) -> *mut wasm_i
|
||||
|
||||
#[no_mangle]
|
||||
pub extern "C" fn wasm_frame_module_offset(frame: &wasm_frame_t) -> usize {
|
||||
frame.trap.trace()[frame.idx]
|
||||
frame.trap.trace().expect("backtraces are always enabled")[frame.idx]
|
||||
.module_offset()
|
||||
.unwrap_or(usize::MAX)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user