mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-31 17:31:06 +00:00
Merge pull request #1376 from alexcrichton/more-debugging
Add some logging useful in debugging #1373
This commit is contained in:
commit
c9a972ac55
@ -42,16 +42,15 @@ impl<'src> Decode<'src> for &'src str {
|
|||||||
let n = u32::decode(data);
|
let n = u32::decode(data);
|
||||||
let (a, b) = data.split_at(n as usize);
|
let (a, b) = data.split_at(n as usize);
|
||||||
*data = b;
|
*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 {
|
impl<'src> Decode<'src> for String {
|
||||||
fn decode(data: &mut &'src [u8]) -> String {
|
fn decode(data: &mut &'src [u8]) -> String {
|
||||||
let n = u32::decode(data);
|
<&'src str>::decode(data).to_string()
|
||||||
let (a, b) = data.split_at(n as usize);
|
|
||||||
*data = b;
|
|
||||||
String::from_utf8(a.to_vec()).unwrap()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,6 +58,7 @@ impl<'src, T: Decode<'src>> Decode<'src> for Vec<T> {
|
|||||||
fn decode(data: &mut &'src [u8]) -> Self {
|
fn decode(data: &mut &'src [u8]) -> Self {
|
||||||
let n = u32::decode(data);
|
let n = u32::decode(data);
|
||||||
let mut v = Vec::with_capacity(n as usize);
|
let mut v = Vec::with_capacity(n as usize);
|
||||||
|
log::trace!("found a list of length {}", n);
|
||||||
for _ in 0..n {
|
for _ in 0..n {
|
||||||
v.push(Decode::decode(data));
|
v.push(Decode::decode(data));
|
||||||
}
|
}
|
||||||
@ -84,6 +84,7 @@ macro_rules! decode_struct {
|
|||||||
|
|
||||||
impl <'a> Decode<'a> for $name <$($lt)*> {
|
impl <'a> Decode<'a> for $name <$($lt)*> {
|
||||||
fn decode(_data: &mut &'a [u8]) -> Self {
|
fn decode(_data: &mut &'a [u8]) -> Self {
|
||||||
|
log::trace!("start decode `{}`", stringify!($name));
|
||||||
$name {
|
$name {
|
||||||
$($field: Decode::decode(_data),)*
|
$($field: Decode::decode(_data),)*
|
||||||
}
|
}
|
||||||
|
@ -491,6 +491,7 @@ fn extract_programs<'a>(
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
to_remove.push(i);
|
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()));
|
program_storage.push(mem::replace(&mut custom.value, Vec::new()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -546,6 +547,7 @@ to open an issue at https://github.com/rustwasm/wasm-bindgen/issues!
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
let next = get_remaining(&mut payload).unwrap();
|
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));
|
ret.push(<decode::Program as decode::Decode>::decode_all(next));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -575,6 +577,7 @@ fn verify_schema_matches<'a>(data: &'a [u8]) -> Result<Option<&'a str>, Error> {
|
|||||||
Ok(s) => s,
|
Ok(s) => s,
|
||||||
Err(_) => bad!(),
|
Err(_) => bad!(),
|
||||||
};
|
};
|
||||||
|
log::debug!("found version specifier {}", data);
|
||||||
if !data.starts_with("{") || !data.ends_with("}") {
|
if !data.starts_with("{") || !data.ends_with("}") {
|
||||||
bad!()
|
bad!()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user