[debugger enhance] don't block gdbserver thread while executing (#989)
Allow to set break point again when all break points are removed and wasm app starts running.
This commit is contained in:
@ -284,6 +284,22 @@ wasm_cluster_del_exec_env(WASMCluster *cluster, WASMExecEnv *exec_env)
|
||||
{
|
||||
bool ret = true;
|
||||
bh_assert(exec_env->cluster == cluster);
|
||||
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
/* Wait for debugger control thread to process the
|
||||
stop event of this thread */
|
||||
if (cluster->debug_inst) {
|
||||
/* lock the debug_inst->wait_lock so
|
||||
other threads can't fire stop events */
|
||||
os_mutex_lock(&cluster->debug_inst->wait_lock);
|
||||
while (cluster->debug_inst->stopped_thread == exec_env) {
|
||||
os_cond_wait(&cluster->debug_inst->wait_cond,
|
||||
&cluster->debug_inst->wait_lock);
|
||||
}
|
||||
os_mutex_unlock(&cluster->debug_inst->wait_lock);
|
||||
}
|
||||
#endif
|
||||
|
||||
os_mutex_lock(&cluster->lock);
|
||||
if (bh_list_remove(&cluster->exec_env_list, exec_env) != 0)
|
||||
ret = false;
|
||||
@ -447,6 +463,9 @@ thread_manager_start_routine(void *arg)
|
||||
free_aux_stack(cluster, exec_env->aux_stack_bottom.bottom);
|
||||
/* Detach the native thread here to ensure the resources are freed */
|
||||
wasm_cluster_detach_thread(exec_env);
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
wasm_cluster_thread_exited(exec_env);
|
||||
#endif
|
||||
/* Remove and destroy exec_env */
|
||||
wasm_cluster_del_exec_env(cluster, exec_env);
|
||||
wasm_exec_env_destroy_internal(exec_env);
|
||||
@ -563,9 +582,7 @@ notify_debug_instance(WASMExecEnv *exec_env)
|
||||
return;
|
||||
}
|
||||
|
||||
os_mutex_lock(&cluster->debug_inst->wait_lock);
|
||||
os_cond_signal(&cluster->debug_inst->wait_cond);
|
||||
os_mutex_unlock(&cluster->debug_inst->wait_lock);
|
||||
on_thread_stop_event(cluster->debug_inst, exec_env);
|
||||
}
|
||||
|
||||
void
|
||||
@ -744,7 +761,6 @@ wasm_cluster_cancel_thread(WASMExecEnv *exec_env)
|
||||
/* Set the termination flag */
|
||||
#if WASM_ENABLE_DEBUG_INTERP != 0
|
||||
wasm_cluster_thread_send_signal(exec_env, WAMR_SIG_TERM);
|
||||
wasm_cluster_thread_exited(exec_env);
|
||||
#else
|
||||
exec_env->suspend_flags.flags |= 0x01;
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user