Skip to content

Commit ea50bd2

Browse files
authored
Support dump call stack on exception and dump call stack on nuttx (#2042)
1 parent 0ee6e18 commit ea50bd2

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

core/iwasm/common/wasm_application.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, char *argv[])
195195

196196
if (argv_buf_offset)
197197
wasm_runtime_module_free(module_inst, argv_buf_offset);
198+
198199
return ret;
199200
}
200201

@@ -203,7 +204,7 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
203204
char *argv[])
204205
{
205206
bool ret;
206-
#if WASM_ENABLE_MEMORY_PROFILING != 0
207+
#if (WASM_ENABLE_MEMORY_PROFILING != 0) || (WASM_ENABLE_DUMP_CALL_STACK != 0)
207208
WASMExecEnv *exec_env;
208209
#endif
209210

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

223-
return (ret && !wasm_runtime_get_exception(module_inst)) ? true : false;
224+
if (ret)
225+
ret = wasm_runtime_get_exception(module_inst) == NULL;
226+
227+
#if WASM_ENABLE_DUMP_CALL_STACK != 0
228+
if (!ret)
229+
wasm_runtime_dump_call_stack(exec_env);
230+
#endif
231+
232+
return ret;
224233
}
225234

226235
/**

product-mini/platforms/nuttx/wamr.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,12 @@ else
216216
CFLAGS += -DWASM_ENABLE_MEMORY_TRACING=0
217217
endif
218218

219+
ifeq ($(CONFIG_INTERPRETERS_WAMR_DUMP_CALL_STACK),y)
220+
CFLAGS += -DWASM_ENABLE_DUMP_CALL_STACK=1
221+
else
222+
CFLAGS += -DWASM_ENABLE_DUMP_CALL_STACK=0
223+
endif
224+
219225
ifeq ($(CONFIG_INTERPRETERS_WAMR_LIBC_BUILTIN),y)
220226
CFLAGS += -DWASM_ENABLE_LIBC_BUILTIN=1
221227
CSRCS += libc_builtin_wrapper.c

0 commit comments

Comments
 (0)