mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2024-11-26 15:32:05 +00:00
Use logger for runtime error/debug prints (#3097)
Change runtime internal error/debug prints from using `os_printf()` to using `LOG_ERROR()`/`LOG_DEBUG()`.
This commit is contained in:
parent
f359b51525
commit
cfa90ca44f
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue
Block a user