debug-engine: fix a few type mismatches (#4189)

- use strict prototypes complained by GCC `-Wstrict-prototypes`
- use `int*` instead of `int32*`

Note: on some targets, int32_t is a long.
for example, GCC shipped with the recent ESP-IDF has such a
configuration.

- https://github.com/apache/nuttx/issues/15755#issuecomment-2635652808
- https://github.com/apache/nuttx/pull/16022
- https://docs.espressif.com/projects/esp-idf/en/stable/esp32/migration-guides/release-5.x/5.0/gcc.html#espressif-toolchain-changes
This commit is contained in:
YAMAMOTO Takashi 2025-04-17 01:07:08 +09:00 committed by GitHub
parent fc78d67e15
commit 0ba6532636
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 16 deletions

View File

@ -58,7 +58,7 @@ static WASMDebugEngine *g_debug_engine;
static uint32 current_instance_id = 1; static uint32 current_instance_id = 1;
static uint32 static uint32
allocate_instance_id() allocate_instance_id(void)
{ {
uint32 id; uint32 id;
@ -302,7 +302,7 @@ wasm_debug_control_thread_destroy(WASMDebugInstance *debug_instance)
} }
static WASMDebugEngine * static WASMDebugEngine *
wasm_debug_engine_create() wasm_debug_engine_create(void)
{ {
WASMDebugEngine *engine; WASMDebugEngine *engine;
@ -326,7 +326,7 @@ wasm_debug_engine_create()
} }
void void
wasm_debug_engine_destroy() wasm_debug_engine_destroy(void)
{ {
if (g_debug_engine) { if (g_debug_engine) {
wasm_debug_handler_deinit(); wasm_debug_handler_deinit();

View File

@ -133,7 +133,7 @@ bool
wasm_debug_engine_init(char *ip_addr, int32 process_port); wasm_debug_engine_init(char *ip_addr, int32 process_port);
void void
wasm_debug_engine_destroy(); wasm_debug_engine_destroy(void);
WASMExecEnv * WASMExecEnv *
wasm_debug_instance_get_current_env(WASMDebugInstance *instance); wasm_debug_instance_get_current_env(WASMDebugInstance *instance);

View File

@ -38,7 +38,7 @@ static const struct packet_handler_elem packet_handler_table[255] = {
}; };
WASMGDBServer * WASMGDBServer *
wasm_create_gdbserver(const char *host, int32 *port) wasm_create_gdbserver(const char *host, int *port)
{ {
bh_socket_t listen_fd = (bh_socket_t)-1; bh_socket_t listen_fd = (bh_socket_t)-1;
WASMGDBServer *server; WASMGDBServer *server;

View File

@ -51,7 +51,7 @@ typedef struct WASMGDBServer {
} WASMGDBServer; } WASMGDBServer;
WASMGDBServer * WASMGDBServer *
wasm_create_gdbserver(const char *host, int32 *port); wasm_create_gdbserver(const char *host, int *port);
bool bool
wasm_gdbserver_listen(WASMGDBServer *server); wasm_gdbserver_listen(WASMGDBServer *server);

View File

@ -34,7 +34,7 @@ static char *tmpbuf;
static korp_mutex tmpbuf_lock; static korp_mutex tmpbuf_lock;
int int
wasm_debug_handler_init() wasm_debug_handler_init(void)
{ {
int ret; int ret;
tmpbuf = wasm_runtime_malloc(MAX_PACKET_SIZE); tmpbuf = wasm_runtime_malloc(MAX_PACKET_SIZE);
@ -51,7 +51,7 @@ wasm_debug_handler_init()
} }
void void
wasm_debug_handler_deinit() wasm_debug_handler_deinit(void)
{ {
wasm_runtime_free(tmpbuf); wasm_runtime_free(tmpbuf);
tmpbuf = NULL; tmpbuf = NULL;
@ -204,8 +204,7 @@ handle_general_query(WASMGDBServer *server, char *payload)
if (!strcmp(name, "Supported")) { if (!strcmp(name, "Supported")) {
os_mutex_lock(&tmpbuf_lock); os_mutex_lock(&tmpbuf_lock);
snprintf(tmpbuf, MAX_PACKET_SIZE, snprintf(tmpbuf, MAX_PACKET_SIZE,
"qXfer:libraries:read+;PacketSize=%" PRIx32 ";", "qXfer:libraries:read+;PacketSize=%x;", MAX_PACKET_SIZE);
MAX_PACKET_SIZE);
write_packet(server, tmpbuf); write_packet(server, tmpbuf);
os_mutex_unlock(&tmpbuf_lock); os_mutex_unlock(&tmpbuf_lock);
} }
@ -384,7 +383,7 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid)
if (status == 0) { if (status == 0) {
os_mutex_lock(&tmpbuf_lock); os_mutex_lock(&tmpbuf_lock);
snprintf(tmpbuf, MAX_PACKET_SIZE, "W%02x", status); snprintf(tmpbuf, MAX_PACKET_SIZE, "W%02" PRIx32, status);
write_packet(server, tmpbuf); write_packet(server, tmpbuf);
os_mutex_unlock(&tmpbuf_lock); os_mutex_unlock(&tmpbuf_lock);
return; return;
@ -400,8 +399,9 @@ send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid)
os_mutex_lock(&tmpbuf_lock); os_mutex_lock(&tmpbuf_lock);
// TODO: how name a wasm thread? // TODO: how name a wasm thread?
len += snprintf(tmpbuf, MAX_PACKET_SIZE, "T%02xthread:%" PRIx64 ";name:%s;", len += snprintf(tmpbuf, MAX_PACKET_SIZE,
gdb_status, (uint64)(uintptr_t)tid, "nobody"); "T%02" PRIx32 "thread:%" PRIx64 ";name:%s;", gdb_status,
(uint64)(uintptr_t)tid, "nobody");
if (tids_count > 0) { if (tids_count > 0) {
len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "threads:"); len += snprintf(tmpbuf + len, MAX_PACKET_SIZE - len, "threads:");
while (i < tids_count) { while (i < tids_count) {
@ -624,7 +624,8 @@ void
handle_get_write_memory(WASMGDBServer *server, char *payload) handle_get_write_memory(WASMGDBServer *server, char *payload)
{ {
size_t hex_len; size_t hex_len;
int32 offset, act_len; int offset;
int32 act_len;
uint64 maddr, mlen; uint64 maddr, mlen;
char *buff; char *buff;
bool ret; bool ret;

View File

@ -9,10 +9,10 @@
#include "gdbserver.h" #include "gdbserver.h"
int int
wasm_debug_handler_init(); wasm_debug_handler_init(void);
void void
wasm_debug_handler_deinit(); wasm_debug_handler_deinit(void);
void void
handle_interrupt(WASMGDBServer *server); handle_interrupt(WASMGDBServer *server);