Make the trap name for unreachable traps more descriptive. (#3568)
Following up on WebAssembly/wasi-sdk#210, this makes the trap message for `unreachable` traps more descriptive of what actually caused the trap, so that it doesn't sound like maybe Wasmtime itself executed a `unreachable!()` macro in Rust. Before: ``` wasm trap: unreachable wasm backtrace: [...] ``` After: ``` wasm trap: wasm `unreachable` instruction executed wasm backtrace: [...] ```
This commit is contained in:
@@ -119,7 +119,7 @@ impl fmt::Display for TrapCode {
|
|||||||
IntegerOverflow => "integer overflow",
|
IntegerOverflow => "integer overflow",
|
||||||
IntegerDivisionByZero => "integer divide by zero",
|
IntegerDivisionByZero => "integer divide by zero",
|
||||||
BadConversionToInteger => "invalid conversion to integer",
|
BadConversionToInteger => "invalid conversion to integer",
|
||||||
UnreachableCodeReached => "unreachable",
|
UnreachableCodeReached => "wasm `unreachable` instruction executed",
|
||||||
Interrupt => "interrupt",
|
Interrupt => "interrupt",
|
||||||
};
|
};
|
||||||
write!(f, "{}", desc)
|
write!(f, "{}", desc)
|
||||||
|
|||||||
@@ -160,7 +160,7 @@ fn trap_display_pretty() -> Result<()> {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
e.to_string(),
|
e.to_string(),
|
||||||
"\
|
"\
|
||||||
wasm trap: unreachable
|
wasm trap: wasm `unreachable` instruction executed
|
||||||
wasm backtrace:
|
wasm backtrace:
|
||||||
0: 0x23 - m!die
|
0: 0x23 - m!die
|
||||||
1: 0x27 - m!<wasm function 1>
|
1: 0x27 - m!<wasm function 1>
|
||||||
@@ -206,7 +206,7 @@ fn trap_display_multi_module() -> Result<()> {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
e.to_string(),
|
e.to_string(),
|
||||||
"\
|
"\
|
||||||
wasm trap: unreachable
|
wasm trap: wasm `unreachable` instruction executed
|
||||||
wasm backtrace:
|
wasm backtrace:
|
||||||
0: 0x23 - a!die
|
0: 0x23 - a!die
|
||||||
1: 0x27 - a!<wasm function 1>
|
1: 0x27 - a!<wasm function 1>
|
||||||
@@ -400,7 +400,7 @@ fn start_trap_pretty() -> Result<()> {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
e.to_string(),
|
e.to_string(),
|
||||||
"\
|
"\
|
||||||
wasm trap: unreachable
|
wasm trap: wasm `unreachable` instruction executed
|
||||||
wasm backtrace:
|
wasm backtrace:
|
||||||
0: 0x1d - m!die
|
0: 0x1d - m!die
|
||||||
1: 0x21 - m!<wasm function 1>
|
1: 0x21 - m!<wasm function 1>
|
||||||
@@ -565,7 +565,7 @@ fn no_hint_even_with_dwarf_info() -> Result<()> {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
trap.to_string(),
|
trap.to_string(),
|
||||||
"\
|
"\
|
||||||
wasm trap: unreachable
|
wasm trap: wasm `unreachable` instruction executed
|
||||||
wasm backtrace:
|
wasm backtrace:
|
||||||
0: 0x1a - <unknown>!start
|
0: 0x1a - <unknown>!start
|
||||||
"
|
"
|
||||||
@@ -600,7 +600,7 @@ fn hint_with_dwarf_info() -> Result<()> {
|
|||||||
assert_eq!(
|
assert_eq!(
|
||||||
trap.to_string(),
|
trap.to_string(),
|
||||||
"\
|
"\
|
||||||
wasm trap: unreachable
|
wasm trap: wasm `unreachable` instruction executed
|
||||||
wasm backtrace:
|
wasm backtrace:
|
||||||
0: 0x1a - <unknown>!start
|
0: 0x1a - <unknown>!start
|
||||||
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable to may show more debugging information
|
note: using the `WASMTIME_BACKTRACE_DETAILS=1` environment variable to may show more debugging information
|
||||||
|
|||||||
Reference in New Issue
Block a user