mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-30 09:01:33 +00:00
Improved debug statements
This commit is contained in:
@ -3,7 +3,6 @@ use libc::{printf, putchar};
|
|||||||
|
|
||||||
extern "C" fn _printf(memory_offset: i32, extra: i32, instance: &Instance) -> i32 {
|
extern "C" fn _printf(memory_offset: i32, extra: i32, instance: &Instance) -> i32 {
|
||||||
let mem = &instance.memories[0];
|
let mem = &instance.memories[0];
|
||||||
println!("instance = {:?}", instance);
|
|
||||||
return unsafe {
|
return unsafe {
|
||||||
let base_memory_offset = mem.mmap.as_ptr().offset(memory_offset as isize) as *const i8;
|
let base_memory_offset = mem.mmap.as_ptr().offset(memory_offset as isize) as *const i8;
|
||||||
printf(base_memory_offset, extra)
|
printf(base_memory_offset, extra)
|
||||||
|
@ -23,17 +23,3 @@ macro_rules! include_wast2wasm_bytes {
|
|||||||
wat2wasm(WAST_BYTES.to_vec()).expect(&format!("Can't convert {} file to wasm", $x))
|
wat2wasm(WAST_BYTES.to_vec()).expect(&format!("Can't convert {} file to wasm", $x))
|
||||||
}};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(feature= "debug")]
|
|
||||||
#[macro_export]
|
|
||||||
macro_rules! debug {
|
|
||||||
($fmt:expr) => (println!(concat!("Wasmer::", $fmt)));
|
|
||||||
($fmt:expr, $($arg:tt)*) => (println!(concat!("Wasmer::", $fmt, "\n"), $($arg)*));
|
|
||||||
}
|
|
||||||
|
|
||||||
// #[cfg(not(feature= "debug"))]
|
|
||||||
// #[macro_export]
|
|
||||||
// macro_rules! debug {
|
|
||||||
// ($fmt:expr) => {};
|
|
||||||
// ($fmt:expr, $($arg:tt)*) => {};
|
|
||||||
// }
|
|
||||||
|
@ -20,7 +20,8 @@ extern crate spin;
|
|||||||
// #[global_allocator]
|
// #[global_allocator]
|
||||||
// static A: System = System;
|
// static A: System = System;
|
||||||
|
|
||||||
// #[macro_use] extern crate log;
|
#[macro_use]
|
||||||
|
extern crate log;
|
||||||
|
|
||||||
// use libc;
|
// use libc;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
@ -89,9 +90,8 @@ fn execute_wasm(wasm_path: PathBuf) -> Result<(), String> {
|
|||||||
Some(&webassembly::Export::Function(index)) => index,
|
Some(&webassembly::Export::Function(index)) => index,
|
||||||
_ => panic!("Main function not found"),
|
_ => panic!("Main function not found"),
|
||||||
});
|
});
|
||||||
let main: fn(&webassembly::Instance) -> i32 = get_instance_function!(instance, func_index);
|
let main: fn(&webassembly::Instance) = get_instance_function!(instance, func_index);
|
||||||
let result = main(&instance);
|
main(&instance);
|
||||||
println!("RESULT {}", result);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +185,7 @@ impl Instance {
|
|||||||
func_context
|
func_context
|
||||||
.compile_and_emit(&*isa, &mut code_buf, &mut reloc_sink, &mut trap_sink)
|
.compile_and_emit(&*isa, &mut code_buf, &mut reloc_sink, &mut trap_sink)
|
||||||
.map_err(|e| {
|
.map_err(|e| {
|
||||||
println!("CompileError: {}", e.to_string());
|
debug!("CompileError: {}", e.to_string());
|
||||||
ErrorKind::CompileError(e.to_string())
|
ErrorKind::CompileError(e.to_string())
|
||||||
})?;
|
})?;
|
||||||
// We set this code_buf to be readable & executable
|
// We set this code_buf to be readable & executable
|
||||||
|
Reference in New Issue
Block a user