wasm_application.c: Do not start debug instance automatically (#1407)

Leave the control from wasm_application_execute_main to host embedders,
eg. product-mini.
This commit is contained in:
YAMAMOTO Takashi 2022-08-24 21:50:26 +09:00 committed by GitHub
parent 1dcc59f234
commit ebcbe0b571
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 11 deletions

View File

@ -107,9 +107,6 @@ execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, char *argv[])
the actual main function. Directly calling main function the actual main function. Directly calling main function
may cause exception thrown. */ may cause exception thrown. */
if ((func = wasm_runtime_lookup_wasi_start_function(module_inst))) { if ((func = wasm_runtime_lookup_wasi_start_function(module_inst))) {
#if WASM_ENABLE_DEBUG_INTERP != 0
wasm_runtime_start_debug_instance(exec_env);
#endif
return wasm_runtime_call_wasm(exec_env, func, 0, NULL); return wasm_runtime_call_wasm(exec_env, func, 0, NULL);
} }
#endif /* end of WASM_ENABLE_LIBC_WASI */ #endif /* end of WASM_ENABLE_LIBC_WASI */
@ -191,10 +188,6 @@ execute_main(WASMModuleInstanceCommon *module_inst, int32 argc, char *argv[])
(uint32)wasm_runtime_addr_native_to_app(module_inst, argv_offsets); (uint32)wasm_runtime_addr_native_to_app(module_inst, argv_offsets);
} }
#if WASM_ENABLE_DEBUG_INTERP != 0
wasm_runtime_start_debug_instance(exec_env);
#endif
ret = wasm_runtime_call_wasm(exec_env, func, argc1, argv1); ret = wasm_runtime_call_wasm(exec_env, func, argc1, argv1);
if (ret && func_type->result_count > 0 && argc > 0 && argv) if (ret && func_type->result_count > 0 && argc > 0 && argv)
/* copy the return value */ /* copy the return value */
@ -618,10 +611,6 @@ execute_func(WASMModuleInstanceCommon *module_inst, const char *name,
goto fail; goto fail;
} }
#if WASM_ENABLE_DEBUG_INTERP != 0
wasm_runtime_start_debug_instance(exec_env);
#endif
if (!wasm_runtime_call_wasm(exec_env, target_func, argc1, argv1)) { if (!wasm_runtime_call_wasm(exec_env, target_func, argc1, argv1)) {
goto fail; goto fail;
} }

View File

@ -568,6 +568,23 @@ main(int argc, char *argv[])
goto fail3; goto fail3;
} }
#if WASM_ENABLE_DEBUG_INTERP != 0
if (ip_addr != NULL) {
wasm_exec_env_t exec_env =
wasm_runtime_get_exec_env_singleton(wasm_module_inst);
uint32_t debug_port;
if (exec_env == NULL) {
printf("%s\n", wasm_runtime_get_exception(wasm_module_inst));
goto fail4;
}
debug_port = wasm_runtime_start_debug_instance(exec_env);
if (debug_port == 0) {
printf("Failed to start debug instance\n");
goto fail4;
}
}
#endif
if (is_repl_mode) if (is_repl_mode)
app_instance_repl(wasm_module_inst); app_instance_repl(wasm_module_inst);
else if (func_name) else if (func_name)
@ -577,6 +594,9 @@ main(int argc, char *argv[])
ret = 0; ret = 0;
#if WASM_ENABLE_DEBUG_INTERP != 0
fail4:
#endif
/* destroy the module instance */ /* destroy the module instance */
wasm_runtime_deinstantiate(wasm_module_inst); wasm_runtime_deinstantiate(wasm_module_inst);

View File

@ -435,6 +435,23 @@ main(int argc, char *argv[])
goto fail3; goto fail3;
} }
#if WASM_ENABLE_DEBUG_INTERP != 0
if (ip_addr != NULL) {
wasm_exec_env_t exec_env =
wasm_runtime_get_exec_env_singleton(wasm_module_inst);
uint32_t debug_port;
if (exec_env == NULL) {
printf("%s\n", wasm_runtime_get_exception(wasm_module_inst));
goto fail4;
}
debug_port = wasm_runtime_start_debug_instance(exec_env);
if (debug_port == 0) {
printf("Failed to start debug instance\n");
goto fail4;
}
}
#endif
if (is_repl_mode) if (is_repl_mode)
app_instance_repl(wasm_module_inst); app_instance_repl(wasm_module_inst);
else if (func_name) else if (func_name)
@ -444,6 +461,9 @@ main(int argc, char *argv[])
ret = 0; ret = 0;
#if WASM_ENABLE_DEBUG_INTERP != 0
fail4:
#endif
/* destroy the module instance */ /* destroy the module instance */
wasm_runtime_deinstantiate(wasm_module_inst); wasm_runtime_deinstantiate(wasm_module_inst);