Skip to content

Commit fc2b7a1

Browse files
authored
Merge pull request #5298 from stacks-network/debug_msg
Add stub for `debug_msg` in linker
2 parents 5947287 + 0dc3764 commit fc2b7a1

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

clarity/src/vm/clarity_wasm.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2048,7 +2048,8 @@ fn link_host_functions(linker: &mut Linker<ClarityWasmContext>) -> Result<(), Er
20482048
link_load_constant_fn(linker)?;
20492049
link_skip_list(linker)?;
20502050

2051-
link_log(linker)
2051+
link_log(linker)?;
2052+
link_debug_msg(linker)
20522053
}
20532054

20542055
/// Link host interface function, `define_variable`, into the Wasm module.
@@ -6169,6 +6170,23 @@ fn link_log<T>(linker: &mut Linker<T>) -> Result<(), Error> {
61696170
.map_err(|e| Error::Wasm(WasmError::UnableToLinkHostFunction("log".to_string(), e)))
61706171
}
61716172

6173+
/// Link host-interface function, `debug_msg`, into the Wasm module.
6174+
/// This function is used for debugging the Wasm, and should not be called in
6175+
/// production.
6176+
fn link_debug_msg<T>(linker: &mut Linker<T>) -> Result<(), Error> {
6177+
linker
6178+
.func_wrap("", "debug_msg", |_caller: Caller<'_, T>, param: i32| {
6179+
println!("debug messages are currently not supported in cross-contract calls ({param})")
6180+
})
6181+
.map(|_| ())
6182+
.map_err(|e| {
6183+
Error::Wasm(WasmError::UnableToLinkHostFunction(
6184+
"debug_msg".to_string(),
6185+
e,
6186+
))
6187+
})
6188+
}
6189+
61726190
#[cfg(test)]
61736191
mod tests {
61746192
use wasmtime::*;

0 commit comments

Comments
 (0)