diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c index 282dc1d67..9312b59c5 100644 --- a/core/iwasm/aot/aot_loader.c +++ b/core/iwasm/aot/aot_loader.c @@ -3335,7 +3335,7 @@ load(const uint8 *buf, uint32 size, AOTModule *module, char *error_buf, { uint32 i; for (i = 0; i < module->func_count; i++) { - os_printf("AOT func %u, addr: %p\n", i, module->func_ptrs[i]); + LOG_VERBOSE("AOT func %u, addr: %p\n", i, module->func_ptrs[i]); } } #endif diff --git a/core/iwasm/common/wasm_runtime_common.c b/core/iwasm/common/wasm_runtime_common.c index 767e417b3..bca70ba70 100644 --- a/core/iwasm/common/wasm_runtime_common.c +++ b/core/iwasm/common/wasm_runtime_common.c @@ -376,7 +376,7 @@ runtime_exception_handler(EXCEPTION_POINTERS *exce_info) #endif } - os_printf("Unhandled exception thrown: exception code: 0x%lx, " + LOG_ERROR("Unhandled exception thrown: exception code: 0x%lx, " "exception address: %p, exception information: %p\n", ExceptionRecord->ExceptionCode, ExceptionRecord->ExceptionAddress, sig_addr); diff --git a/core/iwasm/fast-jit/jit_compiler.c b/core/iwasm/fast-jit/jit_compiler.c index 958d0e987..2c686dd33 100644 --- a/core/iwasm/fast-jit/jit_compiler.c +++ b/core/iwasm/fast-jit/jit_compiler.c @@ -160,10 +160,10 @@ jit_compiler_compile(WASMModule *module, uint32 func_idx) #if WASM_ENABLE_CUSTOM_NAME_SECTION != 0 char *function_name = cc->cur_wasm_func->field_name; - os_printf("fast jit compilation failed: %s (function_name=%s)\n", + LOG_ERROR("fast jit compilation failed: %s (function_name=%s)\n", last_error ? last_error : "unknown error", function_name); #else - os_printf("fast jit compilation failed: %s\n", + LOG_ERROR("fast jit compilation failed: %s\n", last_error ? last_error : "unknown error"); #endif diff --git a/core/iwasm/fast-jit/jit_frontend.c b/core/iwasm/fast-jit/jit_frontend.c index e9d7a3ff3..e1a520a50 100644 --- a/core/iwasm/fast-jit/jit_frontend.c +++ b/core/iwasm/fast-jit/jit_frontend.c @@ -1093,7 +1093,7 @@ init_func_translation(JitCompContext *cc) || !(jit_frame = jit_calloc(offsetof(JitFrame, lp) + sizeof(*jit_frame->lp) * (max_locals + max_stacks)))) { - os_printf("allocate jit frame failed\n"); + LOG_ERROR("allocate jit frame failed\n"); return NULL; } diff --git a/core/iwasm/interpreter/wasm_loader.c b/core/iwasm/interpreter/wasm_loader.c index 8d4b66797..c436dfa70 100644 --- a/core/iwasm/interpreter/wasm_loader.c +++ b/core/iwasm/interpreter/wasm_loader.c @@ -3300,7 +3300,7 @@ orcjit_thread_callback(void *arg) /* Compile fast jit funcitons of this group */ for (i = group_idx; i < func_count; i += group_stride) { if (!jit_compiler_compile(module, i + module->import_function_count)) { - os_printf("failed to compile fast jit function %u\n", i); + LOG_ERROR("failed to compile fast jit function %u\n", i); break; } @@ -3327,7 +3327,7 @@ orcjit_thread_callback(void *arg) if (!jit_compiler_set_call_to_fast_jit( module, i + j * group_stride + module->import_function_count)) { - os_printf( + LOG_ERROR( "failed to compile call_to_fast_jit for func %u\n", i + j * group_stride + module->import_function_count); module->orcjit_stop_compiling = true; @@ -3377,7 +3377,7 @@ orcjit_thread_callback(void *arg) LLVMOrcLLLazyJITLookup(comp_ctx->orc_jit, &func_addr, func_name); if (error != LLVMErrorSuccess) { char *err_msg = LLVMGetErrorMessage(error); - os_printf("failed to compile llvm jit function %u: %s", i, err_msg); + LOG_ERROR("failed to compile llvm jit function %u: %s", i, err_msg); LLVMDisposeErrorMessage(err_msg); break; } @@ -3398,7 +3398,7 @@ orcjit_thread_callback(void *arg) func_name); if (error != LLVMErrorSuccess) { char *err_msg = LLVMGetErrorMessage(error); - os_printf("failed to compile llvm jit function %u: %s", i, + LOG_ERROR("failed to compile llvm jit function %u: %s", i, err_msg); LLVMDisposeErrorMessage(err_msg); /* Ignore current llvm jit func, as its func ptr is diff --git a/core/iwasm/interpreter/wasm_mini_loader.c b/core/iwasm/interpreter/wasm_mini_loader.c index c78da88ea..e186a518b 100644 --- a/core/iwasm/interpreter/wasm_mini_loader.c +++ b/core/iwasm/interpreter/wasm_mini_loader.c @@ -2024,7 +2024,7 @@ orcjit_thread_callback(void *arg) /* Compile fast jit funcitons of this group */ for (i = group_idx; i < func_count; i += group_stride) { if (!jit_compiler_compile(module, i + module->import_function_count)) { - os_printf("failed to compile fast jit function %u\n", i); + LOG_ERROR("failed to compile fast jit function %u\n", i); break; } @@ -2051,7 +2051,7 @@ orcjit_thread_callback(void *arg) if (!jit_compiler_set_call_to_fast_jit( module, i + j * group_stride + module->import_function_count)) { - os_printf( + LOG_ERROR( "failed to compile call_to_fast_jit for func %u\n", i + j * group_stride + module->import_function_count); module->orcjit_stop_compiling = true; @@ -2101,7 +2101,7 @@ orcjit_thread_callback(void *arg) LLVMOrcLLLazyJITLookup(comp_ctx->orc_jit, &func_addr, func_name); if (error != LLVMErrorSuccess) { char *err_msg = LLVMGetErrorMessage(error); - os_printf("failed to compile llvm jit function %u: %s", i, err_msg); + LOG_ERROR("failed to compile llvm jit function %u: %s", i, err_msg); LLVMDisposeErrorMessage(err_msg); break; } @@ -2122,7 +2122,7 @@ orcjit_thread_callback(void *arg) func_name); if (error != LLVMErrorSuccess) { char *err_msg = LLVMGetErrorMessage(error); - os_printf("failed to compile llvm jit function %u: %s", i, + LOG_ERROR("failed to compile llvm jit function %u: %s", i, err_msg); LLVMDisposeErrorMessage(err_msg); /* Ignore current llvm jit func, as its func ptr is diff --git a/core/iwasm/libraries/libc-emcc/libc_emcc_wrapper.c b/core/iwasm/libraries/libc-emcc/libc_emcc_wrapper.c index 23c02aad3..c21b96261 100644 --- a/core/iwasm/libraries/libc-emcc/libc_emcc_wrapper.c +++ b/core/iwasm/libraries/libc-emcc/libc_emcc_wrapper.c @@ -269,14 +269,14 @@ getentropy_wrapper(wasm_exec_env_t exec_env, void *buffer, uint32 length) static int setjmp_wrapper(wasm_exec_env_t exec_env, void *jmp_buf) { - os_printf("setjmp() called\n"); + LOG_DEBUG("setjmp() called\n"); return 0; } static void longjmp_wrapper(wasm_exec_env_t exec_env, void *jmp_buf, int val) { - os_printf("longjmp() called\n"); + LOG_DEBUG("longjmp() called\n"); } #if !defined(BH_PLATFORM_LINUX_SGX) diff --git a/core/shared/mem-alloc/ems/ems_alloc.c b/core/shared/mem-alloc/ems/ems_alloc.c index 0e2c4da7c..047714be9 100644 --- a/core/shared/mem-alloc/ems/ems_alloc.c +++ b/core/shared/mem-alloc/ems/ems_alloc.c @@ -199,7 +199,7 @@ unlink_hmu(gc_heap_t *heap, hmu_t *hmu) } if (!node) { - os_printf("[GC_ERROR]couldn't find the node in the normal list\n"); + LOG_ERROR("[GC_ERROR]couldn't find the node in the normal list\n"); } } else { @@ -504,7 +504,7 @@ gc_alloc_vo_internal(void *vheap, gc_size_t size, const char *file, int line) #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 if (heap->is_heap_corrupted) { - os_printf("[GC_ERROR]Heap is corrupted, allocate memory failed.\n"); + LOG_ERROR("[GC_ERROR]Heap is corrupted, allocate memory failed.\n"); return NULL; } #endif @@ -566,7 +566,7 @@ gc_realloc_vo_internal(void *vheap, void *ptr, gc_size_t size, const char *file, #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 if (heap->is_heap_corrupted) { - os_printf("[GC_ERROR]Heap is corrupted, allocate memory failed.\n"); + LOG_ERROR("[GC_ERROR]Heap is corrupted, allocate memory failed.\n"); return NULL; } #endif @@ -693,7 +693,7 @@ gc_free_vo_internal(void *vheap, gc_object_t obj, const char *file, int line) #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 if (heap->is_heap_corrupted) { - os_printf("[GC_ERROR]Heap is corrupted, free memory failed.\n"); + LOG_ERROR("[GC_ERROR]Heap is corrupted, free memory failed.\n"); return GC_ERROR; } #endif @@ -815,7 +815,7 @@ gci_dump(gc_heap_t *heap) #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 if (size == 0 || size > (uint32)((uint8 *)end - (uint8 *)cur)) { - os_printf("[GC_ERROR]Heap is corrupted, heap dump failed.\n"); + LOG_ERROR("[GC_ERROR]Heap is corrupted, heap dump failed.\n"); heap->is_heap_corrupted = true; return; } @@ -838,7 +838,7 @@ gci_dump(gc_heap_t *heap) #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 if (cur != end) { - os_printf("[GC_ERROR]Heap is corrupted, heap dump failed.\n"); + LOG_ERROR("[GC_ERROR]Heap is corrupted, heap dump failed.\n"); heap->is_heap_corrupted = true; } #else diff --git a/core/shared/mem-alloc/ems/ems_hmu.c b/core/shared/mem-alloc/ems/ems_hmu.c index f9d7c0f4a..bb4f026b7 100644 --- a/core/shared/mem-alloc/ems/ems_hmu.c +++ b/core/shared/mem-alloc/ems/ems_hmu.c @@ -80,7 +80,7 @@ hmu_verify(void *vheap, hmu_t *hmu) } if (!is_padding_ok) { - os_printf("Invalid padding for object created at %s:%d\n", + LOG_ERROR("Invalid padding for object created at %s:%d\n", (prefix->file_name ? prefix->file_name : ""), prefix->line_no); #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 diff --git a/core/shared/mem-alloc/ems/ems_kfc.c b/core/shared/mem-alloc/ems/ems_kfc.c index 1dda3ae03..4498bb1e7 100644 --- a/core/shared/mem-alloc/ems/ems_kfc.c +++ b/core/shared/mem-alloc/ems/ems_kfc.c @@ -15,7 +15,7 @@ gc_init_internal(gc_heap_t *heap, char *base_addr, gc_size_t heap_max_size) ret = os_mutex_init(&heap->lock); if (ret != BHT_OK) { - os_printf("[GC_ERROR]failed to init lock\n"); + LOG_ERROR("[GC_ERROR]failed to init lock\n"); return NULL; } @@ -61,7 +61,7 @@ gc_init_with_pool(char *buf, gc_size_t buf_size) gc_size_t heap_max_size; if (buf_size < APP_HEAP_SIZE_MIN) { - os_printf("[GC_ERROR]heap init buf size (%" PRIu32 ") < %" PRIu32 "\n", + LOG_ERROR("[GC_ERROR]heap init buf size (%" PRIu32 ") < %" PRIu32 "\n", buf_size, (uint32)APP_HEAP_SIZE_MIN); return NULL; } @@ -90,23 +90,23 @@ gc_init_with_struct_and_pool(char *struct_buf, gc_size_t struct_buf_size, gc_size_t heap_max_size; if ((((uintptr_t)struct_buf) & 7) != 0) { - os_printf("[GC_ERROR]heap init struct buf not 8-byte aligned\n"); + LOG_ERROR("[GC_ERROR]heap init struct buf not 8-byte aligned\n"); return NULL; } if (struct_buf_size < sizeof(gc_handle_t)) { - os_printf("[GC_ERROR]heap init struct buf size (%" PRIu32 ") < %zu\n", + LOG_ERROR("[GC_ERROR]heap init struct buf size (%" PRIu32 ") < %zu\n", struct_buf_size, sizeof(gc_handle_t)); return NULL; } if ((((uintptr_t)pool_buf) & 7) != 0) { - os_printf("[GC_ERROR]heap init pool buf not 8-byte aligned\n"); + LOG_ERROR("[GC_ERROR]heap init pool buf not 8-byte aligned\n"); return NULL; } if (pool_buf_size < APP_HEAP_SIZE_MIN) { - os_printf("[GC_ERROR]heap init buf size (%" PRIu32 ") < %u\n", + LOG_ERROR("[GC_ERROR]heap init buf size (%" PRIu32 ") < %u\n", pool_buf_size, APP_HEAP_SIZE_MIN); return NULL; } @@ -138,7 +138,7 @@ gc_destroy_with_pool(gc_handle_t handle) !heap->is_heap_corrupted && #endif (hmu_t *)((char *)cur + hmu_get_size(cur)) != end) { - os_printf("Memory leak detected:\n"); + LOG_WARNING("Memory leak detected:\n"); gci_dump(heap); ret = GC_ERROR; } @@ -175,14 +175,14 @@ gc_migrate(gc_handle_t handle, char *pool_buf_new, gc_size_t pool_buf_size) gc_size_t heap_max_size, size; if ((((uintptr_t)pool_buf_new) & 7) != 0) { - os_printf("[GC_ERROR]heap migrate pool buf not 8-byte aligned\n"); + LOG_ERROR("[GC_ERROR]heap migrate pool buf not 8-byte aligned\n"); return GC_ERROR; } heap_max_size = (uint32)(pool_buf_end - base_addr_new) & (uint32)~7; if (pool_buf_end < base_addr_new || heap_max_size < heap->current_size) { - os_printf("[GC_ERROR]heap migrate invlaid pool buf size\n"); + LOG_ERROR("[GC_ERROR]heap migrate invlaid pool buf size\n"); return GC_ERROR; } @@ -191,7 +191,7 @@ gc_migrate(gc_handle_t handle, char *pool_buf_new, gc_size_t pool_buf_size) #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 if (heap->is_heap_corrupted) { - os_printf("[GC_ERROR]Heap is corrupted, heap migrate failed.\n"); + LOG_ERROR("[GC_ERROR]Heap is corrupted, heap migrate failed.\n"); return GC_ERROR; } #endif @@ -218,7 +218,7 @@ gc_migrate(gc_handle_t handle, char *pool_buf_new, gc_size_t pool_buf_size) #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 if (size <= 0 || size > (uint32)((uint8 *)end - (uint8 *)cur)) { - os_printf("[GC_ERROR]Heap is corrupted, heap migrate failed.\n"); + LOG_ERROR("[GC_ERROR]Heap is corrupted, heap migrate failed.\n"); heap->is_heap_corrupted = true; return GC_ERROR; } @@ -247,7 +247,7 @@ gc_migrate(gc_handle_t handle, char *pool_buf_new, gc_size_t pool_buf_size) #if BH_ENABLE_GC_CORRUPTION_CHECK != 0 if (cur != end) { - os_printf("[GC_ERROR]Heap is corrupted, heap migrate failed.\n"); + LOG_ERROR("[GC_ERROR]Heap is corrupted, heap migrate failed.\n"); heap->is_heap_corrupted = true; return GC_ERROR; } diff --git a/core/shared/utils/bh_assert.c b/core/shared/utils/bh_assert.c index 246c55d1b..5e62baaf3 100644 --- a/core/shared/utils/bh_assert.c +++ b/core/shared/utils/bh_assert.c @@ -18,7 +18,7 @@ bh_assert_internal(int64 v, const char *file_name, int line_number, if (!expr_string) expr_string = "NULL EXPR_STRING"; - os_printf("\nASSERTION FAILED: %s, at file %s, line %d\n", expr_string, + LOG_ERROR("\nASSERTION FAILED: %s, at file %s, line %d\n", expr_string, file_name, line_number); abort();