Skip to content

Commit

Permalink
Merge pull request #67 from wasmerio/feature/add-debug-argument-info
Browse files Browse the repository at this point in the history
Add debug argument info
  • Loading branch information
syrusakbary committed Dec 18, 2018
2 parents 310deb9 + fd94c2d commit cf2f918
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 86 deletions.
2 changes: 1 addition & 1 deletion src/apis/emscripten/errno.rs
@@ -1,7 +1,7 @@
// use std::collections::HashMap;

pub extern "C" fn ___seterrno(value: i32) -> i32 {
debug!("emscripten::___seterrno");
debug!("emscripten::___seterrno {}", value);
// TODO: Incomplete impl
eprintln!("failed to set errno!");
value
Expand Down
2 changes: 1 addition & 1 deletion src/apis/emscripten/io.rs
Expand Up @@ -7,7 +7,7 @@ pub use libc::putchar;

/// printf
pub extern "C" fn printf(memory_offset: i32, extra: i32, instance: &Instance) -> i32 {
debug!("emscripten::printf");
debug!("emscripten::printf {}, {}", memory_offset, extra);
unsafe {
let addr = instance.memory_offset_addr(0, memory_offset as _) as _;
_printf(addr, extra)
Expand Down
8 changes: 4 additions & 4 deletions src/apis/emscripten/lock.rs
Expand Up @@ -2,11 +2,11 @@ use crate::webassembly::Instance;
use libc::c_int;

// NOTE: Not implemented by Emscripten
pub extern "C" fn ___lock(_which: c_int, _varargs: c_int, _instance: &mut Instance) {
debug!("emscripten::___lock");
pub extern "C" fn ___lock(which: c_int, varargs: c_int, _instance: &mut Instance) {
debug!("emscripten::___lock {}, {}", which, varargs);
}

// NOTE: Not implemented by Emscripten
pub extern "C" fn ___unlock(_which: c_int, _varargs: c_int, _instance: &mut Instance) {
debug!("emscripten::___unlock");
pub extern "C" fn ___unlock(which: c_int, varargs: c_int, _instance: &mut Instance) {
debug!("emscripten::___unlock {}, {}", which, varargs);
}
5 changes: 4 additions & 1 deletion src/apis/emscripten/memory.rs
Expand Up @@ -9,7 +9,10 @@ pub extern "C" fn _emscripten_memcpy_big(
len: u32,
instance: &mut Instance,
) -> u32 {
debug!("emscripten::_emscripten_memcpy_big");
debug!(
"emscripten::_emscripten_memcpy_big {}, {}, {}",
dest, src, len
);
let dest_addr = instance.memory_offset_addr(0, dest as usize) as *mut c_void;
let src_addr = instance.memory_offset_addr(0, src as usize) as *mut c_void;
unsafe {
Expand Down
40 changes: 20 additions & 20 deletions src/apis/emscripten/nullfunc.rs
@@ -1,52 +1,52 @@
use super::process::abort_with_message;
use crate::webassembly::Instance;

pub extern "C" fn nullfunc_ii(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_ii");
pub extern "C" fn nullfunc_ii(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_ii {}", x);
abort_with_message("Invalid function pointer called with signature 'ii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_iii(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_iii");
pub extern "C" fn nullfunc_iii(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_iii {}", x);
abort_with_message("Invalid function pointer called with signature 'iii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_iiii(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_iiii");
pub extern "C" fn nullfunc_iiii(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_iiii {}", x);
abort_with_message("Invalid function pointer called with signature 'iiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_iiiii(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_iiiii");
pub extern "C" fn nullfunc_iiiii(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_iiiii {}", x);
abort_with_message("Invalid function pointer called with signature 'iiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_iiiiii(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_iiiiii");
pub extern "C" fn nullfunc_iiiiii(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_iiiiii {}", x);
abort_with_message("Invalid function pointer called with signature 'iiiiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_v(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_v");
pub extern "C" fn nullfunc_v(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_v {}", x);
abort_with_message("Invalid function pointer called with signature 'v'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_vi(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_vi");
pub extern "C" fn nullfunc_vi(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_vi {}", x);
abort_with_message("Invalid function pointer called with signature 'vi'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_vii(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_vii");
pub extern "C" fn nullfunc_vii(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_vii {}", x);
abort_with_message("Invalid function pointer called with signature 'vii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_viii(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_viii");
pub extern "C" fn nullfunc_viii(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_viii {}", x);
abort_with_message("Invalid function pointer called with signature 'viii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}

pub extern "C" fn nullfunc_viiii(_x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_viiii");
pub extern "C" fn nullfunc_viiii(x: u32, _instance: &Instance) {
debug!("emscripten::nullfunc_viiii {}", x);
abort_with_message("Invalid function pointer called with signature 'viiii'. Perhaps this is an invalid value (e.g. caused by calling a virtual method on a NULL pointer)? Or calling a function with an incorrect type, which will fail? (it is worth building your source files with -Werror (warnings are errors), as warnings can indicate undefined behavior which can cause this)");
}
4 changes: 2 additions & 2 deletions src/apis/emscripten/process.rs
Expand Up @@ -25,12 +25,12 @@ pub extern "C" fn _fork(_instance: &mut Instance) -> pid_t {
}

pub extern "C" fn _exit(status: c_int, _instance: &mut Instance) -> ! {
debug!("emscripten::_exit");
debug!("emscripten::_exit {}", status);
unsafe { exit(status) }
}

pub extern "C" fn em_abort(message: u32, instance: &mut Instance) {
debug!("emscripten::em_abort");
debug!("emscripten::em_abort {}", message);
let message_addr = instance.memory_offset_addr(0, message as usize) as *mut c_char;
unsafe {
let message = CStr::from_ptr(message_addr)
Expand Down
11 changes: 3 additions & 8 deletions src/apis/emscripten/signal.rs
Expand Up @@ -10,18 +10,13 @@ pub extern "C" fn _sigemptyset(set: u32, instance: &mut Instance) -> i32 {
0
}

pub extern "C" fn _sigaction(
_signum: u32,
_act: u32,
_oldact: u32,
_instance: &mut Instance,
) -> i32 {
debug!("emscripten::_sigaction");
pub extern "C" fn _sigaction(signum: u32, act: u32, oldact: u32, _instance: &mut Instance) -> i32 {
debug!("emscripten::_sigaction {}, {}, {}", signum, act, oldact);
0
}

pub extern "C" fn _sigaddset(set: u32, signum: u32, instance: &mut Instance) -> i32 {
debug!("emscripten::_sigaddset");
debug!("emscripten::_sigaddset {}, {}", set, signum);
let set_addr = instance.memory_offset_addr(0, set as _) as *mut u32;
unsafe {
*set_addr |= 1 << (signum - 1);
Expand Down

0 comments on commit cf2f918

Please sign in to comment.