Fixes bugs in stepping over

This commit is contained in:
konsoletyper 2014-08-13 16:06:43 +04:00
parent 4115785823
commit c0dc459f22
3 changed files with 15 additions and 7 deletions

View File

@ -325,10 +325,9 @@ public class DebugInformation {
FileDescription build() {
FileDescription description = new FileDescription();
description.generatedLocationData = new int[generatedLocationData.size()];
description.generatedLocationStart = new int[generatedLocationStart.size()];
description.generatedLocationStart = new int[generatedLocationStart.size() + 1];
int current = 0;
for (int i = 0; i < generatedLocationStart.size(); ++i) {
description.generatedLocationStart[i] = current;
current += generatedLocationSize.get(i) * 2;
int j = current;
int ptr = generatedLocationStart.get(i);
@ -336,6 +335,7 @@ public class DebugInformation {
description.generatedLocationData[--j] = generatedLocationData.get(ptr);
ptr = generatedLocationPointers.get(ptr);
}
description.generatedLocationStart[i + 1] = current;
}
return description;
}

View File

@ -348,7 +348,7 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
IntegerArray linesChunk = new IntegerArray(1);
IntegerArray filesChunk = new IntegerArray(1);
int ptr = start.get(i);
while (ptr > 0) {
while (ptr >= 0) {
linesChunk.add(lines.get(ptr));
filesChunk.add(files.get(ptr));
ptr = next.get(ptr);
@ -361,7 +361,7 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
int distinctSize = 0;
for (int j = 0; j < pairs.length; ++j) {
long pair = pairs[j];
if (distinctSize == 0 || pair != pairs[distinctSize]) {
if (distinctSize == 0 || pair != pairs[distinctSize - 1]) {
pairs[distinctSize++] = pair;
filesData.add((int)(pair >>> 32));
linesData.add((int)pair);

View File

@ -16,6 +16,7 @@
package org.teavm.model.util;
import java.util.List;
import java.util.Objects;
import org.teavm.model.*;
/**
@ -25,7 +26,8 @@ import org.teavm.model.*;
public class ListingBuilder {
public String buildListing(ProgramReader program, String prefix) {
StringBuilder sb = new StringBuilder();
InstructionStringifier stringifier = new InstructionStringifier(sb);
StringBuilder insnSb = new StringBuilder();
InstructionStringifier stringifier = new InstructionStringifier(insnSb);
for (int i = 0; i < program.variableCount(); ++i) {
sb.append(prefix).append("var @").append(i);
VariableReader var = program.variableAt(i);
@ -59,10 +61,16 @@ public class ListingBuilder {
}
sb.append("\n");
}
InstructionLocation location = null;
for (int j = 0; j < block.instructionCount(); ++j) {
sb.append(prefix).append(" ");
insnSb.setLength(0);
block.readInstruction(j, stringifier);
sb.append("\n");
if (!Objects.equals(location, stringifier.getLocation())) {
location = stringifier.getLocation();
sb.append(prefix).append(" at ").append(location != null ? location.toString() :
"unknown location").append('\n');
}
sb.append(prefix).append(" ").append(insnSb).append("\n");
}
for (TryCatchBlockReader tryCatch : block.readTryCatchBlocks()) {
sb.append(prefix).append(" catch ").append(tryCatch.getExceptionType()).append(" @")