diff --git a/CHANGELOG.md b/CHANGELOG.md index 01163915a82..9284916aa5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ All PRs to the Wasmer repository must add to this file. Blocks of changes will separated by version increments. ## **[Unreleased]** +- [#371](https://github.com/wasmerio/wasmer/pull/371) Add more Debug impl for WASI types - [#368](https://github.com/wasmerio/wasmer/pull/368) Fix issue with write buffering - [#343](https://github.com/wasmerio/wasmer/pull/343) Implement preopened files for WASI and fix aligment issue when accessing WASI memory - [#367](https://github.com/wasmerio/wasmer/pull/367) Add caching support to the LLVM backend. diff --git a/lib/wasi/src/macros.rs b/lib/wasi/src/macros.rs index 0e00e77b319..1420b8f2d25 100644 --- a/lib/wasi/src/macros.rs +++ b/lib/wasi/src/macros.rs @@ -2,8 +2,14 @@ macro_rules! wasi_try { ($expr:expr) => {{ let res: Result<_, crate::syscalls::types::__wasi_errno_t> = $expr; match res { - Ok(val) => val, - Err(err) => return err, + Ok(val) => { + debug!("wasi::wasi_try::val: {:?}", val); + val + } + Err(err) => { + debug!("wasi::wasi_try::err: {:?}", err); + return err; + } } }}; ($expr:expr; $e:expr) => {{ diff --git a/lib/wasi/src/state.rs b/lib/wasi/src/state.rs index 65cc3e6a88e..813250c574d 100644 --- a/lib/wasi/src/state.rs +++ b/lib/wasi/src/state.rs @@ -171,6 +171,7 @@ pub struct Fd { pub inode: Inode, } +#[derive(Debug)] pub struct WasiFs { //pub repo: Repo, pub name_map: HashMap, @@ -430,6 +431,7 @@ impl WasiFs { } } +#[derive(Debug)] pub struct WasiState<'a> { pub fs: WasiFs, pub args: &'a [Vec], diff --git a/lib/wasi/src/syscalls/types.rs b/lib/wasi/src/syscalls/types.rs index 6e16e03c651..c030df3124b 100644 --- a/lib/wasi/src/syscalls/types.rs +++ b/lib/wasi/src/syscalls/types.rs @@ -2,6 +2,7 @@ use crate::ptr::{Array, WasmPtr}; use byteorder::{ReadBytesExt, WriteBytesExt, LE}; +use std::fmt; use std::mem; use wasmer_runtime_core::types::ValueType; @@ -212,9 +213,15 @@ pub union __wasi_prestat_u { dir: __wasi_prestat_u_dir_t, } +impl fmt::Debug for __wasi_prestat_u { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "__wasi_prestat_u") + } +} + unsafe impl ValueType for __wasi_prestat_u {} -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] #[repr(C)] pub struct __wasi_prestat_t { pub pr_type: __wasi_preopentype_t,