Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/spec_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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/)
Expand Down
13 changes: 7 additions & 6 deletions core/iwasm/libraries/debug-engine/debug_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
10 changes: 9 additions & 1 deletion core/iwasm/libraries/debug-engine/gdbserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
Expand All @@ -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");
Expand Down
8 changes: 4 additions & 4 deletions core/iwasm/libraries/libc-builtin/libc_builtin_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
1 change: 0 additions & 1 deletion core/iwasm/libraries/libc-wasi/libc_wasi_wrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions doc/source_debugging.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions product-mini/platforms/posix/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down