[wasi-common] Log string representation of WASI errno at the trace level (#760)
* Log str repr of WASI errno at trace level
This commit refactors `Error` enum, and adds logging of the WASI
errno string representation at the trace level. Now, when tracing
WASI syscalls, we will be greeted with a nicely formatted errno
value after each syscall:
```
path_open(...)
| *fd=5
| errno=ESUCCESS
```
This commit gets rid of `errno_from_nix`, `errno_from_win` and
`errno_from_host` helper fns in favour of direct `From` implementations
for the relevant types such as `yanix::Errno` and `winx::winerror::WinError`.
`errno_from_host` is replaced by a trait `FromRawOsError`.
* Back port changes to snapshot0
* Fix indentation in logs
This commit is contained in:
@@ -2,12 +2,12 @@ macro_rules! hostcalls {
|
||||
($(pub unsafe fn $name:ident($($arg:ident: $ty:ty,)*) -> $ret:ty;)*) => ($(
|
||||
#[wasi_common_cbindgen::wasi_common_cbindgen]
|
||||
pub unsafe fn $name($($arg: $ty,)*) -> $ret {
|
||||
let ret = match hostcalls_impl::$name($($arg,)*) {
|
||||
Ok(()) => wasi::__WASI_ERRNO_SUCCESS,
|
||||
Err(e) => e.as_wasi_errno(),
|
||||
};
|
||||
|
||||
ret
|
||||
let ret = crate::hostcalls_impl::$name($($arg,)*)
|
||||
.err()
|
||||
.unwrap_or(crate::Error::ESUCCESS)
|
||||
.as_wasi_error();
|
||||
log::trace!(" | errno={}", ret);
|
||||
ret.as_raw_errno()
|
||||
}
|
||||
)*)
|
||||
}
|
||||
@@ -18,12 +18,12 @@ macro_rules! hostcalls_old {
|
||||
($(pub unsafe fn $name:ident($($arg:ident: $ty:ty,)*) -> $ret:ty;)*) => ($(
|
||||
#[wasi_common_cbindgen::wasi_common_cbindgen_old]
|
||||
pub unsafe fn $name($($arg: $ty,)*) -> $ret {
|
||||
let ret = match hostcalls_impl::$name($($arg,)*) {
|
||||
Ok(()) => wasi::__WASI_ERRNO_SUCCESS,
|
||||
Err(e) => e.as_wasi_errno(),
|
||||
};
|
||||
|
||||
ret
|
||||
let ret = crate::old::snapshot_0::hostcalls_impl::$name($($arg,)*)
|
||||
.err()
|
||||
.unwrap_or(crate::old::snapshot_0::Error::ESUCCESS)
|
||||
.as_wasi_error();
|
||||
log::trace!(" | errno={}", ret);
|
||||
ret.as_raw_errno()
|
||||
}
|
||||
)*)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user