From a2bd8d170fb5a4e140f35c268e0bb0893af8a40f Mon Sep 17 00:00:00 2001 From: Steve Akinyemi Date: Mon, 17 Dec 2018 09:15:08 +0100 Subject: [PATCH] Remove debug prints --- src/apis/emscripten/env.rs | 10 ++++++---- src/apis/emscripten/utils.rs | 4 ---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/apis/emscripten/env.rs b/src/apis/emscripten/env.rs index 00931b49d..7826b3020 100644 --- a/src/apis/emscripten/env.rs +++ b/src/apis/emscripten/env.rs @@ -8,12 +8,13 @@ use std::os::raw::c_char; use super::utils::{copy_cstr_into_wasm, copy_terminated_array_of_cstrs}; use crate::webassembly::Instance; +#[no_mangle] /// emscripten: _getenv // (name: *const char) -> *const c_char; -pub extern "C" fn _getenv(name_ptr: c_int, instance: &mut Instance) -> u32 { - debug!("emscripten::_getenv {}", name_ptr); +pub extern "C" fn _getenv(name: c_int, instance: &mut Instance) -> u32 { + debug!("emscripten::_getenv {}", name); let name = unsafe { - let memory_name_ptr = instance.memory_offset_addr(0, name_ptr as usize) as *const c_char; - CStr::from_ptr(memory_name_ptr).to_str().unwrap() + let name_addr = instance.memory_offset_addr(0, name as usize) as *const c_char; + CStr::from_ptr(name_addr).to_str().unwrap() }; match host::get_env(name, instance) { Ok(env_value) => { @@ -25,6 +26,7 @@ pub extern "C" fn _getenv(name_ptr: c_int, instance: &mut Instance) -> u32 { let c_str = instance.memory_offset_addr(0, res as _) as *mut i8; use std::ffi::CStr; debug!("#### cstr = {:?}", unsafe { CStr::from_ptr(c_str) }); + debug!("res = {}", res); res } Err(_) => 0, diff --git a/src/apis/emscripten/utils.rs b/src/apis/emscripten/utils.rs index 93e1a717e..eae2cc7c6 100644 --- a/src/apis/emscripten/utils.rs +++ b/src/apis/emscripten/utils.rs @@ -33,21 +33,17 @@ pub fn write_to_buf(string: *const c_char, buf: u32, max: u32, instance: &Instan pub unsafe fn copy_cstr_into_wasm(instance: &mut Instance, cstr: *const c_char) -> u32 { let s = CStr::from_ptr(cstr).to_str().unwrap(); let cstr_len = s.len(); - debug!("### 1!"); let space_offset = (instance.emscripten_data.as_ref().unwrap().malloc)((cstr_len as i32) + 1, instance); - debug!("### 2!"); let raw_memory = instance.memory_offset_addr(0, space_offset as _) as *mut u8; let slice = slice::from_raw_parts_mut(raw_memory, cstr_len); for (byte, loc) in s.bytes().zip(slice.iter_mut()) { *loc = byte; } - debug!("### KABOOM 10!"); // TODO: Appending null byte won't work, because there is CStr::from_ptr(cstr) // at the top that crashes when there is no null byte *raw_memory.add(cstr_len) = 0; - debug!("### KABOOM 15!"); space_offset }