From 12355ce81c2786c5db1b58139c37f7df093a4f70 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 21 Mar 2019 08:30:30 -0700 Subject: [PATCH] Add some logging useful in debugging #1373 Ended up helping diagnose the problem in the end! --- crates/cli-support/src/decode.rs | 11 ++++++----- crates/cli-support/src/lib.rs | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/crates/cli-support/src/decode.rs b/crates/cli-support/src/decode.rs index 1d337e27..d58b49ff 100644 --- a/crates/cli-support/src/decode.rs +++ b/crates/cli-support/src/decode.rs @@ -42,16 +42,15 @@ impl<'src> Decode<'src> for &'src str { let n = u32::decode(data); let (a, b) = data.split_at(n as usize); *data = b; - str::from_utf8(a).unwrap() + let r = str::from_utf8(a).unwrap(); + log::trace!("decoded string {:?}", r); + r } } impl<'src> Decode<'src> for String { fn decode(data: &mut &'src [u8]) -> String { - let n = u32::decode(data); - let (a, b) = data.split_at(n as usize); - *data = b; - String::from_utf8(a.to_vec()).unwrap() + <&'src str>::decode(data).to_string() } } @@ -59,6 +58,7 @@ impl<'src, T: Decode<'src>> Decode<'src> for Vec { fn decode(data: &mut &'src [u8]) -> Self { let n = u32::decode(data); let mut v = Vec::with_capacity(n as usize); + log::trace!("found a list of length {}", n); for _ in 0..n { v.push(Decode::decode(data)); } @@ -84,6 +84,7 @@ macro_rules! decode_struct { impl <'a> Decode<'a> for $name <$($lt)*> { fn decode(_data: &mut &'a [u8]) -> Self { + log::trace!("start decode `{}`", stringify!($name)); $name { $($field: Decode::decode(_data),)* } diff --git a/crates/cli-support/src/lib.rs b/crates/cli-support/src/lib.rs index d825445a..8ca87a1a 100755 --- a/crates/cli-support/src/lib.rs +++ b/crates/cli-support/src/lib.rs @@ -477,6 +477,7 @@ fn extract_programs<'a>( continue; } to_remove.push(i); + log::debug!("custom section {} looks like a wasm bindgen section", i); program_storage.push(mem::replace(&mut custom.value, Vec::new())); } @@ -532,6 +533,7 @@ to open an issue at https://github.com/rustwasm/wasm-bindgen/issues! ); } let next = get_remaining(&mut payload).unwrap(); + log::debug!("found a program of length {}", next.len()); ret.push(::decode_all(next)); } } @@ -561,6 +563,7 @@ fn verify_schema_matches<'a>(data: &'a [u8]) -> Result, Error> { Ok(s) => s, Err(_) => bad!(), }; + log::debug!("found version specifier {}", data); if !data.starts_with("{") || !data.ends_with("}") { bad!() }