From 506a9bd8c5cb6a2b48311d2dec6ca30482561e89 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Thu, 15 Dec 2022 17:27:14 +0100 Subject: [PATCH] Wasm: fix bugs in debugger --- .../wasm/debug/info/FunctionControlFlowIterator.java | 7 +++++-- .../teavm/backend/wasm/debug/info/StepLocationsFinder.java | 2 +- .../backend/wasm/render/WasmBinaryRenderingVisitor.java | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/teavm/backend/wasm/debug/info/FunctionControlFlowIterator.java b/core/src/main/java/org/teavm/backend/wasm/debug/info/FunctionControlFlowIterator.java index d0fa2949d..fabff1cd0 100644 --- a/core/src/main/java/org/teavm/backend/wasm/debug/info/FunctionControlFlowIterator.java +++ b/core/src/main/java/org/teavm/backend/wasm/debug/info/FunctionControlFlowIterator.java @@ -26,7 +26,7 @@ public class FunctionControlFlowIterator { FunctionControlFlowIterator(FunctionControlFlow controlFlow, int index) { this.controlFlow = controlFlow; - this.index = 0; + this.index = index; } public boolean hasNext() { @@ -39,7 +39,10 @@ public class FunctionControlFlowIterator { } public void rewind(int index) { - this.index = index; + if (this.index != index) { + this.index = index; + fill(); + } } private void fill() { diff --git a/core/src/main/java/org/teavm/backend/wasm/debug/info/StepLocationsFinder.java b/core/src/main/java/org/teavm/backend/wasm/debug/info/StepLocationsFinder.java index 6b0b9719c..61f8f2c63 100644 --- a/core/src/main/java/org/teavm/backend/wasm/debug/info/StepLocationsFinder.java +++ b/core/src/main/java/org/teavm/backend/wasm/debug/info/StepLocationsFinder.java @@ -176,7 +176,7 @@ public class StepLocationsFinder { breakpointAddresses.add(point.address + debugInfo.offset()); return; } - if (enterMethod) { + if (enterMethod && point.isCall) { breakpointAddresses.add(point.address + debugInfo.offset()); callAddresses.add(point.address + debugInfo.offset()); } diff --git a/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java b/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java index d3293aa94..52a81b38b 100644 --- a/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java +++ b/core/src/main/java/org/teavm/backend/wasm/render/WasmBinaryRenderingVisitor.java @@ -967,6 +967,7 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor { emitLocation(null); flushLocation(); if (debugLines != null) { + debugLines.advance(writer.getPosition() + addressOffset); debugLines.end(); } }