Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/coding_guidelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:

jobs:
compliance_job:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions core/iwasm/aot/aot_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -2807,6 +2807,7 @@ aot_create_call_stack(struct WASMExecEnv *exec_env)
total_len += \
wasm_runtime_dump_line_buf_impl(line_buf, print, &buf, &len); \
if ((!print) && buf && (len == 0)) { \
exception_unlock(module_inst); \
return total_len; \
} \
} while (0)
Expand All @@ -2829,6 +2830,7 @@ aot_dump_call_stack(WASMExecEnv *exec_env, bool print, char *buf, uint32 len)
return 0;
}

exception_lock(module_inst);
snprintf(line_buf, sizeof(line_buf), "\n");
PRINT_OR_DUMP();

Expand All @@ -2837,6 +2839,7 @@ aot_dump_call_stack(WASMExecEnv *exec_env, bool print, char *buf, uint32 len)
uint32 line_length, i;

if (!bh_vector_get(module_inst->frames, n, &frame)) {
exception_unlock(module_inst);
return 0;
}

Expand Down Expand Up @@ -2867,6 +2870,7 @@ aot_dump_call_stack(WASMExecEnv *exec_env, bool print, char *buf, uint32 len)
}
snprintf(line_buf, sizeof(line_buf), "\n");
PRINT_OR_DUMP();
exception_unlock(module_inst);

return total_len + 1;
}
Expand Down
10 changes: 1 addition & 9 deletions core/iwasm/common/wasm_application.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
char *argv[])
{
bool ret;
#if (WASM_ENABLE_MEMORY_PROFILING != 0) || (WASM_ENABLE_DUMP_CALL_STACK != 0)
#if (WASM_ENABLE_MEMORY_PROFILING != 0)
WASMExecEnv *exec_env;
#endif

Expand All @@ -251,14 +251,6 @@ wasm_application_execute_main(WASMModuleInstanceCommon *module_inst, int32 argc,
if (ret)
ret = wasm_runtime_get_exception(module_inst) == NULL;

#if WASM_ENABLE_DUMP_CALL_STACK != 0
if (!ret) {
exec_env = wasm_runtime_get_exec_env_singleton(module_inst);
if (exec_env)
wasm_runtime_dump_call_stack(exec_env);
}
#endif

return ret;
}

Expand Down
2 changes: 2 additions & 0 deletions core/iwasm/compilation/aot_emit_aot_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,7 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
|| (obj_data->target_info.bin_type == AOT_COFF32_BIN_TYPE
&& !strncmp(name, "_", 1)
&& !strcmp(name + 1, aot_stack_sizes_alias_name)))) {
#if 0 /* cf. https://github.com/llvm/llvm-project/issues/67765 */
uint64 sz = LLVMGetSymbolSize(sym_itr);
if (sz != sizeof(uint32) * obj_data->func_count
/* sz of COFF64/COFF32 is 0, ignore the check */
Expand All @@ -2711,6 +2712,7 @@ aot_resolve_stack_sizes(AOTCompContext *comp_ctx, AOTObjectData *obj_data)
aot_set_last_error("stack_sizes had unexpected size.");
goto fail;
}
#endif
uint64 addr = LLVMGetSymbolAddress(sym_itr);
if (!(sec_itr =
LLVMObjectFileCopySectionIterator(obj_data->binary))) {
Expand Down
3 changes: 0 additions & 3 deletions core/iwasm/interpreter/wasm_interp_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -4209,7 +4209,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
unsigned frame_size = wasm_interp_interp_frame_size(all_cell_num);
unsigned i;
bool copy_argv_from_frame = true;
char exception[EXCEPTION_BUF_LEN];

if (argc < function->param_cell_num) {
char buf[128];
Expand Down Expand Up @@ -4342,8 +4341,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
wasm_interp_dump_call_stack(exec_env, true, NULL, 0);
}
#endif
wasm_copy_exception(module_inst, exception);
LOG_DEBUG("meet an exception %s", exception);
}

wasm_exec_env_set_cur_frame(exec_env, prev_frame);
Expand Down
3 changes: 0 additions & 3 deletions core/iwasm/interpreter/wasm_interp_fast.c
Original file line number Diff line number Diff line change
Expand Up @@ -3945,7 +3945,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
/* This frame won't be used by JITed code, so only allocate interp
frame here. */
unsigned frame_size = wasm_interp_interp_frame_size(all_cell_num);
char exception[EXCEPTION_BUF_LEN];

if (argc < function->param_cell_num) {
char buf[128];
Expand Down Expand Up @@ -4030,8 +4029,6 @@ wasm_interp_call_wasm(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
wasm_interp_dump_call_stack(exec_env, true, NULL, 0);
}
#endif
wasm_copy_exception(module_inst, exception);
LOG_DEBUG("meet an exception %s", exception);
}

wasm_exec_env_set_cur_frame(exec_env, prev_frame);
Expand Down
4 changes: 4 additions & 0 deletions core/iwasm/interpreter/wasm_runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -2915,6 +2915,7 @@ wasm_interp_create_call_stack(struct WASMExecEnv *exec_env)
total_len += \
wasm_runtime_dump_line_buf_impl(line_buf, print, &buf, &len); \
if ((!print) && buf && (len == 0)) { \
exception_unlock(module_inst); \
return total_len; \
} \
} while (0)
Expand All @@ -2939,6 +2940,7 @@ wasm_interp_dump_call_stack(struct WASMExecEnv *exec_env, bool print, char *buf,
return 0;
}

