Skip to content

Add a WasmBacktrace::new() constructor#5341

Merged
alexcrichton merged 3 commits into
bytecodealliance:mainfrom
alexcrichton:manual-backtrace
Dec 1, 2022
Merged

Add a WasmBacktrace::new() constructor#5341
alexcrichton merged 3 commits into
bytecodealliance:mainfrom
alexcrichton:manual-backtrace

Conversation

@alexcrichton
Copy link
Copy Markdown
Member

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

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 bytecodealliance#5339
@github-actions github-actions Bot added the wasmtime:api Related to the API of the `wasmtime` crate itself label Nov 29, 2022
@github-actions
Copy link
Copy Markdown

Subscribe to Label Action

cc @peterhuene

Details This issue or pull request has been labeled: "wasmtime:api"

Thus the following users have been cc'd because of the following labels:

  • peterhuene: wasmtime:api

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@bjorn3
Copy link
Copy Markdown
Contributor

bjorn3 commented Nov 29, 2022

Maybe mirror std::backtrace::Backtrace? That is WasmBacktrace::capture() respecting Config::wasm_backtrace and WasmBacktrace::force_capture() not respecting it.

@alexcrichton alexcrichton requested a review from fitzgen December 1, 2022 19:38
Comment thread crates/wasmtime/src/trap.rs
Comment thread crates/wasmtime/src/trap.rs Outdated
@alexcrichton alexcrichton enabled auto-merge (squash) December 1, 2022 20:55
@alexcrichton alexcrichton merged commit ed67690 into bytecodealliance:main Dec 1, 2022
@alexcrichton alexcrichton deleted the manual-backtrace branch December 1, 2022 22:19
@jtenner
Copy link
Copy Markdown

jtenner commented Dec 6, 2022

Oh wait, did this get released with 3.0.1?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasmtime:api Related to the API of the `wasmtime` crate itself

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to Obtain Current Stack Trace without a Trap

4 participants