Fix source debugging issues (#776)
- fix data race issue between debug control thread and main thread - fix possible memory leaks in breakpoints list - fix memory uninitialized issues - remove unused data structures - add more checks when handling packet and args - fix mini-loader issues - fix config_common.cmake fast interp prompt issue
This commit is contained in:
@ -51,7 +51,8 @@ process_xfer(WASMGDBServer *server, const char *name, char *args)
|
||||
const char *mode = args;
|
||||
|
||||
args = strchr(args, ':');
|
||||
*args++ = '\0';
|
||||
if (args)
|
||||
*args++ = '\0';
|
||||
|
||||
if (!strcmp(name, "libraries") && !strcmp(mode, "read")) {
|
||||
//TODO: how to get current wasm file name?
|
||||
@ -145,9 +146,18 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
|
||||
if (!strcmp(name, "Xfer")) {
|
||||
name = args;
|
||||
|
||||
if (!args) {
|
||||
LOG_ERROR("payload parse error during handle_generay_query");
|
||||
return;
|
||||
}
|
||||
|
||||
args = strchr(args, ':');
|
||||
*args++ = '\0';
|
||||
process_xfer(server, name, args);
|
||||
|
||||
if (args) {
|
||||
*args++ = '\0';
|
||||
process_xfer(server, name, args);
|
||||
}
|
||||
}
|
||||
|
||||
if (!strcmp(name, "HostInfo")) {
|
||||
@ -202,7 +212,7 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
write_packet(server, "");
|
||||
}
|
||||
|
||||
if (!strcmp(name, "MemoryRegionInfo")) {
|
||||
if (args && (!strcmp(name, "MemoryRegionInfo"))) {
|
||||
uint64_t addr = strtol(args, NULL, 16);
|
||||
WASMDebugMemoryInfo *mem_info = wasm_debug_instance_get_memregion(
|
||||
(WASMDebugInstance *)server->thread->debug_instance, addr);
|
||||
@ -229,7 +239,7 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
write_packet(server, "");
|
||||
}
|
||||
|
||||
if (!strcmp(name, "WasmCallStack")) {
|
||||
if (args && (!strcmp(name, "WasmCallStack"))) {
|
||||
uint64_t tid = strtol(args, NULL, 16);
|
||||
uint64_t buf[1024 / sizeof(uint64_t)];
|
||||
uint64_t count = wasm_debug_instance_get_call_stack_pcs(
|
||||
@ -243,11 +253,11 @@ handle_generay_query(WASMGDBServer *server, char *payload)
|
||||
write_packet(server, "");
|
||||
}
|
||||
|
||||
if (!strcmp(name, "WasmLocal")) {
|
||||
if (args && (!strcmp(name, "WasmLocal"))) {
|
||||
porcess_wasm_local(server, args);
|
||||
}
|
||||
|
||||
if (!strcmp(name, "WasmGlobal")) {
|
||||
if (args && (!strcmp(name, "WasmGlobal"))) {
|
||||
porcess_wasm_global(server, args);
|
||||
}
|
||||
}
|
||||
@ -320,7 +330,7 @@ handle_v_packet(WASMGDBServer *server, char *payload)
|
||||
write_packet(server, "vCont;c;C;s;S;");
|
||||
|
||||
if (!strcmp("Cont", name)) {
|
||||
if (args[0] == 's') {
|
||||
if (args && args[0] == 's') {
|
||||
char *numstring = strchr(args, ':');
|
||||
if (numstring) {
|
||||
*numstring++ = '\0';
|
||||
@ -539,8 +549,13 @@ handle_malloc(WASMGDBServer *server, char *payload)
|
||||
sprintf(tmpbuf, "%s", "E03");
|
||||
|
||||
args = strstr(payload, ",");
|
||||
if (args)
|
||||
if (args) {
|
||||
*args++ = '\0';
|
||||
}
|
||||
else {
|
||||
LOG_ERROR("Payload parse error during handle malloc");
|
||||
return;
|
||||
}
|
||||
|
||||
size = strtol(payload, NULL, 16);
|
||||
if (size > 0) {
|
||||
|
||||
Reference in New Issue
Block a user