mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 02:00:51 +00:00
Add some logging useful in debugging #1373
Ended up helping diagnose the problem in the end!
This commit is contained in:
parent
d49d8c9e1b
commit
12355ce81c
@ -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<T> {
|
||||
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),)*
|
||||
}
|
||||
|
@ -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::Program as decode::Decode>::decode_all(next));
|
||||
}
|
||||
}
|
||||
@ -561,6 +563,7 @@ fn verify_schema_matches<'a>(data: &'a [u8]) -> Result<Option<&'a str>, Error> {
|
||||
Ok(s) => s,
|
||||
Err(_) => bad!(),
|
||||
};
|
||||
log::debug!("found version specifier {}", data);
|
||||
if !data.starts_with("{") || !data.ends_with("}") {
|
||||
bad!()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user