Add a WasmBacktrace::new() constructor (#5341)
* Add a `WasmBacktrace::new()` constructor This commit adds a method of manually capturing a backtrace of WebAssembly frames within a `Store`. The new constructor can be called with any `AsContext` values, primarily `&Store` and `&Caller`, during host functions to inspect the calling state. For now this does not respect the `Config::wasm_backtrace` option and instead unconditionally captures the backtrace. It's hoped that this can continue to adapt to needs of embedders by making it more configurable int he future if necessary. Closes #5339 * Split `new` into `capture` and `force_capture`
This commit is contained in:
@@ -74,6 +74,11 @@ impl Frame {
|
||||
}
|
||||
|
||||
impl Backtrace {
|
||||
/// Returns an empty backtrace
|
||||
pub fn empty() -> Backtrace {
|
||||
Backtrace(Vec::new())
|
||||
}
|
||||
|
||||
/// Capture the current Wasm stack in a backtrace.
|
||||
pub fn new() -> Backtrace {
|
||||
tls::with(|state| match state {
|
||||
|
||||
Reference in New Issue
Block a user