Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add println #25

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/libwasmer-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ jobs:
- os: ubuntu-18.04
artifact_name: libwasmer_linux_amd64.so
make_target: capi-linux-amd64
- os: macos-11
artifact_name: libwasmer_darwin_amd64.dylib
make_target: capi-osx-amd64
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
1 change: 1 addition & 0 deletions lib/runtime-c-api/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,7 @@ pub unsafe extern "C" fn wasmer_instance_call(
let instance = &mut *(instance as *mut Instance);

wasmer_middleware_common::opcode_trace::reset_opcodetracer_last_location(instance);
println!("WASMER\t\tbegin instance call func {}", func_name_r);
let result = instance.call(func_name_r, &params[..]);

let result = match result {
Expand Down
7 changes: 7 additions & 0 deletions lib/runtime-core/src/fault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ extern "C" fn signal_trap_handler(
siginfo: *mut siginfo_t,
ucontext: *mut c_void,
) {
println!("WASMER\t\t signal_trap_handler");
use crate::backend::{Architecture, InlineBreakpointType};

#[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -343,8 +344,10 @@ extern "C" fn signal_trap_handler(

WAS_SIGINT_TRIGGERED.with(|x| x.set(false));

println!("WASMER\t\t kernel signal {}", signum);
match Signal::from_c_int(signum) {
Ok(SIGTRAP) => {
println!("WASMER\t\t kernel signal {:?}", Signal::from_c_int(signum));
// breakpoint
let out: Option<Result<(), Box<dyn Any + Send>>> =
with_breakpoint_map(|bkpt_map| {
Expand All @@ -366,6 +369,7 @@ extern "C" fn signal_trap_handler(
}
}
Ok(SIGSEGV) | Ok(SIGBUS) => {
println!("WASMER\t\t kernel signal {:?}", Signal::from_c_int(signum));
if fault.faulting_addr as usize == get_wasm_interrupt_signal_mem() as usize {
is_suspend_signal = true;
clear_wasm_interrupt();
Expand All @@ -374,6 +378,9 @@ extern "C" fn signal_trap_handler(
}
}
}
Ok(signal) => {
println!("WASMER\t\t kernel signal {}", signal);
}
_ => {}
}

Expand Down
15 changes: 15 additions & 0 deletions lib/runtime-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ impl Instance {
/// # }
/// ```
pub fn call(&self, name: &str, params: &[Value]) -> CallResult<Vec<Value>> {
println!("WASMER\t\texport_index");
let export_index =
self.module
.info
Expand All @@ -359,6 +360,7 @@ impl Instance {
let func_index = if let ExportIndex::Func(func_index) = export_index {
*func_index
} else {
println!("WASMER\t\tfunc_index error for {}", name.to_string());
return Err(CallError::Resolve(ResolveError::ExportWrongType {
name: name.to_string(),
})
Expand Down Expand Up @@ -586,6 +588,7 @@ fn call_func_with_index(
args: &[Value],
rets: &mut Vec<Value>,
) -> CallResult<()> {
println!("WASMER\t\tcall_func_with_index");
let sig_index = *info
.func_assoc
.get(func_index)
Expand All @@ -602,6 +605,7 @@ fn call_func_with_index(
}
};

println!("WASMER\t\tcall_func_with_index resolve ctx_ptr");
let ctx_ptr = match func_index.local_or_import(info) {
LocalOrImport::Local(_) => local_ctx,
LocalOrImport::Import(imported_func_index) => unsafe {
Expand All @@ -613,6 +617,7 @@ fn call_func_with_index(
.as_ptr(),
};

println!("WASMER\t\tcall_func_with_index resolve prepare trampoline");
let wasm = runnable
.get_trampoline(info, sig_index)
.expect("wasm trampoline");
Expand All @@ -628,6 +633,7 @@ pub(crate) fn call_func_with_index_inner(
args: &[Value],
rets: &mut Vec<Value>,
) -> CallResult<()> {
println!("WASMER\t\tcall_func_with_index_inner");
rets.clear();

let num_results = signature.returns().len();
Expand All @@ -639,6 +645,7 @@ pub(crate) fn call_func_with_index_inner(
.count();
rets.reserve(num_results);

println!("WASMER\t\tcall_func_with_index_inner check_param_value_types");
if !signature.check_param_value_types(args) {
Err(ResolveError::Signature {
expected: signature.clone(),
Expand Down Expand Up @@ -682,6 +689,7 @@ pub(crate) fn call_func_with_index_inner(
let run_wasm = |result_space: *mut u64| unsafe {
let mut error_out = None;

println!("WASMER\t\tcall_func_with_index_inner invoke");
let success = invoke(
trampoline,
ctx_ptr,
Expand All @@ -693,8 +701,10 @@ pub(crate) fn call_func_with_index_inner(
);

if success {
println!("WASMER\t\tcall_func_with_index_inner invoke ok");
Ok(())
} else {
println!("WASMER\t\tcall_func_with_index_inner invoke error");
Err(error_out
.map(RuntimeError)
.unwrap_or_else(|| RuntimeError(Box::new("invoke(): Unknown error".to_string()))))
Expand All @@ -711,12 +721,14 @@ pub(crate) fn call_func_with_index_inner(

match signature.returns() {
&[] => {
println!("WASMER\t\tcall_func_with_index_inner run_wasm 1");
run_wasm(ptr::null_mut())?;
Ok(())
}
&[Type::V128] => {
let mut result = [0u64; 2];

println!("WASMER\t\tcall_func_with_index_inner run_wasm 2");
run_wasm(result.as_mut_ptr())?;

let mut bytes = [0u8; 16];
Expand All @@ -730,6 +742,7 @@ pub(crate) fn call_func_with_index_inner(
&[ty] => {
let mut result = 0u64;

println!("WASMER\t\tcall_func_with_index_inner run_wasm 3");
run_wasm(&mut result)?;

rets.push(raw_to_value(result, ty));
Expand All @@ -739,6 +752,7 @@ pub(crate) fn call_func_with_index_inner(
result_tys @ _ => {
let mut results: SmallVec<[u64; 8]> = smallvec![0; num_results];

println!("WASMER\t\tcall_func_with_index_inner run_wasm 4");
run_wasm(results.as_mut_ptr())?;

rets.extend(
Expand All @@ -748,6 +762,7 @@ pub(crate) fn call_func_with_index_inner(
.map(|(&raw, &ty)| raw_to_value(raw, ty)),
);

println!("WASMER\t\tcall_func_with_index_inner ok");
Ok(())
}
}
Expand Down
Loading