exception_lock(module_inst);
snprintf(line_buf, sizeof(line_buf), "\n");
PRINT_OR_DUMP();

Expand All @@ -2947,6 +2949,7 @@ wasm_interp_dump_call_stack(struct WASMExecEnv *exec_env, bool print, char *buf,
uint32 line_length, i;

if (!bh_vector_get(module_inst->frames, n, &frame)) {
exception_unlock(module_inst);
return 0;
}

Expand Down Expand Up @@ -2977,6 +2980,7 @@ wasm_interp_dump_call_stack(struct WASMExecEnv *exec_env, bool print, char *buf,
}
snprintf(line_buf, sizeof(line_buf), "\n");
PRINT_OR_DUMP();
exception_unlock(module_inst);

return total_len + 1;
}
Expand Down
13 changes: 9 additions & 4 deletions product-mini/platforms/posix/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ app_instance_main(wasm_module_inst_t module_inst)
const char *exception;

wasm_application_execute_main(module_inst, app_argc, app_argv);
if ((exception = wasm_runtime_get_exception(module_inst)))
printf("%s\n", exception);
exception = wasm_runtime_get_exception(module_inst);
return exception;
}

Expand Down Expand Up @@ -977,17 +976,20 @@ main(int argc, char *argv[])
#endif

ret = 0;
const char *exception = NULL;
if (is_repl_mode) {
app_instance_repl(wasm_module_inst);
}
else if (func_name) {
if (app_instance_func(wasm_module_inst, func_name)) {
exception = app_instance_func(wasm_module_inst, func_name);
if (exception) {
/* got an exception */
ret = 1;
}
}
else {
if (app_instance_main(wasm_module_inst)) {
exception = app_instance_main(wasm_module_inst);
if (exception) {
/* got an exception */
ret = 1;
}
Expand All @@ -1000,6 +1002,9 @@ main(int argc, char *argv[])
}
#endif

if (exception)
printf("%s\n", exception);

#if WASM_ENABLE_STATIC_PGO != 0 && WASM_ENABLE_AOT != 0
if (get_package_type(wasm_file_buf, wasm_file_size) == Wasm_Module_AoT
&& gen_prof_file)
Expand Down
13 changes: 9 additions & 4 deletions product-mini/platforms/windows/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ app_instance_main(wasm_module_inst_t module_inst)
const char *exception;

wasm_application_execute_main(module_inst, app_argc, app_argv);
if ((exception = wasm_runtime_get_exception(module_inst)))
printf("%s\n", exception);
exception = wasm_runtime_get_exception(module_inst);
return exception;
}

Expand Down Expand Up @@ -545,17 +544,20 @@ main(int argc, char *argv[])
#endif

ret = 0;
const char *exception = NULL;
if (is_repl_mode) {
app_instance_repl(wasm_module_inst);
}
else if (func_name) {
if (app_instance_func(wasm_module_inst, func_name)) {
exception = app_instance_func(wasm_module_inst, func_name);
if (exception) {
/* got an exception */
ret = 1;
}
}
else {
if (app_instance_main(wasm_module_inst)) {
exception = app_instance_main(wasm_module_inst);
if (exception) {
/* got an exception */
ret = 1;
}
Expand All @@ -568,6 +570,9 @@ main(int argc, char *argv[])
}
#endif

if (exception)
printf("%s\n", exception);

#if WASM_ENABLE_DEBUG_INTERP != 0
fail4:
#endif
Expand Down