mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2025-01-10 08:54:11 -08:00
Fixes bugs in stepping
This commit is contained in:
parent
0c708868a5
commit
fed5637d4d
|
@ -228,7 +228,7 @@ public class DebugInformation {
|
||||||
|
|
||||||
public MethodReference getExactMethod(int index) {
|
public MethodReference getExactMethod(int index) {
|
||||||
long item = exactMethods[index];
|
long item = exactMethods[index];
|
||||||
int classIndex = (int)(item >> 32);
|
int classIndex = (int)(item >>> 32);
|
||||||
int methodIndex = (int)item;
|
int methodIndex = (int)item;
|
||||||
return new MethodReference(classNames[classIndex], MethodDescriptor.parse(methods[methodIndex]));
|
return new MethodReference(classNames[classIndex], MethodDescriptor.parse(methods[methodIndex]));
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ public class DebugInformation {
|
||||||
int lastClass = -1;
|
int lastClass = -1;
|
||||||
for (int i = 0; i < exactMethods.length; ++i) {
|
for (int i = 0; i < exactMethods.length; ++i) {
|
||||||
long exactMethod = exactMethods[i];
|
long exactMethod = exactMethods[i];
|
||||||
int classIndex = (int)(exactMethod >> 32);
|
int classIndex = (int)(exactMethod >>> 32);
|
||||||
if (classIndex != lastClass) {
|
if (classIndex != lastClass) {
|
||||||
if (lastClass >= 0) {
|
if (lastClass >= 0) {
|
||||||
ClassMetadata clsData = classesMetadata.get(lastClass);
|
ClassMetadata clsData = classesMetadata.get(lastClass);
|
||||||
|
@ -454,6 +454,7 @@ public class DebugInformation {
|
||||||
next = new IntegerArray(0);
|
next = new IntegerArray(0);
|
||||||
int methodMappingIndex = 0;
|
int methodMappingIndex = 0;
|
||||||
int classMappingIndex = 0;
|
int classMappingIndex = 0;
|
||||||
|
GeneratedLocation previousLocation = new GeneratedLocation(0, 0);
|
||||||
while (methodMappingIndex < methodMapping.lines.length &&
|
while (methodMappingIndex < methodMapping.lines.length &&
|
||||||
classMappingIndex < classMapping.lines.length) {
|
classMappingIndex < classMapping.lines.length) {
|
||||||
GeneratedLocation methodLoc = new GeneratedLocation(methodMapping.lines[methodMappingIndex],
|
GeneratedLocation methodLoc = new GeneratedLocation(methodMapping.lines[methodMappingIndex],
|
||||||
|
@ -462,38 +463,39 @@ public class DebugInformation {
|
||||||
classMapping.columns[classMappingIndex]);
|
classMapping.columns[classMappingIndex]);
|
||||||
int cmp = methodLoc.compareTo(classLoc);
|
int cmp = methodLoc.compareTo(classLoc);
|
||||||
if (cmp < 0) {
|
if (cmp < 0) {
|
||||||
|
addMethodEntrance(previousLocation, methodLoc);
|
||||||
|
previousLocation = methodLoc;
|
||||||
methodIndex = methodMapping.values[methodMappingIndex++];
|
methodIndex = methodMapping.values[methodMappingIndex++];
|
||||||
addMethodEntrance(methodLoc);
|
|
||||||
} else if (cmp > 0) {
|
} else if (cmp > 0) {
|
||||||
|
addMethodEntrance(previousLocation, classLoc);
|
||||||
|
previousLocation = classLoc;
|
||||||
classIndex = classMapping.values[classMappingIndex++];
|
classIndex = classMapping.values[classMappingIndex++];
|
||||||
addMethodEntrance(classLoc);
|
|
||||||
} else {
|
} else {
|
||||||
|
addMethodEntrance(previousLocation, classLoc);
|
||||||
|
previousLocation = classLoc;
|
||||||
methodIndex = methodMapping.values[methodMappingIndex++];
|
methodIndex = methodMapping.values[methodMappingIndex++];
|
||||||
classIndex = classMapping.values[classMappingIndex++];
|
classIndex = classMapping.values[classMappingIndex++];
|
||||||
addMethodEntrance(classLoc);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (methodMappingIndex < methodMapping.lines.length) {
|
while (methodMappingIndex < methodMapping.lines.length) {
|
||||||
GeneratedLocation methodLoc = new GeneratedLocation(methodMapping.lines[methodMappingIndex],
|
GeneratedLocation methodLoc = new GeneratedLocation(methodMapping.lines[methodMappingIndex],
|
||||||
methodMapping.columns[methodMappingIndex]);
|
methodMapping.columns[methodMappingIndex]);
|
||||||
|
addMethodEntrance(previousLocation, methodLoc);
|
||||||
|
previousLocation = methodLoc;
|
||||||
methodIndex = methodMapping.values[methodMappingIndex++];
|
methodIndex = methodMapping.values[methodMappingIndex++];
|
||||||
addMethodEntrance(methodLoc);
|
|
||||||
}
|
}
|
||||||
while (classMappingIndex < classMapping.lines.length) {
|
while (classMappingIndex < classMapping.lines.length) {
|
||||||
GeneratedLocation classLoc = new GeneratedLocation(classMapping.lines[classMappingIndex],
|
GeneratedLocation classLoc = new GeneratedLocation(classMapping.lines[classMappingIndex],
|
||||||
classMapping.columns[classMappingIndex]);
|
classMapping.columns[classMappingIndex]);
|
||||||
|
addMethodEntrance(previousLocation, classLoc);
|
||||||
|
previousLocation = classLoc;
|
||||||
classIndex = classMapping.values[classMappingIndex++];
|
classIndex = classMapping.values[classMappingIndex++];
|
||||||
addMethodEntrance(classLoc);
|
|
||||||
}
|
}
|
||||||
return assemble();
|
return assemble();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addMethodEntrance(GeneratedLocation location) {
|
private void addMethodEntrance(GeneratedLocation location, GeneratedLocation limit) {
|
||||||
int lineIndex = indexByKey(lineMapping, location);
|
if (classIndex < 0 || methodIndex < 0) {
|
||||||
if (lineIndex < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (lineMapping.values[lineIndex] < 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long exactMethod = ((long)classIndex << 32) | methodIndex;
|
long exactMethod = ((long)classIndex << 32) | methodIndex;
|
||||||
|
@ -501,14 +503,35 @@ public class DebugInformation {
|
||||||
if (exactMethodIndex == null) {
|
if (exactMethodIndex == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int lineIndex = indexByKey(lineMapping, location);
|
||||||
|
if (lineIndex < 0) {
|
||||||
|
lineIndex = 0;
|
||||||
|
}
|
||||||
|
int line = -1;
|
||||||
|
while (lineIndex < lineMapping.values.length) {
|
||||||
|
location = new GeneratedLocation(lineMapping.lines[lineIndex], lineMapping.columns[lineIndex]);
|
||||||
|
if (location.compareTo(limit) >= 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (lineMapping.values[lineIndex] >= 0) {
|
||||||
|
line = lineMapping.values[lineIndex];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++lineIndex;
|
||||||
|
}
|
||||||
|
if (line == -1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int ptr = start[exactMethodIndex];
|
int ptr = start[exactMethodIndex];
|
||||||
start[exactMethodIndex] = data.size();
|
start[exactMethodIndex] = data.size();
|
||||||
next.add(ptr);
|
next.add(ptr);
|
||||||
data.add(location.getColumn());
|
|
||||||
ptr = data.size();
|
ptr = data.size();
|
||||||
|
data.add(location.getColumn());
|
||||||
next.add(ptr);
|
next.add(ptr);
|
||||||
data.add(location.getLine());
|
|
||||||
start[exactMethodIndex] = data.size();
|
start[exactMethodIndex] = data.size();
|
||||||
|
data.add(location.getLine());
|
||||||
}
|
}
|
||||||
|
|
||||||
private MethodEntrances assemble() {
|
private MethodEntrances assemble() {
|
||||||
|
@ -728,7 +751,7 @@ public class DebugInformation {
|
||||||
MethodReference[] references = new MethodReference[end - start];
|
MethodReference[] references = new MethodReference[end - start];
|
||||||
for (int i = 0; i < references.length; ++i) {
|
for (int i = 0; i < references.length; ++i) {
|
||||||
long item = exactMethods[data[start + i]];
|
long item = exactMethods[data[start + i]];
|
||||||
int classIndex = (int)(item >> 32);
|
int classIndex = (int)(item >>> 32);
|
||||||
int methodIndex = (int)item;
|
int methodIndex = (int)item;
|
||||||
references[i] = new MethodReference(classNames[classIndex],
|
references[i] = new MethodReference(classNames[classIndex],
|
||||||
MethodDescriptor.parse(methods[methodIndex]));
|
MethodDescriptor.parse(methods[methodIndex]));
|
||||||
|
|
|
@ -90,6 +90,14 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
||||||
methodMapping.add(locationProvider, methodIndex);
|
methodMapping.add(locationProvider, methodIndex);
|
||||||
currentMethod = method;
|
currentMethod = method;
|
||||||
}
|
}
|
||||||
|
if (currentClass != null) {
|
||||||
|
int classIndex = classes.index(currentClass);
|
||||||
|
long fullIndex = ((long)classIndex << 32) | methodIndex;
|
||||||
|
if (!exactMethodMap.containsKey(fullIndex)) {
|
||||||
|
exactMethodMap.put(fullIndex, exactMethods.size());
|
||||||
|
exactMethods.add(fullIndex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -113,7 +121,7 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
||||||
if (method != null) {
|
if (method != null) {
|
||||||
int methodIndex = methods.index(method.getDescriptor().toString());
|
int methodIndex = methods.index(method.getDescriptor().toString());
|
||||||
int classIndex = classes.index(method.getClassName());
|
int classIndex = classes.index(method.getClassName());
|
||||||
long fullIndex = (((long)classIndex << 32) | methodIndex) + 1;
|
long fullIndex = ((long)classIndex << 32) | methodIndex;
|
||||||
Integer exactMethodIndex = exactMethodMap.get(fullIndex);
|
Integer exactMethodIndex = exactMethodMap.get(fullIndex);
|
||||||
if (exactMethodIndex == null) {
|
if (exactMethodIndex == null) {
|
||||||
exactMethodIndex = exactMethods.size();
|
exactMethodIndex = exactMethods.size();
|
||||||
|
|
|
@ -98,10 +98,12 @@ class DebugInformationReader {
|
||||||
int[] lines = new int[readUnsignedNumber()];
|
int[] lines = new int[readUnsignedNumber()];
|
||||||
int[] files = new int[lines.length];
|
int[] files = new int[lines.length];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int line = 0;
|
int line = -1;
|
||||||
offsets.add(0);
|
|
||||||
while (i < lines.length) {
|
while (i < lines.length) {
|
||||||
int passedLines = readUnsignedNumber();
|
int passedLines = readUnsignedNumber();
|
||||||
|
for (int j = 0; j < passedLines; ++j) {
|
||||||
|
offsets.add(i);
|
||||||
|
}
|
||||||
line += passedLines;
|
line += passedLines;
|
||||||
int sz = readUnsignedNumber();
|
int sz = readUnsignedNumber();
|
||||||
if (sz == 0) {
|
if (sz == 0) {
|
||||||
|
@ -110,7 +112,7 @@ class DebugInformationReader {
|
||||||
} else if (sz == 1) {
|
} else if (sz == 1) {
|
||||||
lines[i] = line + 1;
|
lines[i] = line + 1;
|
||||||
files[i++] = index;
|
files[i++] = index;
|
||||||
}
|
} else {
|
||||||
sz -= 1;
|
sz -= 1;
|
||||||
int last = line;
|
int last = line;
|
||||||
for (int j = 0; j < sz; ++j) {
|
for (int j = 0; j < sz; ++j) {
|
||||||
|
@ -118,10 +120,9 @@ class DebugInformationReader {
|
||||||
lines[i] = last;
|
lines[i] = last;
|
||||||
files[i++] = index + readNumber();
|
files[i++] = index + readNumber();
|
||||||
}
|
}
|
||||||
for (int j = 0; j < passedLines; ++j) {
|
}
|
||||||
|
}
|
||||||
offsets.add(i);
|
offsets.add(i);
|
||||||
}
|
|
||||||
}
|
|
||||||
DebugInformation.CFG cfg = new DebugInformation.CFG();
|
DebugInformation.CFG cfg = new DebugInformation.CFG();
|
||||||
cfg.offsets = offsets.getAll();
|
cfg.offsets = offsets.getAll();
|
||||||
cfg.lines = lines;
|
cfg.lines = lines;
|
||||||
|
|
|
@ -165,7 +165,7 @@ class DebugInformationWriter {
|
||||||
|
|
||||||
private void writeCFG(DebugInformation.CFG mapping, int fileIndex) throws IOException {
|
private void writeCFG(DebugInformation.CFG mapping, int fileIndex) throws IOException {
|
||||||
writeUnsignedNumber(mapping.lines.length);
|
writeUnsignedNumber(mapping.lines.length);
|
||||||
int lastLine = 0;
|
int lastLine = -1;
|
||||||
for (int i = 0; i < mapping.offsets.length - 1; ++i) {
|
for (int i = 0; i < mapping.offsets.length - 1; ++i) {
|
||||||
int start = mapping.offsets[i];
|
int start = mapping.offsets[i];
|
||||||
int sz = mapping.offsets[i + 1] - start;
|
int sz = mapping.offsets[i + 1] - start;
|
||||||
|
|
|
@ -102,8 +102,9 @@ public class Debugger {
|
||||||
GeneratedLocation genLoc = new GeneratedLocation(frame.originalLocation.getLine(),
|
GeneratedLocation genLoc = new GeneratedLocation(frame.originalLocation.getLine(),
|
||||||
frame.originalLocation.getColumn());
|
frame.originalLocation.getColumn());
|
||||||
MethodReference callMethod = mainDebugInfo != null ? mainDebugInfo.getCallSite(genLoc) : null;
|
MethodReference callMethod = mainDebugInfo != null ? mainDebugInfo.getCallSite(genLoc) : null;
|
||||||
for (Map.Entry<String, DebugInformation> entry : debugInformationMap.entrySet()) {
|
String script = frame.originalLocation.getScript();
|
||||||
DebugInformation debugInfo = entry.getValue();
|
DebugInformation debugInfo = debugInformationMap.get(script);
|
||||||
|
if (debugInfo != null) {
|
||||||
SourceLocation[] following = debugInfo.getFollowingLines(frame.getLocation());
|
SourceLocation[] following = debugInfo.getFollowingLines(frame.getLocation());
|
||||||
if (following != null) {
|
if (following != null) {
|
||||||
for (SourceLocation successor : following) {
|
for (SourceLocation successor : following) {
|
||||||
|
@ -111,7 +112,7 @@ public class Debugger {
|
||||||
exits = true;
|
exits = true;
|
||||||
} else {
|
} else {
|
||||||
for (GeneratedLocation loc : debugInfo.getGeneratedLocations(successor)) {
|
for (GeneratedLocation loc : debugInfo.getGeneratedLocations(successor)) {
|
||||||
successors.add(new JavaScriptLocation(entry.getKey(), loc.getLine(), loc.getColumn()));
|
successors.add(new JavaScriptLocation(script, loc.getLine(), loc.getColumn()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +120,7 @@ public class Debugger {
|
||||||
if (enterMethod && callMethod != null) {
|
if (enterMethod && callMethod != null) {
|
||||||
for (MethodReference potentialMethod : debugInfo.getOverridingMethods(callMethod)) {
|
for (MethodReference potentialMethod : debugInfo.getOverridingMethods(callMethod)) {
|
||||||
for (GeneratedLocation loc : debugInfo.getMethodEntrances(potentialMethod)) {
|
for (GeneratedLocation loc : debugInfo.getMethodEntrances(potentialMethod)) {
|
||||||
successors.add(new JavaScriptLocation(entry.getKey(), loc.getLine(), loc.getColumn()));
|
successors.add(new JavaScriptLocation(script, loc.getLine(), loc.getColumn()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user