Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more Debug impl for WASI types #371

Merged
merged 2 commits into from
Apr 20, 2019
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 8 additions & 2 deletions lib/wasi/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {{
Expand Down
2 changes: 2 additions & 0 deletions lib/wasi/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ pub struct Fd {
pub inode: Inode,
}

#[derive(Debug)]
pub struct WasiFs {
//pub repo: Repo,
pub name_map: HashMap<String, Inode>,
Expand Down Expand Up @@ -430,6 +431,7 @@ impl WasiFs {
}
}

#[derive(Debug)]
pub struct WasiState<'a> {
pub fs: WasiFs,
pub args: &'a [Vec<u8>],
Expand Down
9 changes: 8 additions & 1 deletion lib/wasi/src/syscalls/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand Down