mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
wasm gc: fix issues with stack trace deobfuscator
This commit is contained in:
parent
cfd381f47b
commit
d37ab2a276
|
@ -25,4 +25,12 @@ public class DeobfuscatedLocation {
|
|||
this.method = method;
|
||||
this.line = line;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
var sourceLocation = file == null || line < 0
|
||||
? "Unknow source"
|
||||
: file.name() + ":" + line;
|
||||
return " at " + method.cls().name() + "." + method.name() + "(" + sourceLocation + ")";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -61,15 +61,13 @@ public class LineInfo {
|
|||
}
|
||||
var result = new DeobfuscatedLocation[location.depth()];
|
||||
var method = sequence.method();
|
||||
var i = result.length - 1;
|
||||
while (true) {
|
||||
result[i--] = new DeobfuscatedLocation(location.file(), method, location.line());
|
||||
if (i < 0) {
|
||||
break;
|
||||
}
|
||||
method = location.inlining().method();
|
||||
var i = 0;
|
||||
while (i < result.length - 1) {
|
||||
var inlining = location.inlining();
|
||||
result[i++] = new DeobfuscatedLocation(location.file(), inlining.method(), location.line());
|
||||
location = location.inlining().location();
|
||||
}
|
||||
result[i] = new DeobfuscatedLocation(location.file(), method, location.line());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,8 @@ public class LineInfoCommandExecutor implements LineInfoCommandVisitor {
|
|||
@Override
|
||||
public void visit(LineInfoExitCommand command) {
|
||||
address = command.address();
|
||||
file = inliningLocation.location().file();
|
||||
line = inliningLocation.location().line();
|
||||
inliningLocation = inliningLocation.location().inlining();
|
||||
}
|
||||
|
||||
|
|
|
@ -779,6 +779,7 @@ public abstract class BaseWasmGenerationVisitor implements StatementVisitor, Exp
|
|||
var callSiteId = generateCallSiteId(expr.getLocation());
|
||||
if (needsCallSiteId() && isManagedCall(expr.getMethod())) {
|
||||
var invocation = generateInvocation(expr, callSiteId);
|
||||
invocation.setLocation(expr.getLocation());
|
||||
var type = mapType(expr.getMethod().getReturnType());
|
||||
|
||||
List<WasmExpression> targetList;
|
||||
|
@ -828,6 +829,7 @@ public abstract class BaseWasmGenerationVisitor implements StatementVisitor, Exp
|
|||
return block;
|
||||
} else {
|
||||
var resultExpr = generateInvocation(expr, null);
|
||||
resultExpr.setLocation(expr.getLocation());
|
||||
return trivialInvocation(resultExpr, resultConsumer, expr.getLocation(), willDrop);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ import org.teavm.backend.wasm.model.expression.WasmTest;
|
|||
import org.teavm.backend.wasm.model.expression.WasmThrow;
|
||||
import org.teavm.backend.wasm.model.expression.WasmTry;
|
||||
import org.teavm.backend.wasm.model.expression.WasmUnreachable;
|
||||
import org.teavm.model.MethodReference;
|
||||
import org.teavm.model.InliningInfo;
|
||||
import org.teavm.model.TextLocation;
|
||||
|
||||
class WasmBinaryRenderingVisitor implements WasmExpressionVisitor {
|
||||
|
@ -100,8 +100,8 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor {
|
|||
private int addressOffset;
|
||||
private int depth;
|
||||
private Map<WasmBlock, Integer> blockDepths = new HashMap<>();
|
||||
private List<MethodReference> methodStack = new ArrayList<>();
|
||||
private List<MethodReference> currentMethodStack = new ArrayList<>();
|
||||
private List<InliningInfo> methodStack = new ArrayList<>();
|
||||
private List<InliningInfo> currentMethodStack = new ArrayList<>();
|
||||
private TextLocation textLocationToEmit;
|
||||
private boolean deferTextLocationToEmit;
|
||||
private TextLocation lastEmittedLocation;
|
||||
|
@ -1441,13 +1441,13 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor {
|
|||
var loc = textLocationToEmit;
|
||||
var inlining = loc != null ? loc.getInlining() : null;
|
||||
while (inlining != null) {
|
||||
currentMethodStack.add(inlining.getMethod());
|
||||
currentMethodStack.add(inlining);
|
||||
inlining = inlining.getParent();
|
||||
}
|
||||
Collections.reverse(currentMethodStack);
|
||||
var commonPart = 0;
|
||||
while (commonPart < currentMethodStack.size() && commonPart < methodStack.size()
|
||||
&& currentMethodStack.get(commonPart).equals(methodStack.get(commonPart))) {
|
||||
&& currentMethodStack.get(commonPart) == methodStack.get(commonPart)) {
|
||||
++commonPart;
|
||||
}
|
||||
while (methodStack.size() > commonPart) {
|
||||
|
@ -1457,7 +1457,8 @@ class WasmBinaryRenderingVisitor implements WasmExpressionVisitor {
|
|||
while (commonPart < currentMethodStack.size()) {
|
||||
var method = currentMethodStack.get(commonPart++);
|
||||
methodStack.add(method);
|
||||
debugLines.start(method);
|
||||
debugLines.location(method.getFileName(), method.getLine());
|
||||
debugLines.start(method.getMethod());
|
||||
}
|
||||
currentMethodStack.clear();
|
||||
if (loc != null) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user