[source debug] refine some code in source debugging (#856)

- move the wait_cond from exec_env to debug_instance, so the debug thread can be waken up by any threads
- process more general query message from debugger
- refine debug instance create/destroy mechanism
- avoid creating debug instance during module instantiating
- avoid blocking execution thread during creating debug instance
- update related documents
This commit is contained in:
Xu Jun
2021-12-06 10:25:38 +08:00
committed by GitHub
parent c8fe1004aa
commit 2af5ae5abb
18 changed files with 401 additions and 145 deletions

View File

@ -294,6 +294,26 @@ get_package_type(const uint8 *buf, uint32 size)
return Package_Type_Unknown;
}
#if (WASM_ENABLE_THREAD_MGR != 0) && (WASM_ENABLE_DEBUG_INTERP != 0)
uint32
wasm_runtime_start_debug_instance(WASMExecEnv *exec_env)
{
WASMCluster *cluster = wasm_exec_env_get_cluster(exec_env);
bh_assert(cluster);
if (cluster->debug_inst) {
LOG_WARNING("Cluster already bind to a debug instance");
return cluster->debug_inst->control_thread->port;
}
if (wasm_debug_instance_create(cluster)) {
return cluster->debug_inst->control_thread->port;
}
return 0;
}
#endif
#if WASM_ENABLE_MULTI_MODULE != 0
static module_reader reader;
static module_destroyer destroyer;
@ -1431,7 +1451,7 @@ wasm_runtime_create_exec_env_and_call_wasm(
if (module_inst->module_type == Wasm_Module_Bytecode)
ret = wasm_create_exec_env_and_call_function(
(WASMModuleInstance *)module_inst, (WASMFunctionInstance *)function,
argc, argv);
argc, argv, true);
#endif
#if WASM_ENABLE_AOT != 0
if (module_inst->module_type == Wasm_Module_AoT)