AS1/2 debugger

debugger listening only when really debugging started
fail to listen message
break reason displayed
This commit is contained in:
Jindra Petřík
2015-11-21 19:12:42 +01:00
parent 6d7ebb2619
commit 1237762e60
32 changed files with 1355 additions and 626 deletions
@@ -21,6 +21,7 @@ import com.jpexs.decompiler.flash.BaseLocalData;
import com.jpexs.decompiler.flash.DisassemblyListener;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.SWFOutputStream;
import com.jpexs.decompiler.flash.abc.avm2.parser.script.Reference;
import com.jpexs.decompiler.flash.action.deobfuscation.ActionDeobfuscator;
import com.jpexs.decompiler.flash.action.model.ActionItem;
import com.jpexs.decompiler.flash.action.model.ConstantPool;
@@ -109,6 +110,8 @@ public abstract class Action implements GraphSourceItem {
private boolean ignored = false;
public long fileOffset = -1;
/**
* Action type identifier
*/
@@ -121,6 +124,11 @@ public abstract class Action implements GraphSourceItem {
private long address;
@Override
public long getLineOffset() {
return fileOffset;
}
/**
* Names of ActionScript properties
*/
@@ -937,11 +945,12 @@ public abstract class Action implements GraphSourceItem {
this.ignored = ignored;
}
public static List<GraphTargetItem> actionsPartToTree(HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, TranslateStack stack, List<Action> actions, int start, int end, int version, int staticOperation, String path) throws InterruptedException {
public static List<GraphTargetItem> actionsPartToTree(Reference<GraphSourceItem> fi, HashMap<Integer, String> registerNames, HashMap<String, GraphTargetItem> variables, HashMap<String, GraphTargetItem> functions, TranslateStack stack, List<Action> actions, int start, int end, int version, int staticOperation, String path) throws InterruptedException {
if (start < actions.size() && (end > 0) && (start > 0)) {
logger.log(Level.FINE, "Entering {0}-{1}{2}", new Object[]{start, end, actions.size() > 0 ? (" (" + actions.get(start).toString() + " - " + actions.get(end == actions.size() ? end - 1 : end) + ")") : ""});
}
ActionLocalData localData = new ActionLocalData(registerNames, variables, functions);
localData.lineStartAction = fi.getVal();
List<GraphTargetItem> output = new ArrayList<>();
int ip = start;
boolean isWhile = false;
@@ -964,6 +973,10 @@ public abstract class Action implements GraphSourceItem {
ip++;
continue;
}
if (stack.isEmpty()) {
localData.lineStartAction = action;
fi.setVal(action);
}
if (action instanceof GraphSourceItemContainer) {
GraphSourceItemContainer cnt = (GraphSourceItemContainer) action;
//List<GraphTargetItem> out=actionsPartToTree(new HashMap<Integer, String>(), new HashMap<String, GraphTargetItem>(),new HashMap<String, GraphTargetItem>(), new TranslateStack(), src, ip+1,endip-1 , version);
@@ -79,7 +79,11 @@ public class ActionGraphSource extends GraphSource {
@Override
public List<GraphTargetItem> translatePart(GraphPart part, BaseLocalData localData, TranslateStack stack, int start, int end, int staticOperation, String path) throws InterruptedException {
return Action.actionsPartToTree(registerNames, variables, functions, stack, actions, start, end, version, staticOperation, path);
Reference<GraphSourceItem> fi = new Reference<>(localData.lineStartInstruction);
List<GraphTargetItem> r = Action.actionsPartToTree(fi, registerNames, variables, functions, stack, actions, start, end, version, staticOperation, path);
localData.lineStartInstruction = fi.getVal();
return r;
}
private List<Long> posCache = null;
@@ -796,6 +796,7 @@ public class ActionListReader {
if ((a = sis.readAction()) == null) {
break;
}
a.fileOffset = ip;
int actionLengthWithHeader = a.getTotalActionLength();