From 930912f783b2d00c09eb3cd2c4a48d21f9ed42f2 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 25 Aug 2020 11:29:34 -0700 Subject: [PATCH] tracing fixes in unix poll; add some missing debug impls --- crates/wasi-common/src/entry.rs | 6 ++++++ crates/wasi-common/src/poll.rs | 1 + crates/wasi-common/src/sys/unix/poll.rs | 13 +++++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/crates/wasi-common/src/entry.rs b/crates/wasi-common/src/entry.rs index 8734c63d3f..73923e6902 100644 --- a/crates/wasi-common/src/entry.rs +++ b/crates/wasi-common/src/entry.rs @@ -18,6 +18,12 @@ impl EntryHandle { } } +impl std::fmt::Debug for EntryHandle { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + f.debug_struct("EntryHandle").field("opaque", &()).finish() + } +} + impl From> for EntryHandle { fn from(handle: Box) -> Self { Self(handle.into()) diff --git a/crates/wasi-common/src/poll.rs b/crates/wasi-common/src/poll.rs index a0be6b17b5..97f3f9ea38 100644 --- a/crates/wasi-common/src/poll.rs +++ b/crates/wasi-common/src/poll.rs @@ -9,6 +9,7 @@ pub(crate) struct ClockEventData { pub(crate) userdata: types::Userdata, } +#[derive(Debug)] pub(crate) struct FdEventData { pub(crate) handle: EntryHandle, pub(crate) r#type: types::Eventtype, diff --git a/crates/wasi-common/src/sys/unix/poll.rs b/crates/wasi-common/src/sys/unix/poll.rs index 8b30861b8d..022a2ba644 100644 --- a/crates/wasi-common/src/sys/unix/poll.rs +++ b/crates/wasi-common/src/sys/unix/poll.rs @@ -38,7 +38,10 @@ pub(crate) fn oneoff( let delay = timeout.delay / 1_000_000; // poll syscall requires delay to expressed in milliseconds delay.try_into().unwrap_or(libc::c_int::max_value()) }); - tracing::debug!("poll_oneoff poll_timeout = {:?}", poll_timeout); + tracing::debug!( + poll_timeout = tracing::field::debug(poll_timeout), + "poll_oneoff" + ); let ready = loop { match poll(&mut poll_fds, poll_timeout) { @@ -91,15 +94,17 @@ fn handle_fd_event( } for (fd_event, poll_fd) in ready_events { - tracing::debug!("poll_oneoff_handle_fd_event poll_fd = {:?}", poll_fd); + tracing::debug!( + poll_fd = tracing::field::debug(poll_fd), + poll_event = tracing::field::debug(&fd_event), + "poll_oneoff handle_fd_event" + ); let revents = match poll_fd.revents() { Some(revents) => revents, None => continue, }; - tracing::debug!("poll_oneoff_handle_fd_event revents = {:?}", revents); - let nbytes = if fd_event.r#type == types::Eventtype::FdRead { query_nbytes(fd_event.handle)? } else {