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 trace macro for more verbose debug statements #447

Merged
merged 3 commits into from
May 21, 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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ rustc_version = "0.2.3"
default = ["fast-tests", "wasi"]
"loader:kernel" = ["wasmer-kernel-loader"]
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 = []
Expand Down
3 changes: 2 additions & 1 deletion lib/runtime-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,5 @@ blake2b_simd = "0.4.1"
rustc_version = "0.2.3"

[features]
debug = []
debug = []
trace = ["debug"]
18 changes: 18 additions & 0 deletions lib/runtime-core/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {{
Expand Down
4 changes: 2 additions & 2 deletions lib/wasi/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down