bugfixes and step in, out, and over
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 11 Aug 2022 03:19:59 +0000 (22:19 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 11 Aug 2022 03:19:59 +0000 (22:19 -0500)
lib/linux_x86_64/lib/libovmwasm.so
misc/vscode/onyx-0.0.3.vsix
misc/vscode/out/ovmDebug.js
misc/vscode/ovmDebug.ts
src/wasm_output.h
src/wasm_runtime.c

index ca483d25be5c8c174d44169bd3f86c7c6b1ec6e0..e7177dd43c39971068b780b853d3225e9cadc35a 100755 (executable)
Binary files a/lib/linux_x86_64/lib/libovmwasm.so and b/lib/linux_x86_64/lib/libovmwasm.so differ
index 8c1803e340bd088f7d51146cb3f7d845893d4b04..45cca5df8f6aad1e57a5ad198cfa0300db534f2b 100644 (file)
Binary files a/misc/vscode/onyx-0.0.3.vsix and b/misc/vscode/onyx-0.0.3.vsix differ
index f1479902993d98e87389267f586a2cb8edf54aa5..edd0972654c229550ba96b1f56bd6abdebc0ea68 100644 (file)
@@ -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();
index b229340186300473641dfcc2c092d34266c6ab00..7877ac586fe161b5a7009533adf90f68653243ed 100644 (file)
@@ -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<IFileLocation> {
-        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: {
index bf2d9446f40c38fc72cbd8e50f06377e11784281..8f9ccc4a021ba50d7a31e0935a5f84d55816c8f3 100644 (file)
@@ -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);
index adbd1d3eb80f9a70f607a262e45eeab3d155259a..09797d4d8edbc63b67852ae2fff8c4fd785c4256 100644 (file)
@@ -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);
 }
 
 //