mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-03-11 16:35:33 +00:00
Improve stack trace dump and fix coding guideline CI (#2599)
Avoid the stack traces getting mixed up together when multi-threading is enabled by using exception_lock/unlock in dumping the call stacks. And remove duplicated call stack dump in wasm_application.c. Also update coding guideline CI to fix the clang-format-12 not found issue.
This commit is contained in:
parent
3c17a36ccb
commit
00539620e9
2
.github/workflows/coding_guidelines.yml
vendored
2
.github/workflows/coding_guidelines.yml
vendored
|
@ -16,7 +16,7 @@ concurrency:
|
|||
|
||||
jobs:
|
||||
compliance_job:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@v3
|
||||
|
|
|
@ -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)
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
|
@ -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();
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -568,6 +570,9 @@ main(int argc, char *argv[])
|
|||
}
|
||||
#endif
|
||||
|
||||
if (exception)
|
||||
printf("%s\n", exception);
|
||||
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
fail4:
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue
Block a user