From a9f643f774e27a0a626ead9e81b59f40730a30e6 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Wed, 15 May 2019 11:46:17 -0700 Subject: [PATCH 1/2] add trace macro for more verbose debug statements --- Cargo.toml | 1 + lib/runtime-core/Cargo.toml | 1 + lib/runtime-core/src/macros.rs | 18 ++++++++++++++++++ lib/wasi/src/macros.rs | 4 ++-- 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 5de0f17ee41..66e7a46fe8e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,6 +44,7 @@ rustc_version = "0.2.3" [features] default = ["fast-tests", "wasi"] debug = ["wasmer-runtime-core/debug"] +trace = ["wasmer-runtime-core/trace"] extra-debug = ["wasmer-clif-backend/debug", "wasmer-runtime-core/debug"] # This feature will allow cargo test to run much faster fast-tests = [] diff --git a/lib/runtime-core/Cargo.toml b/lib/runtime-core/Cargo.toml index d6b735cff43..07560d15d5f 100644 --- a/lib/runtime-core/Cargo.toml +++ b/lib/runtime-core/Cargo.toml @@ -50,3 +50,4 @@ rustc_version = "0.2.3" [features] debug = [] +trace = ["debug"] diff --git a/lib/runtime-core/src/macros.rs b/lib/runtime-core/src/macros.rs index edda293664e..6dbb93ca09c 100644 --- a/lib/runtime-core/src/macros.rs +++ b/lib/runtime-core/src/macros.rs @@ -18,6 +18,24 @@ macro_rules! debug { ($fmt:expr, $($arg:tt)*) => {}; } +#[macro_export] +#[cfg(feature = "trace")] +macro_rules! trace { + ($fmt:expr) => { + debug!($fmt) + }; + ($fmt:expr, $($arg:tt)*) => { + debug!($fmt, $($arg)*); + } +} + +#[macro_export] +#[cfg(not(feature = "trace"))] +macro_rules! trace { + ($fmt:expr) => {}; + ($fmt:expr, $($arg:tt)*) => {}; +} + #[macro_export] macro_rules! func { ($func:path) => {{ diff --git a/lib/wasi/src/macros.rs b/lib/wasi/src/macros.rs index 1420b8f2d25..86b6b07dcbd 100644 --- a/lib/wasi/src/macros.rs +++ b/lib/wasi/src/macros.rs @@ -3,11 +3,11 @@ macro_rules! wasi_try { let res: Result<_, crate::syscalls::types::__wasi_errno_t> = $expr; match res { Ok(val) => { - debug!("wasi::wasi_try::val: {:?}", val); + wasmer_runtime_core::trace!("wasi::wasi_try::val: {:?}", val); val } Err(err) => { - debug!("wasi::wasi_try::err: {:?}", err); + wasmer_runtime_core::trace!("wasi::wasi_try::err: {:?}", err); return err; } } From c12b9541c667def0bb99517ed5f0764339bd3b48 Mon Sep 17 00:00:00 2001 From: Mark McCaskey Date: Tue, 21 May 2019 11:46:35 -0700 Subject: [PATCH 2/2] update changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad600bdc154..e76e6b6ebef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ Blocks of changes will separated by version increments. ## **[Unreleased]** +- [#459](https://github.com/wasmerio/wasmer/pull/459) Add monotonic and real time clocks for wasi on windows +- [#447](https://github.com/wasmerio/wasmer/pull/447) Add trace macro (`--features trace`) for more verbose debug statements - [#451](https://github.com/wasmerio/wasmer/pull/451) Add `--mapdir=src:dest` flag to rename host directories in the guest context - [#457](https://github.com/wasmerio/wasmer/pull/457) Implement file metadata for WASI, fix bugs in WASI clock code for Unix platforms