447: add trace macro for more verbose debug statements r=MarkMcCaskey a=MarkMcCaskey

The next step is to implement these in terms of `log`

Co-authored-by: Mark McCaskey <mark@wasmer.io>
Co-authored-by: Mark McCaskey <markmccaskey@users.noreply.github.com>
This commit is contained in:
bors[bot] 2019-05-21 19:28:34 +00:00
commit 32c2ad1916
5 changed files with 25 additions and 3 deletions

View File

@ -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

View File

@ -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 = []

View File

@ -50,3 +50,4 @@ rustc_version = "0.2.3"
[features]
debug = []
trace = ["debug"]

View File

@ -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) => {{

View File

@ -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;
}
}