From 7f38697d5075dcce4cfc631cda784e0f59f10a83 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sat, 19 Nov 2022 20:15:54 +0100 Subject: [PATCH] Wasm: don't emit DW_LNE_end_sequence when there were no previous command emitted --- .../teavm/backend/wasm/generate/DwarfLinesGenerator.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/src/main/java/org/teavm/backend/wasm/generate/DwarfLinesGenerator.java b/core/src/main/java/org/teavm/backend/wasm/generate/DwarfLinesGenerator.java index 709bde180..fc01c62a5 100644 --- a/core/src/main/java/org/teavm/backend/wasm/generate/DwarfLinesGenerator.java +++ b/core/src/main/java/org/teavm/backend/wasm/generate/DwarfLinesGenerator.java @@ -47,6 +47,7 @@ class DwarfLinesGenerator { private int address; private int file = 1; private int line = 1; + private boolean sequenceStarted; DwarfLinesGenerator(DwarfStrings strings) { this.strings = strings; @@ -178,9 +179,13 @@ class DwarfLinesGenerator { if (changed) { instructionsBlob.writeByte(DW_LNS_COPY); } + sequenceStarted = true; } void endLineNumberSequence(int address) { + if (!sequenceStarted) { + return; + } advanceTo(address, line); instructionsBlob.writeByte(0); instructionsBlob.writeByte(1); @@ -188,6 +193,7 @@ class DwarfLinesGenerator { this.line = 1; this.file = 0; this.address = 0; + sequenceStarted = false; } private boolean advanceTo(int address, int line) {