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:
@ -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);
|
||||
}
|
||||
|
||||
@ -20,6 +20,9 @@ struct WASMInterpFrame;
|
||||
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
typedef struct WASMCluster WASMCluster;
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
typedef struct WASMCurrentEnvStatus WASMCurrentEnvStatus;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef OS_ENABLE_HW_BOUND_CHECK
|
||||
@ -97,6 +100,10 @@ typedef struct WASMExecEnv {
|
||||
korp_cond wait_cond;
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
WASMCurrentEnvStatus *current_status;
|
||||
#endif
|
||||
|
||||
/* attachment for native function */
|
||||
void *attachment;
|
||||
|
||||
|
||||
@ -14,9 +14,15 @@
|
||||
#endif
|
||||
#if WASM_ENABLE_AOT != 0
|
||||
#include "../aot/aot_runtime.h"
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
#include "../aot/debug/jit_debug.h"
|
||||
#endif
|
||||
#endif
|
||||
#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
|
||||
#if WASM_ENABLE_SHARED_MEMORY != 0
|
||||
#include "wasm_shared_memory.h"
|
||||
@ -128,20 +134,29 @@ wasm_runtime_env_init()
|
||||
goto fail6;
|
||||
}
|
||||
#endif
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
if (!jit_debug_engine_init()) {
|
||||
goto fail7;
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
if (!wasm_externref_map_init()) {
|
||||
goto fail7;
|
||||
goto fail8;
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
|
||||
#if WASM_ENABLE_REF_TYPES != 0
|
||||
fail7:
|
||||
fail8:
|
||||
#endif
|
||||
#if WASM_ENABLE_AOT != 0
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
jit_debug_engine_destroy();
|
||||
fail7:
|
||||
#endif
|
||||
#ifdef OS_ENABLE_HW_BOUND_CHECK
|
||||
aot_signal_destroy();
|
||||
fail6:
|
||||
@ -201,6 +216,9 @@ wasm_runtime_destroy()
|
||||
#endif
|
||||
|
||||
#if WASM_ENABLE_AOT != 0
|
||||
#if WASM_ENABLE_DEBUG_AOT != 0
|
||||
jit_debug_engine_destroy();
|
||||
#endif
|
||||
#ifdef OS_ENABLE_HW_BOUND_CHECK
|
||||
aot_signal_destroy();
|
||||
#endif
|
||||
@ -220,6 +238,9 @@ wasm_runtime_destroy()
|
||||
#endif
|
||||
|
||||
#if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_THREAD_MGR != 0)
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
wasm_debug_engine_destroy();
|
||||
#endif
|
||||
thread_manager_destroy();
|
||||
#endif
|
||||
|
||||
@ -241,6 +262,16 @@ wasm_runtime_full_init(RuntimeInitArgs *init_args)
|
||||
return false;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
if (strlen(init_args->ip_addr))
|
||||
if (!wasm_debug_engine_init(init_args->ip_addr,
|
||||
init_args->platform_port,
|
||||
init_args->instance_port)) {
|
||||
wasm_runtime_destroy();
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (init_args->n_native_symbols > 0
|
||||
&& !wasm_runtime_register_natives(init_args->native_module_name,
|
||||
init_args->native_symbols,
|
||||
|
||||
@ -774,24 +774,24 @@ wasm_runtime_finalize_call_function(WASMExecEnv *exec_env,
|
||||
|
||||
bool
|
||||
wasm_runtime_get_export_func_type(const WASMModuleCommon *module_comm,
|
||||
const WASMExport *export_func_type,
|
||||
const WASMExport *export_,
|
||||
WASMType **out);
|
||||
|
||||
bool
|
||||
wasm_runtime_get_export_global_type(const WASMModuleCommon *module_comm,
|
||||
const WASMExport *export_global_type,
|
||||
const WASMExport *export_,
|
||||
uint8 *out_val_type,
|
||||
bool *out_mutability);
|
||||
|
||||
bool
|
||||
wasm_runtime_get_export_memory_type(const WASMModuleCommon *module_comm,
|
||||
const WASMExport *export_memory_type,
|
||||
const WASMExport *export_,
|
||||
uint32 *out_min_page,
|
||||
uint32 *out_max_page);
|
||||
|
||||
bool
|
||||
wasm_runtime_get_export_table_type(const WASMModuleCommon *module_comm,
|
||||
const WASMExport *export_table_type,
|
||||
const WASMExport *export_,
|
||||
uint8 *out_elem_type,
|
||||
uint32 *out_min_size,
|
||||
uint32 *out_max_size);
|
||||
|
||||
Reference in New Issue
Block a user