diff --git a/.github/workflows/spec_test.yml b/.github/workflows/spec_test.yml index cab196966c..18a211adf2 100644 --- a/.github/workflows/spec_test.yml +++ b/.github/workflows/spec_test.yml @@ -34,7 +34,7 @@ concurrency: env: DEFAULT_TEST_OPTIONS: "-s spec" - LLVM_CACHE_SUFFIX: "build-llvm_libraries" + LLVM_CACHE_SUFFIX: "build-llvm_libraries_ex" MULTI_MODULES_TEST_OPTIONS: "-s spec -M" SIMD_TEST_OPTIONS: "-s spec -S" THREADS_TEST_OPTIONS: "-s spec -p" diff --git a/ci/Dockerfile b/ci/Dockerfile index 51a0deb4cc..f90e4cc7cc 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,7 +1,7 @@ # Copyright (C) 2019 Intel Corporation. All rights reserved. # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -ARG VARIANT=need_to_assign +ARG VARIANT=focal FROM ubuntu:${VARIANT} ARG DEBIAN_FRONTEND=noninteractive @@ -13,7 +13,7 @@ RUN apt update \ libgcc-9-dev lib32gcc-9-dev lsb-release \ ninja-build ocaml ocamlbuild python2.7 \ software-properties-common tree tzdata \ - unzip url valgrind vim wget zip + unzip valgrind vim wget zip # # CMAKE (https://apt.kitware.com/) diff --git a/core/iwasm/libraries/debug-engine/debug_engine.c b/core/iwasm/libraries/debug-engine/debug_engine.c index 889e328dec..9694c7d789 100644 --- a/core/iwasm/libraries/debug-engine/debug_engine.c +++ b/core/iwasm/libraries/debug-engine/debug_engine.c @@ -59,10 +59,12 @@ control_thread_routine(void *arg) control_thread->debug_engine = g_debug_engine; control_thread->debug_instance = debug_inst; strcpy(control_thread->ip_addr, g_debug_engine->ip_addr); - control_thread->port = g_debug_engine->process_base_port + debug_inst->id; + control_thread->port = + (g_debug_engine->process_base_port == 0) + ? 0 + : g_debug_engine->process_base_port + debug_inst->id; - LOG_WARNING("control thread of debug object %p start at %s:%d\n", - debug_inst, control_thread->ip_addr, control_thread->port); + LOG_WARNING("control thread of debug object %p start\n", debug_inst); control_thread->server = wasm_launch_gdbserver(control_thread->ip_addr, control_thread->port); @@ -152,8 +154,7 @@ static void wasm_debug_control_thread_destroy(WASMDebugInstance *debug_instance) { WASMDebugControlThread *control_thread = debug_instance->control_thread; - LOG_VERBOSE("control thread of debug object %p stop at %s:%d\n", - debug_instance, control_thread->ip_addr, control_thread->port); + LOG_VERBOSE("control thread of debug object %p stop\n", debug_instance); control_thread->status = STOPPED; os_mutex_lock(&control_thread->wait_lock); wasm_close_gdbserver(control_thread->server); @@ -201,7 +202,7 @@ wasm_debug_engine_init(char *ip_addr, int platform_port, int process_port) g_debug_engine->platform_port = platform_port > 0 ? platform_port : 1234; g_debug_engine->process_base_port = - process_port > 0 ? process_port : 6169; + (process_port > 0) ? process_port : 0; if (ip_addr) sprintf(g_debug_engine->ip_addr, "%s", ip_addr); else diff --git a/core/iwasm/libraries/debug-engine/gdbserver.c b/core/iwasm/libraries/debug-engine/gdbserver.c index dedd366ad7..6e1eec2ff5 100644 --- a/core/iwasm/libraries/debug-engine/gdbserver.c +++ b/core/iwasm/libraries/debug-engine/gdbserver.c @@ -56,6 +56,7 @@ wasm_launch_gdbserver(char *host, int port) int listen_fd = -1; const int one = 1; struct sockaddr_in addr; + socklen_t socklen; int ret; int sockt_fd = 0; @@ -87,7 +88,6 @@ wasm_launch_gdbserver(char *host, int port) goto fail; } - LOG_VERBOSE("Listening on %s:%d\n", host, port); addr.sin_family = AF_INET; addr.sin_addr.s_addr = inet_addr(host); addr.sin_port = htons(port); @@ -98,6 +98,14 @@ wasm_launch_gdbserver(char *host, int port) goto fail; } + socklen = sizeof(addr); + if (getsockname(listen_fd, (void *)&addr, &socklen) == -1) { + LOG_ERROR("%s", strerror(errno)); + goto fail; + } + + LOG_WARNING("Listening on %s:%d\n", host, ntohs(addr.sin_port)); + ret = listen(listen_fd, 1); if (ret < 0) { LOG_ERROR("wasm gdb server error: listen() failed"); diff --git a/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c b/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c index 979e6e6cd4..d7387804ba 100644 --- a/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c +++ b/core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c @@ -1128,10 +1128,10 @@ print_f64_wrapper(wasm_exec_env_t exec_env, double f64) } #endif /* WASM_ENABLE_SPEC_TEST */ -#define REG_NATIVE_FUNC(func_name, signature) \ - { \ -#func_name, func_name##_wrapper, signature, NULL \ - } +/* clang-format off */ +#define REG_NATIVE_FUNC(func_name, signature) \ + { #func_name, func_name##_wrapper, signature, NULL } +/* clang-format on */ static NativeSymbol native_symbols_libc_builtin[] = { REG_NATIVE_FUNC(printf, "($*)i"), diff --git a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h index 53219f438e..b57f8835e7 100644 --- a/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h +++ b/core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h @@ -41,7 +41,6 @@ typedef __wasi_riflags_t wasi_riflags_t; typedef __wasi_roflags_t wasi_roflags_t; typedef __wasi_siflags_t wasi_siflags_t; typedef __wasi_sdflags_t wasi_sdflags_t; -typedef __wasi_dircookie_t wasi_dircookie_t; typedef __wasi_preopentype_t wasi_preopentype_t; #ifdef __cplusplus diff --git a/doc/source_debugging.md b/doc/source_debugging.md index 4c09c3e18f..6d0021b430 100644 --- a/doc/source_debugging.md +++ b/doc/source_debugging.md @@ -30,6 +30,7 @@ make 3. Execute iwasm with debug engine enabled ``` bash iwasm -g=127.0.0.1:1234 test.wasm +# Use port = 0 to allow a random assigned debug port ``` 4. Build customized lldb (assume you have already cloned llvm) diff --git a/product-mini/platforms/posix/main.c b/product-mini/platforms/posix/main.c index ecdd7973bd..179dd3e0e3 100644 --- a/product-mini/platforms/posix/main.c +++ b/product-mini/platforms/posix/main.c @@ -53,6 +53,7 @@ print_help() #endif #if WASM_ENABLE_DEBUG_INTERP != 0 printf(" -g=ip:port Set the debug sever address, default is debug disabled\n"); + printf(" if port is 0, then a random port will be used\n"); #endif return 1; }