From: Brendan Hansen Date: Thu, 11 Aug 2022 03:19:59 +0000 (-0500) Subject: bugfixes and step in, out, and over X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=717aecd0174cd6cbd57aad028ff7807c55ffbb9d;p=onyx.git bugfixes and step in, out, and over --- diff --git a/lib/linux_x86_64/lib/libovmwasm.so b/lib/linux_x86_64/lib/libovmwasm.so index ca483d25..e7177dd4 100755 Binary files a/lib/linux_x86_64/lib/libovmwasm.so and b/lib/linux_x86_64/lib/libovmwasm.so differ diff --git a/misc/vscode/onyx-0.0.3.vsix b/misc/vscode/onyx-0.0.3.vsix index 8c1803e3..45cca5df 100644 Binary files a/misc/vscode/onyx-0.0.3.vsix and b/misc/vscode/onyx-0.0.3.vsix differ diff --git a/misc/vscode/out/ovmDebug.js b/misc/vscode/out/ovmDebug.js index f1479902..edd09726 100644 --- a/misc/vscode/out/ovmDebug.js +++ b/misc/vscode/out/ovmDebug.js @@ -195,13 +195,16 @@ class OVMDebugSession extends debugadapter_1.LoggingDebugSession { this.sendResponse(response); } nextRequest(response, args, request) { - this.debugger.step("line", args.threadId); + this.debugger.step("over", args.threadId); + this.sendResponse(response); } stepOutRequest(response, args, request) { - console.log("STEP OUT"); + this.debugger.step("out", args.threadId); + this.sendResponse(response); } stepInRequest(response, args, request) { - console.log("STEP IN"); + this.debugger.step("line", args.threadId); + this.sendResponse(response); } fileNameToShortName(filename) { return filename.substring(filename.lastIndexOf("/") + 1); @@ -214,7 +217,6 @@ var OVMCommand; OVMCommand[OVMCommand["RES"] = 1] = "RES"; OVMCommand[OVMCommand["BRK"] = 2] = "BRK"; OVMCommand[OVMCommand["CLR_BRK"] = 3] = "CLR_BRK"; - OVMCommand[OVMCommand["LOC"] = 4] = "LOC"; OVMCommand[OVMCommand["STEP"] = 5] = "STEP"; OVMCommand[OVMCommand["TRACE"] = 6] = "TRACE"; })(OVMCommand || (OVMCommand = {})); @@ -285,17 +287,6 @@ class OVMDebugger extends EventEmitter { return this.preparePromise(cmd_id); }); } - request_location(thread_id) { - let data = new ArrayBuffer(12); - let view = new DataView(data); - let cmd_id = this.next_command_id; - view.setUint32(0, cmd_id, true); - view.setUint32(4, OVMCommand.LOC, true); - view.setUint32(8, thread_id, true); - this.client.write(new Uint8Array(data)); - this.pending_responses[cmd_id] = OVMCommand.LOC; - return this.preparePromise(cmd_id); - } step(granularity, thread_id) { let data = new ArrayBuffer(16); let view = new DataView(data); @@ -308,7 +299,13 @@ class OVMDebugger extends EventEmitter { view.setUint32(8, 1, true); break; case "instruction": - view.setUint32(8, 1, true); + view.setUint32(8, 2, true); + break; + case "over": + view.setUint32(8, 3, true); + break; + case "out": + view.setUint32(8, 4, true); break; } this.client.write(new Uint8Array(data)); @@ -390,15 +387,6 @@ class OVMDebugger extends EventEmitter { this.resolvePromise(msg_id, success); break; } - case OVMCommand.LOC: { - let success = parser.parseBool(); - let filename = parser.parseString(); - let line = parser.parseInt32(); - if (!success) - break; - this.resolvePromise(msg_id, { funcname: "unknown", filename, line }); - break; - } case OVMCommand.STEP: break; case OVMCommand.TRACE: { let result = new Array(); diff --git a/misc/vscode/ovmDebug.ts b/misc/vscode/ovmDebug.ts index b2293401..7877ac58 100644 --- a/misc/vscode/ovmDebug.ts +++ b/misc/vscode/ovmDebug.ts @@ -260,15 +260,18 @@ export class OVMDebugSession extends LoggingDebugSession { } protected nextRequest(response: DebugProtocol.NextResponse, args: DebugProtocol.NextArguments, request?: DebugProtocol.Request): void { - this.debugger.step("line", args.threadId); + this.debugger.step("over", args.threadId); + this.sendResponse(response); } protected stepOutRequest(response: DebugProtocol.StepOutResponse, args: DebugProtocol.StepOutArguments, request?: DebugProtocol.Request): void { - console.log("STEP OUT"); + this.debugger.step("out", args.threadId); + this.sendResponse(response); } protected stepInRequest(response: DebugProtocol.StepInResponse, args: DebugProtocol.StepInArguments, request?: DebugProtocol.Request): void { - console.log("STEP IN"); + this.debugger.step("line", args.threadId); + this.sendResponse(response); } private fileNameToShortName(filename: string): string { @@ -293,7 +296,6 @@ enum OVMCommand { RES = 1, BRK = 2, CLR_BRK = 3, - LOC = 4, STEP = 5, TRACE = 6 } @@ -393,24 +395,7 @@ class OVMDebugger extends EventEmitter { return this.preparePromise(cmd_id); } - request_location(thread_id: number): Promise { - let data = new ArrayBuffer(12); - let view = new DataView(data); - - let cmd_id = this.next_command_id; - - view.setUint32(0, cmd_id, true); - view.setUint32(4, OVMCommand.LOC, true); - view.setUint32(8, thread_id, true); - - this.client.write(new Uint8Array(data)); - - this.pending_responses[cmd_id] = OVMCommand.LOC; - - return this.preparePromise(cmd_id); - } - - step(granularity: "line" | "instruction", thread_id: number): void { + step(granularity: "line" | "instruction" | "over" | "out", thread_id: number): void { let data = new ArrayBuffer(16); let view = new DataView(data); @@ -422,7 +407,9 @@ class OVMDebugger extends EventEmitter { switch (granularity) { case "line": view.setUint32(8, 1, true); break; - case "instruction": view.setUint32(8, 1, true); break; + case "instruction": view.setUint32(8, 2, true); break; + case "over": view.setUint32(8, 3, true); break; + case "out": view.setUint32(8, 4, true); break; } this.client.write(new Uint8Array(data)); @@ -525,17 +512,6 @@ class OVMDebugger extends EventEmitter { break; } - case OVMCommand.LOC: { - let success = parser.parseBool(); - let filename = parser.parseString(); - let line = parser.parseInt32(); - - if (!success) break; - - this.resolvePromise(msg_id, {funcname: "unknown", filename, line}); - break; - } - case OVMCommand.STEP: break; case OVMCommand.TRACE: { diff --git a/src/wasm_output.h b/src/wasm_output.h index bf2d9446..8f9ccc4a 100644 --- a/src/wasm_output.h +++ b/src/wasm_output.h @@ -430,6 +430,8 @@ static void output_instruction(WasmFunc* func, WasmInstruction* instr, bh_buffer if (instr->type == WI_UNREACHABLE) assert(("EMITTING UNREACHABLE!!", 0)); + if (instr->type == WI_NOP && !context.options->debug_enabled) return; + if (instr->type & SIMD_INSTR_MASK) { bh_buffer_write_byte(buff, 0xFD); leb = uint_to_uleb128((u64) (instr->type &~ SIMD_INSTR_MASK), &leb_len); diff --git a/src/wasm_runtime.c b/src/wasm_runtime.c index adbd1d3e..09797d4d 100644 --- a/src/wasm_runtime.c +++ b/src/wasm_runtime.c @@ -224,7 +224,6 @@ static void cleanup_wasm_objects() { if (wasm_module) wasm_module_delete(wasm_module); if (wasm_store) wasm_store_delete(wasm_store); if (wasm_engine) wasm_engine_delete(wasm_engine); - if (wasm_config) wasm_config_delete(wasm_config); } //