Ignore SWF files that are not instrumented by FFDec.

Fixed: AS1/2 debug panel not visible on first break
This commit is contained in:
Jindra Petřík
2026-02-15 16:12:47 +01:00
parent 7260e67a72
commit 3a44891b26
6 changed files with 39 additions and 9 deletions
@@ -466,7 +466,7 @@ public class DebugPanel extends JPanel {
});
add(new HeaderLabel(AppStrings.translate("debugpanel.header")), BorderLayout.NORTH);
add(varTabs, BorderLayout.CENTER);
add(varTabs, BorderLayout.CENTER);
}
/* private void getVariableList() {
@@ -323,6 +323,7 @@ public class DebuggerSession {
Runnable r = new Runnable() {
@Override
public void run() {
boolean modulesEmptyBefore = debuggedSwfs.isEmpty();
try {
for (InSwfInfo.SwfInfo s : t.swfInfos) {
try {
@@ -350,11 +351,12 @@ public class DebuggerSession {
connected = false;
}
disconnected();
return;
} else {
debuggedSwfs.put((int) s.index, debuggedSwf);
if (debuggedSwfs.size() == 1) { //it's the first one
con.isAS3 = debuggedSwf.isAS3();
}
}
}
} catch (IOException | NoSuchAlgorithmException ex) {
//ignore
@@ -370,7 +372,26 @@ public class DebuggerSession {
}
try {
if (!debuggedSwfs.isEmpty()) {
Set<String> hashes = new LinkedHashSet<>();
for (int file : modulePaths.keySet()) {
String path = modulePaths.get(file);
if (!path.contains(":")) {
//This is probably SWF file instrumented by another software
throw new IOException("Missing hash");
}
String hash = path.substring(0, path.indexOf(":"));
hashes.add(hash);
}
for (String hash : hashes) {
if (Main.findOpenedSwfByHash(hash) == null) {
//This is probably SWF file instrumented by another software
throw new IOException("SWF with hash " + hash + " not found");
}
}
if (!debuggedSwfs.isEmpty() && modulesEmptyBefore) {
if (con.isAS3) {
//Widelines - only AS3, it hangs in AS1/2 and SWD does not support UI32 lines
con.wideLines = commands.getOption("wide_line_player", "false").equals("true");
@@ -457,6 +478,11 @@ public class DebuggerSession {
@Override
public void run() {
synchronized (DebuggerSession.this) {
if (!connected) {
return;
}
paused = true;
Logger.getLogger(DebuggerSession.class.getName()).log(Level.FINE, "paused");
}
+2 -2
View File
@@ -1120,9 +1120,9 @@ public class Main {
return null;
}
SWF currentSwf = mainFrame.getPanel().getCurrentSwf();
if (currentSwf == null) {
if (currentSwf == null) {
return null;
}
}
return getDebugHandler().getSessionContainingSwf(currentSwf);
}
@@ -2878,7 +2878,7 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
if (asms.containsKey(rawScriptName)) {
oldItem = null;
getCurrentTree().setSelectionPath(null);
setTagTreeSelectedNode(getCurrentTree(), asms.get(rawScriptName));
setTagTreeSelectedNode(getCurrentTree(), asms.get(rawScriptName));
}
/*if (actionPanel != null && asms.containsKey(rawScriptName)) {
actionPanel.setSource(asms.get(rawScriptName), true);
@@ -5776,12 +5776,13 @@ public final class MainPanel extends JPanel implements TreeSelectionListener, Se
private void valueChanged(Object source, TreePath selectedPath) {
TreeItem treeItem = selectedPath == null ? null : (TreeItem) selectedPath.getLastPathComponent();
Main.updateSession();
if (treeItem == null) {
if (treeItem == null) {
updateUi(null);
reload(false);
return;
}
Main.updateSession();
if (!(treeItem instanceof OpenableList)) {
Openable openable = treeItem.getOpenable();
@@ -1158,6 +1158,7 @@ public class ActionPanel extends JPanel implements SearchListener<ScriptSearchRe
editor.addTextChangedListener(this::editorTextChanged);
decompiledEditor.addTextChangedListener(this::decompiledEditorTextChanged);
debugPanel.refresh(Main.getCurrentDebugSession());
}
private void deobfuscateButtonActionPerformed(ActionEvent evt) {
@@ -16,6 +16,7 @@
*/
package com.jpexs.decompiler.flash.gui.editor;
import com.jpexs.decompiler.flash.SWF;
import com.jpexs.decompiler.flash.gui.Main;
import java.awt.BasicStroke;
import java.awt.Color;
@@ -142,7 +143,8 @@ public class DebuggableEditorPane extends LineMarkedEditorPane implements BreakP
ipHash = ipPath.substring(0, ipPath.indexOf(":"));
ipPath = ipPath.substring(ipPath.indexOf(":") + 1);
}
String myhash = Main.getSwfHash(Main.getMainFrame().getPanel().getCurrentSwf());
SWF currentSwf = Main.getMainFrame().getPanel().getCurrentSwf();
String myhash = currentSwf == null ? "myunknown" : Main.getSwfHash(currentSwf);
if (ip > 0 && ipPath != null && ipHash.equals(myhash) && ipPath.equals(breakPointScriptName)) {
addColorMarker(ip + firstLineOffset(), IP_MARKER);
}