Implement source debugging for interpreter and AOT (#769)

Implement source debugging feature for classic interpreter and AOT:
- use `cmake -DWAMR_BUILD_DEBUG_INTERP=1` to enable interpreter debugging
- use `cmake -DWAMR_BUILD_DEBUG_AOT=1` to enable AOT debugging

See doc/source_debugging.md for more details.
This commit is contained in:
Wenyong Huang
2021-09-29 13:36:46 +08:00
committed by GitHub
parent b5a67cb91e
commit 9ef37dd781
55 changed files with 10092 additions and 63 deletions

View File

@ -18,6 +18,9 @@
#if WASM_ENABLE_THREAD_MGR != 0
#include "../libraries/thread-mgr/thread_manager.h"
#if WASM_ENABLE_DEBUG_INTERP != 0
#include "../libraries/debug-engine/debug_engine.h"
#endif
#endif
WASMExecEnv *
@ -46,6 +49,12 @@ wasm_exec_env_create_internal(struct WASMModuleInstanceCommon *module_inst,
if (os_cond_init(&exec_env->wait_cond) != 0)
goto fail3;
#if WASM_ENABLE_DEBUG_INTERP != 0
if (!(exec_env->current_status = wasm_cluster_create_exenv_status()))
goto fail4;
#endif
#endif
exec_env->module_inst = module_inst;
@ -68,6 +77,10 @@ wasm_exec_env_create_internal(struct WASMModuleInstanceCommon *module_inst,
return exec_env;
#if WASM_ENABLE_THREAD_MGR != 0
#if WASM_ENABLE_DEBUG_INTERP != 0
fail4:
os_cond_destroy(&exec_env->wait_cond);
#endif
fail3:
os_mutex_destroy(&exec_env->wait_lock);
fail2:
@ -86,6 +99,9 @@ wasm_exec_env_destroy_internal(WASMExecEnv *exec_env)
#if WASM_ENABLE_THREAD_MGR != 0
os_mutex_destroy(&exec_env->wait_lock);
os_cond_destroy(&exec_env->wait_cond);
#if WASM_ENABLE_DEBUG_INTERP != 0
wasm_cluster_destroy_exenv_status(exec_env->current_status);
#endif
#endif
#if WASM_ENABLE_AOT != 0
wasm_runtime_free(exec_env->argv_buf);
@ -131,6 +147,10 @@ wasm_exec_env_create(struct WASMModuleInstanceCommon *module_inst,
wasm_exec_env_destroy_internal(exec_env);
return NULL;
}
#if WASM_ENABLE_DEBUG_INTERP != 0
wasm_debug_instance_create(cluster);
#endif
#endif
return exec_env;
}
@ -142,6 +162,12 @@ wasm_exec_env_destroy(WASMExecEnv *exec_env)
/* Terminate all sub-threads */
WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env);
if (cluster) {
#if WASM_ENABLE_THREAD_MGR != 0
#if WASM_ENABLE_DEBUG_INTERP != 0
wasm_cluster_thread_exited(exec_env);
wasm_debug_instance_destroy(cluster);
#endif
#endif
wasm_cluster_terminate_all_except_self(cluster, exec_env);
wasm_cluster_del_exec_env(cluster, exec_env);
}