Fixed Incorrect debugger line numbers when "Open loaded while playing" is enabled

Fixed AS3 debugger - Slow injecting debug info - now faster
Fixed AS3 debugger - obfuscated classes debugging
Fixed Delayed open loaded SWFs while playing
Fixed AS3 Direct editation - script initializer for main document class

Changed Wrong unicode escape `{invalid_utf8:xxx}` changed to `{invalid_utf8=xxx}` for compatibility with file names
This commit is contained in:
Jindra Petřík
2023-12-30 18:06:08 +01:00
parent e54973b761
commit bd6c953218
53 changed files with 325 additions and 80 deletions
@@ -577,8 +577,7 @@ public class DebuggerHandler implements DebugConnectionListener {
}
Main.getMainFrame().getPanel().updateMenu();
boolean isAS3 = (Main.getMainFrame().getPanel().getCurrentSwf().isAS3());
//enlog(DebuggerConnection.class);
//enlog(DebuggerCommands.class);
//enlog(DebuggerHandler.class);
@@ -608,6 +607,7 @@ public class DebuggerHandler implements DebugConnectionListener {
final Pattern patAS3 = Pattern.compile("^(.*);(.*);(.*)\\.as$");
final Pattern patAS3PCode = Pattern.compile("^#PCODE abc:([0-9]+),script:([0-9]+),class:(-?[0-9]+),trait:(-?[0-9]+),method:([0-9]+),body:([0-9]+);(.*)$");
boolean isAS3 = (Main.getMainFrame().getPanel().getCurrentSwf().isAS3());
try {
con.addMessageListener(new DebugMessageListener<InNumScript>() {
@@ -627,14 +627,15 @@ public class DebuggerHandler implements DebugConnectionListener {
moduleToSwfIndex.put(sc.module, sc.swfIndex);
int file = sc.module;
String name = sc.name;
String[] parts = name.split(";");
name = name.replaceAll("\\[(invalid_utf8=[0-9]+)\\]", "{$1}");
Matcher m;
if ((m = patAS3.matcher(name)).matches()) {
String clsNameWithSuffix = m.group(3);
String pkg = m.group(2).replace("\\", ".");
String clsNameWithSuffix = m.group(3).replace("{{semicolon}}", ";");
String pkg = m.group(2).replace("{{semicolon}}", ";").replace("\\", ".");
m = patAS3PCode.matcher(name);
if (m.matches()) {
moduleToClassIndex.put(file, Integer.parseInt(m.group(3)));
moduleToTraitIndex.put(file, Integer.parseInt(m.group(4)));
@@ -642,7 +643,7 @@ public class DebuggerHandler implements DebugConnectionListener {
name = DottedChain.parseWithSuffix(pkg).addWithSuffix(clsNameWithSuffix).toString();
name = "#PCODE abc:" + m.group(1) + ",body:" + m.group(6) + ";" + name;
} else {
name = DottedChain.parseWithSuffix(pkg).addWithSuffix(clsNameWithSuffix).toString();
name = DottedChain.parseWithSuffix(pkg).addWithSuffix(clsNameWithSuffix).toPrintableString(con.isAS3);
}
}
Logger.getLogger(DebuggerHandler.class.getName()).log(Level.FINE, "Script added - index {0} name: {1}", new Object[]{file, name});
@@ -762,7 +763,7 @@ public class DebuggerHandler implements DebugConnectionListener {
} else if (reasonInt != InBreakReason.REASON_SCRIPT_LOADED) {
Logger.getLogger(DebuggerCommands.class.getName()).log(Level.SEVERE, "Invalid file: {0}", message.file);
return;
//return;
}
final String[] reasonNames = new String[]{"unknown", "breakpoint", "watch", "fault", "stopRequest", "step", "halt", "scriptLoaded"};
+3 -2
View File
@@ -456,8 +456,6 @@ public class Main {
@Override
public SWF prepare(SWF instrSWF) throws InterruptedException {
instrSWF = super.prepare(instrSWF);
EventListener prepEventListner = new EventListener() {
@Override
public void handleExportingEvent(String type, int index, int count, Object data) {
@@ -525,6 +523,9 @@ public class Main {
//ignore, return instrSWF
}
instrSWF.removeEventListener(prepEventListner);
instrSWF = super.prepare(instrSWF);
return instrSWF;
}
}
@@ -152,6 +152,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
}
writer.appendNoHilight("end ; trait").newLine();
}
writer.finishHilights();
return new HighlightedText(writer);
}
@@ -180,6 +181,7 @@ public class ASMSourceEditorPane extends DebuggableEditorPane implements CaretLi
if (bodyIndex > -1) {
Helper.byteArrayToHexWithHeader(writer, abc.bodies.get(bodyIndex).getCodeBytes());
}
writer.finishHilights();
textHexOnly = new HighlightedText(writer);
}
setText(textHexOnly);
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.gui.ViewMessages;
import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightingList;
import com.jpexs.decompiler.flash.tags.Tag;
import java.awt.BorderLayout;
import java.io.IOException;
@@ -51,7 +52,7 @@ public class ClassTraitDetailPanel extends JPanel implements TraitDetail {
private TraitClass trait;
private List<Highlighting> specialHilights;
private HighlightingList specialHilights;
private boolean ignoreCaret = false;
@@ -103,6 +104,7 @@ public class ClassTraitDetailPanel extends JPanel implements TraitDetail {
writer.unindent();
}
writer.appendNoHilight("end ; trait");
writer.finishHilights();
String s = writer.toString();
specialHilights = writer.specialHilights;
classEditor.setText(s);
@@ -27,6 +27,7 @@ import com.jpexs.decompiler.flash.gui.ViewMessages;
import com.jpexs.decompiler.flash.gui.editor.LineMarkedEditorPane;
import com.jpexs.decompiler.flash.helpers.HighlightedTextWriter;
import com.jpexs.decompiler.flash.helpers.hilight.Highlighting;
import com.jpexs.decompiler.flash.helpers.hilight.HighlightingList;
import com.jpexs.decompiler.flash.tags.Tag;
import java.awt.BorderLayout;
import java.io.IOException;
@@ -53,7 +54,7 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail {
private boolean showWarning = false;
private List<Highlighting> specialHilights;
private HighlightingList specialHilights;
private boolean ignoreCaret = false;
@@ -105,6 +106,7 @@ public class SlotConstTraitDetailPanel extends JPanel implements TraitDetail {
writer.unindent();
}
writer.appendNoHilight("end ; trait");
writer.finishHilights();
String s = writer.toString();
specialHilights = writer.specialHilights;
showWarning = trait.isConst() || isStatic;
@@ -112,6 +112,7 @@ public class TraitsListItem {
insideInterface = abc.instance_info.get(classIndex).isInterface();
}
trait.toStringHeader(null, convertData, "", abc, true, ScriptExportMode.AS, scriptIndex, classIndex, writer, new ArrayList<>(), false, insideInterface);
writer.finishHilights();
s = writer.toString();
} else {
ConvertData convertData = new ConvertData();
@@ -127,6 +128,7 @@ public class TraitsListItem {
insideInterface = abc.instance_info.get(classIndex).isInterface();
}
trait.toStringHeader(null, convertData, "", abc, false, ScriptExportMode.AS, scriptIndex, classIndex, writer, new ArrayList<>(), false, insideInterface);
writer.finishHilights();
s = writer.toString();
}
} catch (InterruptedException ex) {
@@ -398,6 +398,7 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
}
asm.removeDisassemblyListener(listener);
writer.finishHilights();
return new HighlightedText(writer);
}
@@ -432,6 +433,7 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
if (srcHexOnly == null) {
HighlightedTextWriter writer = new HighlightedTextWriter(Configuration.getCodeFormatting(), true);
Helper.byteArrayToHexWithHeader(writer, src.getActionBytes().getRangeData());
writer.finishHilights();
srcHexOnly = new HighlightedText(writer);
}
@@ -2286,7 +2286,7 @@ public class TagTreeContextMenu extends JPopupMenu {
+ "public class " + IdentifiersDeobfuscation.printIdentifier(true, classSimpleName) + " {"
+ " }"
+ "}";
parser.addScript(script, fileName, 0, 0);
parser.addScript(script, fileName, 0, 0, swf.getDocumentClass());
} catch (IOException | InterruptedException | AVM2ParseException | CompilationException ex) {
Logger.getLogger(TagTreeContextMenu.class.getName()).log(Level.SEVERE, "Error during script compilation", ex);
}