Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions crates/debugger/src/host/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,13 +257,9 @@ fn result_to_event(table: &mut ResourceTable, value: DebugRunResult) -> Result<w
DebugRunResult::Trap(_t) => wit::Event::Trap,
DebugRunResult::Breakpoint => wit::Event::Breakpoint,
DebugRunResult::EpochYield => wit::Event::Interrupted,
DebugRunResult::CaughtExceptionThrown(e) => {
DebugRunResult::Exception(e) => {
let e = table.push(WasmException(e))?;
wit::Event::CaughtExceptionThrown(e)
}
DebugRunResult::UncaughtExceptionThrown(e) => {
let e = table.push(WasmException(e))?;
wit::Event::UncaughtExceptionThrown(e)
wit::Event::Exception(e)
}
})
}
Expand Down
13 changes: 4 additions & 9 deletions crates/debugger/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,7 @@ impl<T: Send + 'static> DebugHandler for Handler<T> {

let result = match event {
DebugEvent::HostcallError(_) => DebugRunResult::HostcallError,
DebugEvent::CaughtExceptionThrown(exn) => DebugRunResult::CaughtExceptionThrown(exn),
DebugEvent::UncaughtExceptionThrown(exn) => {
DebugRunResult::UncaughtExceptionThrown(exn)
}
DebugEvent::Exception(exn) => DebugRunResult::Exception(exn),
DebugEvent::Trap(trap) => DebugRunResult::Trap(trap),
DebugEvent::Breakpoint => DebugRunResult::Breakpoint,
DebugEvent::EpochYield => {
Expand Down Expand Up @@ -513,11 +510,9 @@ pub enum DebugRunResult {
HostcallError,
/// Wasm execution was interrupted by an epoch change.
EpochYield,
/// An exception is thrown and caught by Wasm. The current state
/// is at the throw-point.
CaughtExceptionThrown(OwnedRooted<ExnRef>),
/// An exception was not caught and is escaping to the host.
UncaughtExceptionThrown(OwnedRooted<ExnRef>),
/// An exception is thrown by Wasm. The current state is at the
/// throw-point.
Exception(OwnedRooted<ExnRef>),
/// A Wasm trap occurred.
Trap(Trap),
/// A breakpoint was reached.
Expand Down
6 changes: 2 additions & 4 deletions crates/debugger/wit/world.wit
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,8 @@ interface debuggee {
breakpoint,
/// An interruption due to `debuggee.interrupt` occurred.
interrupted,
/// An exception was thrown and caught by Wasm.
caught-exception-thrown(wasm-exception),
/// An exception was thrown and not caught by Wasm.
uncaught-exception-thrown(wasm-exception),
/// An exception was thrown by Wasm.
exception(wasm-exception),
/// An injected call completed with return value(s).
injected-call-return(list<wasm-value>),
}
Expand Down
12 changes: 7 additions & 5 deletions crates/wasmtime/src/runtime/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,11 +868,13 @@ pub(crate) fn gc_refs_in_frame<'a>(ft: FrameTable<'a>, pc: u32, fp: *mut usize)
pub enum DebugEvent<'a> {
/// A [`wasmtime::Error`](crate::Error) was raised by a hostcall.
HostcallError(&'a crate::Error),
/// An exception is thrown and caught by Wasm. The current state
/// is at the throw-point.
CaughtExceptionThrown(OwnedRooted<ExnRef>),
/// An exception was not caught and is escaping to the host.
UncaughtExceptionThrown(OwnedRooted<ExnRef>),
/// An exception is thrown by wasm.
///
/// Note that the exception may be caught by wasm if there's an appropriate
/// handler on the stack, but the stack hasn't been searched yet. The
/// debugger can inject its own exception or overwrite this exception if
/// desired.
Exception(OwnedRooted<ExnRef>),
/// A Wasm trap occurred.
Trap(Trap),
/// A breakpoint was reached.
Expand Down
31 changes: 12 additions & 19 deletions crates/wasmtime/src/runtime/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ use crate::runtime::vm::{
};
use crate::trampoline::VMHostGlobalContext;
#[cfg(feature = "debug")]
use crate::{BreakpointState, DebugHandler, FrameDataCache, OwnedRooted};
use crate::{BreakpointState, DebugHandler, FrameDataCache};
use crate::{Engine, Module, Val, ValRaw, module::ModuleRegistry};
#[cfg(feature = "gc")]
use crate::{ExnRef, Rooted, ThrownException};
Expand Down Expand Up @@ -2774,26 +2774,19 @@ at https://bytecodealliance.org/security.

/// Get an owned rooted reference to the pending exception,
/// without taking it off the store.
#[cfg(feature = "debug")]
#[cfg(all(feature = "debug", feature = "gc"))]
pub(crate) fn pending_exception_owned_rooted(
&mut self,
) -> Result<Option<OwnedRooted<crate::ExnRef>>, crate::error::OutOfMemory> {
#[cfg(feature = "gc")]
{
let mut nogc = AutoAssertNoGc::new(self);
nogc.pending_exception
.take()
.map(|vmexnref| {
let cloned = nogc.clone_gc_ref(vmexnref.as_gc_ref());
nogc.pending_exception = Some(cloned.into_exnref_unchecked());
OwnedRooted::new(&mut nogc, vmexnref.into())
})
.transpose()
}
#[cfg(not(feature = "gc"))]
{
Ok(None)
}
) -> Result<Option<crate::OwnedRooted<crate::ExnRef>>, crate::error::OutOfMemory> {
let mut nogc = AutoAssertNoGc::new(self);
nogc.pending_exception
.take()
.map(|vmexnref| {
let cloned = nogc.clone_gc_ref(vmexnref.as_gc_ref());
nogc.pending_exception = Some(cloned.into_exnref_unchecked());
crate::OwnedRooted::new(&mut nogc, vmexnref.into())
})
.transpose()
}

#[cfg(feature = "gc")]
Expand Down
1 change: 0 additions & 1 deletion crates/wasmtime/src/runtime/trap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ pub(crate) fn from_runtime_box(
}
(err, Some(pc))
}
crate::runtime::vm::TrapReason::Wasm(trap_code) => (trap_code.into(), None),
};

if let Some(bt) = backtrace {
Expand Down
12 changes: 3 additions & 9 deletions crates/wasmtime/src/runtime/vm/libcalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use crate::runtime::vm::VMGcRef;
use crate::runtime::vm::table::TableElementType;
use crate::runtime::vm::vmcontext::VMFuncRef;
use crate::runtime::vm::{
self, HostResultHasUnwindSentinel, SendSyncPtr, TrapReason, VMStore, f32x4, f64x2, i8x16,
self, HostResultHasUnwindSentinel, SendSyncPtr, VMStore, f32x4, f64x2, i8x16,
};
use core::convert::Infallible;
use core::ptr::NonNull;
Expand Down Expand Up @@ -1660,14 +1660,8 @@ fn fma_f64x2(
/// The `Infallible` "ok" type here means that this never returns success, it
/// only ever returns an error, and this hooks into the machinery to handle
/// `Result` values to record such trap information.
fn trap(
_store: &mut dyn VMStore,
_instance: InstanceId,
code: u8,
) -> Result<Infallible, TrapReason> {
Err(TrapReason::Wasm(
wasmtime_environ::Trap::from_u8(code).unwrap(),
))
fn trap(_store: &mut dyn VMStore, _instance: InstanceId, code: u8) -> Result<Infallible> {
Err(wasmtime_environ::Trap::from_u8(code).unwrap().into())
}

fn raise(store: &mut dyn VMStore, _instance: InstanceId) {
Expand Down
Loading
Loading