From d9e679dac8c97afec75be637439b50698c0f3396 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 15 Sep 2022 19:29:44 -0500 Subject: [PATCH] fixed many issues with the debugger --- compiler/src/wasm_emit.c | 2 +- interpreter/src/debug/debug_thread.c | 2 +- shared/include/bh.h | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/compiler/src/wasm_emit.c b/compiler/src/wasm_emit.c index 37ea48bd..83427bf3 100644 --- a/compiler/src/wasm_emit.c +++ b/compiler/src/wasm_emit.c @@ -271,8 +271,8 @@ static u32 debug_get_file_id(OnyxWasmModule *mod, const char *name) { file_info.line_count = fc->line_count; } } - shput(mod->debug_context->file_info, name, file_info); + shput(mod->debug_context->file_info, name, file_info); return id; } diff --git a/interpreter/src/debug/debug_thread.c b/interpreter/src/debug/debug_thread.c index ba0fa285..5d52312c 100644 --- a/interpreter/src/debug/debug_thread.c +++ b/interpreter/src/debug/debug_thread.c @@ -184,7 +184,7 @@ static void process_command(debug_state_t *debug, struct msg_parse_ctx_t *ctx) { } } - printf("[INFO ] Setting breakpoint at %s:%d (%xd)\n", filename, line, instr); + printf("[INFO ] Setting breakpoint at %s:%d (%x)\n", filename, line, instr); debug_breakpoint_t bp; bp.id = debug->next_breakpoint_id++; diff --git a/shared/include/bh.h b/shared/include/bh.h index 96d6e639..16a40da3 100644 --- a/shared/include/bh.h +++ b/shared/include/bh.h @@ -2447,6 +2447,8 @@ b32 bh__arr_grow(bh_allocator alloc, void** arr, i32 elemsize, i32 cap) { arrptr = (bh__arr *) bh_alloc(alloc, sizeof(*arrptr) + elemsize * cap); if (arrptr == NULL) return 0; + memset(arrptr + 1, 0, elemsize * cap); + arrptr->allocator = alloc; arrptr->capacity = cap; arrptr->length = 0; @@ -2456,12 +2458,14 @@ b32 bh__arr_grow(bh_allocator alloc, void** arr, i32 elemsize, i32 cap) { if (arrptr->capacity < cap) { void* p; - i32 newcap = arrptr->capacity; + i32 newcap = arrptr->capacity, oldcap = arrptr->capacity; while (newcap < cap) newcap = BH_ARR_GROW_FORMULA(newcap); p = bh_resize(arrptr->allocator, arrptr, sizeof(*arrptr) + elemsize * newcap); if (p) { + memset(bh_pointer_add(((bh__arr *) p + 1), elemsize * oldcap), 0, elemsize * (newcap - oldcap - 1)); + arrptr = (bh__arr *) p; arrptr->capacity = newcap; } else { -- 2.25.1