|
|
@@ -26,8 +26,11 @@ wasm_debug_handler_deinit()
|
|
|
os_mutex_destroy(&tmpbuf_lock);
|
|
|
}
|
|
|
|
|
|
-static void
|
|
|
-send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid);
|
|
|
+void
|
|
|
+handle_interrupt(WASMGDBServer *server)
|
|
|
+{
|
|
|
+ wasm_debug_instance_interrupt_all_threads(server->thread->debug_instance);
|
|
|
+}
|
|
|
|
|
|
void
|
|
|
handle_generay_set(WASMGDBServer *server, char *payload)
|
|
|
@@ -91,7 +94,7 @@ process_xfer(WASMGDBServer *server, const char *name, char *args)
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-porcess_wasm_local(WASMGDBServer *server, char *args)
|
|
|
+process_wasm_local(WASMGDBServer *server, char *args)
|
|
|
{
|
|
|
int32 frame_index;
|
|
|
int32 local_index;
|
|
|
@@ -114,7 +117,7 @@ porcess_wasm_local(WASMGDBServer *server, char *args)
|
|
|
}
|
|
|
|
|
|
void
|
|
|
-porcess_wasm_global(WASMGDBServer *server, char *args)
|
|
|
+process_wasm_global(WASMGDBServer *server, char *args)
|
|
|
{
|
|
|
int32 frame_index;
|
|
|
int32 global_index;
|
|
|
@@ -189,12 +192,12 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
|
|
}
|
|
|
|
|
|
if (!strcmp(name, "HostInfo")) {
|
|
|
- // Todo: change vendor to Intel for outside tree?
|
|
|
- mem2hex("wasm32-Ant-wasi-wasm", triple, strlen("wasm32-Ant-wasi-wasm"));
|
|
|
+ mem2hex("wasm32-wamr-wasi-wasm", triple,
|
|
|
+ strlen("wasm32-wamr-wasi-wasm"));
|
|
|
|
|
|
os_mutex_lock(&tmpbuf_lock);
|
|
|
snprintf(tmpbuf, sizeof(tmpbuf),
|
|
|
- "vendor:Ant;ostype:wasi;arch:wasm32;"
|
|
|
+ "vendor:wamr;ostype:wasi;arch:wasm32;"
|
|
|
"triple:%s;endian:little;ptrsize:4;",
|
|
|
triple);
|
|
|
write_packet(server, tmpbuf);
|
|
|
@@ -220,13 +223,13 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
|
|
uint64 pid;
|
|
|
pid = wasm_debug_instance_get_pid(
|
|
|
(WASMDebugInstance *)server->thread->debug_instance);
|
|
|
- // arch-vendor-os-env(format)
|
|
|
- mem2hex("wasm32-Ant-wasi-wasm", triple, strlen("wasm32-Ant-wasi-wasm"));
|
|
|
+ mem2hex("wasm32-wamr-wasi-wasm", triple,
|
|
|
+ strlen("wasm32-wamr-wasi-wasm"));
|
|
|
|
|
|
os_mutex_lock(&tmpbuf_lock);
|
|
|
snprintf(tmpbuf, sizeof(tmpbuf),
|
|
|
"pid:%" PRIx64 ";parent-pid:%" PRIx64
|
|
|
- ";vendor:Ant;ostype:wasi;arch:wasm32;"
|
|
|
+ ";vendor:wamr;ostype:wasi;arch:wasm32;"
|
|
|
"triple:%s;endian:little;ptrsize:4;",
|
|
|
pid, pid, triple);
|
|
|
write_packet(server, tmpbuf);
|
|
|
@@ -298,11 +301,11 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
|
|
}
|
|
|
|
|
|
if (args && (!strcmp(name, "WasmLocal"))) {
|
|
|
- porcess_wasm_local(server, args);
|
|
|
+ process_wasm_local(server, args);
|
|
|
}
|
|
|
|
|
|
if (args && (!strcmp(name, "WasmGlobal"))) {
|
|
|
- porcess_wasm_global(server, args);
|
|
|
+ process_wasm_global(server, args);
|
|
|
}
|
|
|
|
|
|
if (!strcmp(name, "Offsets")) {
|
|
|
@@ -322,7 +325,7 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-static void
|
|
|
+void
|
|
|
send_thread_stop_status(WASMGDBServer *server, uint32 status, korp_tid tid)
|
|
|
{
|
|
|
int32 len = 0;
|
|
|
@@ -391,7 +394,6 @@ handle_v_packet(WASMGDBServer *server, char *payload)
|
|
|
{
|
|
|
const char *name;
|
|
|
char *args;
|
|
|
- uint32 status;
|
|
|
|
|
|
args = strchr(payload, ';');
|
|
|
if (args)
|
|
|
@@ -427,11 +429,6 @@ handle_v_packet(WASMGDBServer *server, char *payload)
|
|
|
(WASMDebugInstance *)
|
|
|
server->thread->debug_instance);
|
|
|
}
|
|
|
-
|
|
|
- tid = wasm_debug_instance_wait_thread(
|
|
|
- (WASMDebugInstance *)server->thread->debug_instance,
|
|
|
- tid, &status);
|
|
|
- send_thread_stop_status(server, status, tid);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -441,14 +438,34 @@ handle_v_packet(WASMGDBServer *server, char *payload)
|
|
|
void
|
|
|
handle_threadstop_request(WASMGDBServer *server, char *payload)
|
|
|
{
|
|
|
- korp_tid tid = wasm_debug_instance_get_tid(
|
|
|
- (WASMDebugInstance *)server->thread->debug_instance);
|
|
|
+ korp_tid tid;
|
|
|
uint32 status;
|
|
|
+ WASMDebugInstance *debug_inst =
|
|
|
+ (WASMDebugInstance *)server->thread->debug_instance;
|
|
|
+ bh_assert(debug_inst);
|
|
|
+
|
|
|
+ /* According to
|
|
|
+ https://sourceware.org/gdb/onlinedocs/gdb/Packets.html#Packets, the "?"
|
|
|
+ package should be sent when connection is first established to query the
|
|
|
+ reason the target halted */
|
|
|
+ bh_assert(debug_inst->current_state == DBG_LAUNCHING);
|
|
|
|
|
|
- tid = wasm_debug_instance_wait_thread(
|
|
|
- (WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
|
|
+ /* Waiting for the stop event */
|
|
|
+ os_mutex_lock(&debug_inst->wait_lock);
|
|
|
+ while (!debug_inst->stopped_thread) {
|
|
|
+ os_cond_wait(&debug_inst->wait_cond, &debug_inst->wait_lock);
|
|
|
+ }
|
|
|
+ os_mutex_unlock(&debug_inst->wait_lock);
|
|
|
+
|
|
|
+ tid = debug_inst->stopped_thread->handle;
|
|
|
+ status = (uint32)debug_inst->stopped_thread->current_status->signal_flag;
|
|
|
+
|
|
|
+ wasm_debug_instance_set_cur_thread(debug_inst, tid);
|
|
|
|
|
|
send_thread_stop_status(server, status, tid);
|
|
|
+
|
|
|
+ debug_inst->current_state = APP_STOPPED;
|
|
|
+ debug_inst->stopped_thread = NULL;
|
|
|
}
|
|
|
|
|
|
void
|
|
|
@@ -611,37 +628,15 @@ handle_remove_break(WASMGDBServer *server, char *payload)
|
|
|
void
|
|
|
handle_continue_request(WASMGDBServer *server, char *payload)
|
|
|
{
|
|
|
- korp_tid tid;
|
|
|
- uint32 status;
|
|
|
-
|
|
|
wasm_debug_instance_continue(
|
|
|
(WASMDebugInstance *)server->thread->debug_instance);
|
|
|
-
|
|
|
- tid = wasm_debug_instance_get_tid(
|
|
|
- (WASMDebugInstance *)server->thread->debug_instance);
|
|
|
-
|
|
|
- tid = wasm_debug_instance_wait_thread(
|
|
|
- (WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
|
|
-
|
|
|
- send_thread_stop_status(server, status, tid);
|
|
|
}
|
|
|
|
|
|
void
|
|
|
handle_kill_request(WASMGDBServer *server, char *payload)
|
|
|
{
|
|
|
- korp_tid tid;
|
|
|
- uint32 status;
|
|
|
-
|
|
|
wasm_debug_instance_kill(
|
|
|
(WASMDebugInstance *)server->thread->debug_instance);
|
|
|
-
|
|
|
- tid = wasm_debug_instance_get_tid(
|
|
|
- (WASMDebugInstance *)server->thread->debug_instance);
|
|
|
-
|
|
|
- tid = wasm_debug_instance_wait_thread(
|
|
|
- (WASMDebugInstance *)server->thread->debug_instance, tid, &status);
|
|
|
-
|
|
|
- send_thread_stop_status(server, status, tid);
|
|
|
}
|
|
|
|
|
|
static void
|