Skip to content

Commit

Permalink
Support dump call stack on exception and dump call stack on nuttx (by…
Browse files Browse the repository at this point in the history
  • Loading branch information
no1wudi authored Mar 22, 2023
1 parent 0ee6e18 commit ea50bd2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
13 changes: 11 additions & 2 deletions core/iwasm/common/wasm_application.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, char *argv[])

if (argv_buf_offset)
wasm_runtime_module_free(module_inst, argv_buf_offset);

return ret;
}

Expand All @@ -203,7 +204,7 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
char *argv[])
{
bool ret;
#if WASM_ENABLE_MEMORY_PROFILING != 0
#if (WASM_ENABLE_MEMORY_PROFILING != 0) || (WASM_ENABLE_DUMP_CALL_STACK != 0)
WASMExecEnv *exec_env;
#endif

Expand All @@ -220,7 +221,15 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
wasm_runtime_dump_perf_profiling(module_inst);
#endif

return (ret && !wasm_runtime_get_exception(module_inst)) ? true : false;
if (ret)
ret = wasm_runtime_get_exception(module_inst) == NULL;

#if WASM_ENABLE_DUMP_CALL_STACK != 0
if (!ret)
wasm_runtime_dump_call_stack(exec_env);
#endif

return ret;
}

/**
Expand Down
6 changes: 6 additions & 0 deletions product-mini/platforms/nuttx/wamr.mk
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,12 @@ else
CFLAGS += -DWASM_ENABLE_MEMORY_TRACING=0
endif

ifeq ($(CONFIG_INTERPRETERS_WAMR_DUMP_CALL_STACK),y)
CFLAGS += -DWASM_ENABLE_DUMP_CALL_STACK=1
else
CFLAGS += -DWASM_ENABLE_DUMP_CALL_STACK=0
endif

ifeq ($(CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN),y)
CFLAGS += -DWASM_ENABLE_LIBC_BUILTIN=1
CSRCS += libc_builtin_wrapper.c
Expand Down

0 comments on commit ea50bd2

Please sign in to comment.